§
    1@Äj%  ã                   ó^  — 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dS )é    )Úir)ÚcudaÚtypes)Úcgutils)ÚRequireLiteralValueÚNumbaValueError)Ú	signature)Úoverload_attribute)Ú	nvvmutils)Ú	intrinsicc                 óÐ   — | j         }|dk    rt          j        }n3|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      úFC:\Projects\Historical\venv\Lib\site-packages\numba/cuda/intrinsics.pyÚ_type_grid_functionr      s[   € Ø
Ô
€CØ
ˆa‚x€xÝ”+ˆˆØ	�ˆˆÝ”.¥¤¨cÑ2Ô2ˆˆåÐ<Ñ=Ô=Ð=å�W�eœkÑ*Ô*Ð*ó    c                 ó€   — 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        ¦  «        r0t          j        ||j        ¬¦  «        }t          j	        ||¦  «        S d S )Nr   )Údim)
Úreturn_typer   r   r   Úget_global_idÚ
isinstancer   Úcountr   Ú
pack_array)ÚcontextÚbuilderÚsigÚargsr   Úidss         r   Úcodegenzgrid.<locals>.codegen1   st   € Ø”/ˆØ•e”kÒ!Ð!ÝÔ*¨7¸Ð:Ñ:Ô:Ð:Ý˜¥¤Ñ0Ô0ð 	4ÝÔ)¨'°w´}ÐEÑEÔEˆCÝÔ% g¨sÑ3Ô3Ð3ð	4ð 	4r   ©r    r   ÚIntegerLiteralr   r   )Ú	typingctxr   r%   r(   s       r   Úgridr,      sO   € õ" �d�EÔ0Ñ1Ô1ð (Ý! $Ñ'Ô'Ð'å
˜dÑ
#Ô
#€Cð4ð 4ð 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|› �¦  «        }|                      |                      ||¦  «        |                      ||¦  «        ¦  «        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   so   € ÝŒj˜‰nŒnˆÝÔ" 7¨M°C¨M¨MÑ:Ô:ˆÝÔ$ W¨o¸¨o¨oÑ>Ô>ˆØ�{Š{˜7Ÿ<š<¨¨cÑ2Ô2°G·L²LÀÈÑ4MÔ4MÑNÔNÐNr   c                 óD  •— |j         } ‰|d¦  «        }|t          j        k    r|S t          |t          j        ¦  «        r] ‰|d¦  «        }|j        dk    rt          j        |||f¦  «        S |j        dk    r& ‰|d¦  «        }t          j        ||||f¦  «        S d S d S )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Ò!Ð!ØˆIÝ˜¥¤Ñ0Ô0ð 	AØ"Ð" 7¨CÑ0Ô0ˆBàŒ} Ò!Ð!ÝÔ)¨'°B¸°8Ñ<Ô<Ð<Ø” !Ò#Ð#Ø&Ð& w°Ñ4Ô4�ÝÔ)¨'°B¸¸B°<Ñ@Ô@Ð@ð	Að 	Að
 $Ð#r   r)   )r+   r   r%   r(   r7   s       @r   Úgridsizer?   <   sq   ø€ õ" �d�EÔ0Ñ1Ô1ð (Ý! $Ñ'Ô'Ð'å
˜dÑ
#Ô
#€CðOð Oð OðAð Að Að Að 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Ô7Ð7r   )r	   r   r   ©r+   r%   r(   s      r   Ú	_warpsizerD   j   s,   € å
•E”KÑ
 Ô
 €Cð8ð 8ð 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        |||¦  «        }|                     |d¦  «         |                      ¦   «         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Œ   s_   € Ø$ˆØŒ~ˆÝŒ�rœ{™}œ}¨bÑ1Ô1ˆÝÔ-¨d°D¸%Ñ@Ô@ˆØ�Š�T˜2ÑÔÐØ×&Ò&Ñ(Ô(Ð(r   )r	   r   ÚnonerC   s      r   ÚsyncthreadsrY   ‚   s.   € õ •E”JÑ
Ô
€Cð)ð )ð )ð �ˆ<Ðr   c                 ó–   ‡— t          |t          j        ¦  «        sd S t          t          j        t          j        ¦  «        }ˆfd„}||fS )Nc                 óÚ   •— t          j        t          j        d¦  «        t          j        d¦  «        f¦  «        }t          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�   sQ   ø€ ÝŒ�rœz¨"™~œ~µ´
¸2±´Ð/@ÑAÔAˆÝÔ-¨g¬n¸dÀEÑJÔJˆØ�|Š|˜D $Ñ'Ô'Ð'r   )r    r   ÚIntegerr	   Úi4)r+   Ú	predicaterT   r%   r(   s     `  r   Ú_syncthreads_predicater`   —   sT   ø€ Ý�i¥¤Ñ/Ô/ð Øˆtå
•E”H�eœ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Ð BÐ BÐ BÐ BÐ BÐ BÐ BØ 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø  Ð  Ð  Ð  Ð  Ð  Ø *Ð *Ð *Ð *Ð *Ð *ð	+ð 	+ð 	+ð ðð ñ „ðð@ ð*ð *ñ „ð*ðZ ðð ñ „ðð Ð�L�E”L Ñ&Ô&¨
¸6ÐBÑBÔBðð ñ CÔBðð ðð ñ „ðð(ð ð ð ð?ð ?ñ „ð?ð ð?ð ?ñ „ð?ð ð?ð ?ñ „ð?ð ?ð ?r   