Ë
    èÿæi_  ã                   ó*  — d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d	„ Zed
„ «       Zed„ «       Zed„ «       Z e ej,                  e«      dd¬«      d„ «       Zed„ «       Zd„ Zed„ «       Zed„ «       Zed„ «       Zy)é    )Úir)ÚcudaÚtypes)Úcgutils)ÚRequireLiteralValueÚNumbaValueError)Ú	signature)Úoverload_attribute)Ú	nvvmutils)Ú	intrinsicc                 óâ   — | j                   }|dk(  rt        j                  }n4|dv r%t        j                  t        j                  |«      }nt	        d«      ‚t        |t        j                  «      S )Né   )é   é   zargument can only be 1, 2, 3)Úliteral_valuer   Úint64ÚUniTupler   r	   Úint32)ÚndimÚvalÚrestypes      új/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/numba/cuda/intrinsics.pyÚ_type_grid_functionr      sU   € Ø
×
Ñ
€CØ
ˆa‚xÜ—+‘+‰Ø	�‰Ü—.‘.¤§¡¨cÓ2‰äÐ<Ó=Ð=ä�WœeŸk™kÓ*Ð*ó    c                 óp   — t        |t        j                  «      st        |«      ‚t	        |«      }d„ }||fS )a  grid(ndim)

    Return the absolute position of the current thread in the entire grid of
    blocks.  *ndim* should correspond to the number of dimensions declared when
    instantiating the kernel. If *ndim* is 1, a single integer is returned.
    If *ndim* is 2 or 3, a tuple of the given number of integers is returned.

    Computation of the first integer is as follows::

        cuda.threadIdx.x + cuda.blockIdx.x * cuda.blockDim.x

    and is similar for the other two indices, but using the ``y`` and ``z``
    attributes.
    c                 ó  — |j                   }|t        j                  k(  rt        j                  |d¬«      S t        |t        j                  «      r7t        j                  ||j                  ¬«      }t        j                  ||«      S y )Nr   )Údim)
Úreturn_typer   r   r   Úget_global_idÚ
isinstancer   Úcountr   Ú
pack_array)ÚcontextÚbuilderÚsigÚargsr   Úidss         r   Úcodegenzgrid.<locals>.codegen1   sf   € Ø—/‘/ˆØ”e—k‘kÒ!Ü×*Ñ*¨7¸Ô:Ð:Ü˜¤§¡Ô0Ü×)Ñ)¨'°w·}±}ÔEˆCÜ×%Ñ% g¨sÓ3Ð3ð 1r   ©r    r   ÚIntegerLiteralr   r   )Ú	typingctxr   r%   r(   s       r   Úgridr,      s:   € ô" �dœE×0Ñ0Ô1Ü! $Ó'Ð'ä
˜dÓ
#€Cò4ð �ˆ<Ðr   c                 ó|   ‡— t        |t        j                  «      st        |«      ‚t	        |«      }d„ Šˆfd„}||fS )a  gridsize(ndim)

    Return the absolute size (or shape) in threads of the entire grid of
    blocks. *ndim* should correspond to the number of dimensions declared when
    instantiating the kernel. If *ndim* is 1, a single integer is returned.
    If *ndim* is 2 or 3, a tuple of the given number of integers is returned.

    Computation of the first integer is as follows::

        cuda.blockDim.x * cuda.gridDim.x

    and is similar for the other two indices, but using the ``y`` and ``z``
    attributes.
    c                 óô   — t        j                  d«      }t        j                  | d|› �«      }t        j                  | d|› �«      }| j	                  | j                  ||«      | j                  ||«      «      S )Né@   zntid.znctaid.)r   ÚIntTyper   Ú	call_sregÚmulÚsext)r$   r   Úi64ÚntidÚnctaids        r   Ú_nthreads_for_dimz#gridsize.<locals>._nthreads_for_dimR   sf   € Ü�j‰j˜‹nˆÜ×"Ñ" 7¨e°C°5¨MÓ:ˆÜ×$Ñ$ W°¸°u¨oÓ>ˆØ�{‰{˜7Ÿ<™<¨¨cÓ2°G·L±LÀÈÓ4MÓNÐNr   c                 óR  •— |j                   } ‰|d«      }|t        j                  k(  r|S t        |t        j                  «      rb ‰|d«      }|j
                  dk(  rt        j                  |||f«      S |j
                  dk(  r" ‰|d«      }t        j                  ||||f«      S y y )NÚxÚyr   r   Úz)r   r   r   r    r   r!   r   r"   )	r#   r$   r%   r&   r   ÚnxÚnyÚnzr7   s	           €r   r(   zgridsize.<locals>.codegenX   s¡   ø€ Ø—/‘/ˆÙ˜w¨Ó,ˆà”e—k‘kÒ!ØˆIÜ˜¤§¡Ô0Ù" 7¨CÓ0ˆBà�}‰} Ò!Ü×)Ñ)¨'°B¸°8Ó<Ð<Ø—‘ !Ò#Ù& w°Ó4�Ü×)Ñ)¨'°B¸¸B°<Ó@Ð@ð $ð 1r   r)   )r+   r   r%   r(   r7   s       @r   Úgridsizer?   <   sB   ø€ ô" �dœE×0Ñ0Ô1Ü! $Ó'Ð'ä
˜dÓ
#€CòOôAð �ˆ<Ðr   c                 óB   — t        t        j                  «      }d„ }||fS )Nc                 ó.   — t        j                  |d«      S )NÚwarpsize)r   r1   )r#   r$   r%   r&   s       r   r(   z_warpsize.<locals>.codegenn   s   € Ü×"Ñ" 7¨JÓ7Ð7r   )r	   r   r   ©r+   r%   r(   s      r   Ú	_warpsizerD   j   s!   € ä
”E—K‘KÓ
 €Cò8ð �ˆ<Ðr   rB   r   )Útargetc                 ó   — d„ }|S )z_
    The size of a warp. All architectures implemented to date have a warp size
    of 32.
    c                 ó   — t        «       S )N)rD   )Úmods    r   Úgetzcuda_warpsize.<locals>.getz   s
   € Ü‹{Ðr   © )rH   rI   s     r   Úcuda_warpsizerK   t   s   € òà€Jr   c                 óB   — t        t        j                  «      }d„ }||fS )a  
    Synchronize all threads in the same thread block.  This function implements
    the same pattern as barriers in traditional multi-threaded programming: this
    function waits until all threads in the block call it, at which point it
    returns control to all its callers.
    c                 óà   — d}|j                   }t        j                  t        j                  «       d«      }t	        j
                  |||«      }|j                  |d«       | j                  «       S )Nzllvm.nvvm.barrier0rJ   )Úmoduler   ÚFunctionTypeÚVoidTyper   Úget_or_insert_functionÚcallÚget_dummy_value)r#   r$   r%   r&   ÚfnameÚlmodÚfntyÚsyncs           r   r(   zsyncthreads.<locals>.codegenŒ   sW   € Ø$ˆØ�~‰~ˆÜ�‰œrŸ{™{›}¨bÓ1ˆÜ×-Ñ-¨d°D¸%Ó@ˆØ�‰�T˜2ÔØ×&Ñ&Ó(Ð(r   )r	   r   ÚnonerC   s      r   ÚsyncthreadsrY   ‚   s#   € ô ”E—J‘JÓ
€Cò)ð �ˆ<Ðr   c                 óœ   ‡— t        |t        j                  «      sy t        t        j                  t        j                  «      }ˆfd„}||fS )Nc                 óä   •— t        j                  t        j                  d«      t        j                  d«      f«      }t        j                  |j
                  |‰«      }|j                  ||«      S )Né    )r   rO   r0   r   rQ   rN   rR   )r#   r$   r%   r&   rV   rW   rT   s         €r   r(   z'_syncthreads_predicate.<locals>.codegen�   sO   ø€ Ü�‰œrŸz™z¨"›~´·
±
¸2³Ð/@ÓAˆÜ×-Ñ-¨g¯n©n¸dÀEÓJˆØ�|‰|˜D $Ó'Ð'r   )r    r   ÚIntegerr	   Úi4)r+   Ú	predicaterT   r%   r(   s     `  r   Ú_syncthreads_predicater`   —   s9   ø€ Ü�i¤§¡Ô/Øä
”E—H‘HœeŸh™hÓ
'€Cô(ð
 �ˆ<Ðr   c                 ó    — d}t        | ||«      S )z 
    syncthreads_count(predicate)

    An extension to numba.cuda.syncthreads where the return value is a count
    of the threads where predicate is true.
    zllvm.nvvm.barrier0.popc©r`   ©r+   r_   rT   s      r   Úsyncthreads_countrd   ¥   s   € ð &€EÜ! )¨Y¸Ó>Ð>r   c                 ó    — d}t        | ||«      S )z�
    syncthreads_and(predicate)

    An extension to numba.cuda.syncthreads where 1 is returned if predicate is
    true for all threads or 0 otherwise.
    zllvm.nvvm.barrier0.andrb   rc   s      r   Úsyncthreads_andrf   ±   s   € ð %€EÜ! )¨Y¸Ó>Ð>r   c                 ó    — d}t        | ||«      S )z›
    syncthreads_or(predicate)

    An extension to numba.cuda.syncthreads where 1 is returned if predicate is
    true for any thread or 0 otherwise.
    zllvm.nvvm.barrier0.orrb   rc   s      r   Úsyncthreads_orrh   ½   s   € ð $€EÜ! )¨Y¸Ó>Ð>r   N)Úllvmliter   Únumbar   r   Ú
numba.corer   Únumba.core.errorsr   r   Únumba.core.typingr	   Únumba.core.extendingr
   Ú
numba.cudar   Únumba.cuda.extendingr   r   r,   r?   rD   ÚModulerK   rY   r`   rd   rf   rh   rJ   r   r   Ú<module>rr      sÞ   ðÝ ç Ý ß BÝ 'Ý 3Ý  Ý *ò	+ð ñó ðð@ ñ*ó ð*ðZ ñó ðñ �L�E—L‘L Ó&¨
¸6ÔBñó Cðð ñó ðò(ð ñ?ó ð?ð ñ?ó ð?ð ñ?ó ñ?r   