ó
\K]c           @` s‚  d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l j j	 Z
 d d l m Z m Z m Z m Z d d l m Z d e f d „  ƒ  YZ e j e j ƒ Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e j d e ƒ Z e j d e ƒ Z d „  Z d „  Z d „  Z  e j d e  d e! ƒZ" d „  Z# e j d e# d e! ƒZ$ d e f d „  ƒ  YZ% d e f d „  ƒ  YZ& d e f d „  ƒ  YZ' d  e f d! „  ƒ  YZ( d" e f d# „  ƒ  YZ) d$ e f d% „  ƒ  YZ* d& e f d' „  ƒ  YZ+ d( e f d) „  ƒ  YZ, d* e f d+ „  ƒ  YZ- d, e f d- „  ƒ  YZ. d. e f d/ „  ƒ  YZ/ d0 e f d1 „  ƒ  YZ0 d2 „  Z1 d3 „  Z2 d4 e f d5 „  ƒ  YZ3 d6 „  Z4 d7 e f d8 „  ƒ  YZ5 d9 „  Z6 d: e f d; „  ƒ  YZ7 d< e f d= „  ƒ  YZ8 d> e f d? „  ƒ  YZ9 d@ e f dA „  ƒ  YZ: dB e f dC „  ƒ  YZ; dD e f dE „  ƒ  YZ< dF e f dG „  ƒ  YZ= dH e f dI „  ƒ  YZ> d S(J   s1   
This scripts specifies all PTX special objects.
i    (   t   print_functiont   absolute_importt   divisionN(   t   typest   irt   typingt   macroi   (   t   nvvmt   Stubc           B` s,   e  Z d  Z d Z d Z d „  Z d „  Z RS(   sl   A stub object to represent special objects which is meaningless
    outside the context of CUDA-python.
    s   <ptx special value>c         C` s   t  d |  ƒ ‚ d  S(   Ns   %s is not instantiable(   t   NotImplementedError(   t   cls(    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   __new__   s    c         C` s   |  j  S(   N(   t   _description_(   t   self(    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   __repr__   s    (    (   t   __name__t
   __module__t   __doc__R   t	   __slots__R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR      s
   	t	   threadIdxc           B` sJ   e  Z d  Z d Z e j d e ƒ Z e j d e ƒ Z e j d e ƒ Z	 RS(   s  
    The thread indices in the current thread block, accessed through the
    attributes ``x``, ``y``, and ``z``. Each index is an integer spanning the
    range from 0 inclusive to the corresponding value of the attribute in
    :attr:`numba.cuda.blockDim` exclusive.
    s   <threadIdx.{x,y,z}>s   tid.xs   tid.ys   tid.z(
   R   R   R   R   R   t   Macrot   SREG_SIGNATUREt   xt   yt   z(    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR      s
   t   blockIdxc           B` sJ   e  Z d  Z d Z e j d e ƒ Z e j d e ƒ Z e j d e ƒ Z	 RS(   s  
    The block indices in the grid of thread blocks, accessed through the
    attributes ``x``, ``y``, and ``z``. Each index is an integer spanning the
    range from 0 inclusive to the corresponding value of the attribute in
    :attr:`numba.cuda.gridDim` exclusive.
    s   <blockIdx.{x,y,z}>s   ctaid.xs   ctaid.ys   ctaid.z(
   R   R   R   R   R   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR   -   s
   t   blockDimc           B` sD   e  Z d  Z e j d e ƒ Z e j d e ƒ Z e j d e ƒ Z RS(   sÝ   
    The shape of a block of threads, as declared when instantiating the
    kernel.  This value is the same for all threads in a given kernel, even
    if they belong to different blocks (i.e. each block is "full").
    s   ntid.xs   ntid.ys   ntid.z(	   R   R   R   R   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR   ;   s   t   gridDimc           B` sJ   e  Z d  Z d Z e j d e ƒ Z e j d e ƒ Z e j d e ƒ Z	 RS(   sh   
    The shape of the grid of blocks, accressed through the attributes ``x``,
    ``y``, and ``z``.
    s   <gridDim.{x,y,z}>s   nctaid.xs   nctaid.ys   nctaid.z(
   R   R   R   R   R   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR   F   s
   t   warpsizet   laneidc           C` s   d  S(   N(    (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   _ptx_grid1dW   t    c           C` s   d  S(   N(    (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   _ptx_grid2dZ   R   c         C` s¦   |  d k r d } t  j } n` |  d k rH d } t  j t  j d ƒ } n6 |  d k rr d } t  j t  j d ƒ } n t d ƒ ‚ t j | t j | t  j ƒ d |  g ƒS(	   s  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.
    i   s   ptx.grid.1di   s   ptx.grid.2di   s   ptx.grid.3ds   argument can only be 1, 2, 3t   args(	   R   t   int32t   UniTuplet
   ValueErrorR   t	   IntrinsicR   t	   signaturet   intp(   t   ndimt   fnamet   restype(    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   grid_expand]   s    s   ptx.gridt   callablec         C` s¦   |  d k r d } t  j } n` |  d k rH d } t  j t  j d ƒ } n6 |  d k rr d } t  j t  j d ƒ } n t d ƒ ‚ t j | t j | t  j ƒ d |  g ƒS(	   sx  
    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.

    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.
    i   s   ptx.gridsize.1di   s   ptx.gridsize.2di   s   ptx.gridsize.3ds   argument can only be 1, 2 or 3R!   (	   R   R"   R#   R$   R   R%   R   R&   R'   (   R(   R)   R*   (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   gridsize_expand   s    s   ptx.gridsizet   syncthreadsc           B` s   e  Z d  Z d Z RS(   s  
    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.
    s   <syncthreads()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR.   £   s   t   syncthreads_countc           B` s   e  Z d  Z d Z RS(   s¡   
    syncthreads_count(predictate)

    An extension to numba.cuda.syncthreads where the return value is a count
    of the threads where predicate is true.
    s   <syncthreads_count()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR/   ­   s   t   syncthreads_andc           B` s   e  Z d  Z d Z RS(   sž   
    syncthreads_and(predictate)

    An extension to numba.cuda.syncthreads where 1 is returned if predicate is
    true for all threads or 0 otherwise.
    s   <syncthreads_and()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR0   ·   s   t   syncthreads_orc           B` s   e  Z d  Z d Z RS(   sœ   
    syncthreads_or(predictate)

    An extension to numba.cuda.syncthreads where 1 is returned if predicate is
    true for any thread or 0 otherwise.
    s   <syncthreads_or()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR1   Á   s   t   syncwarpc           B` s   e  Z d  Z d Z RS(   sP   
    syncwarp(mask)

    Synchronizes a masked subset of threads in a warp.
    s   <warp_sync()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR2   Î   s   t   shfl_sync_intrinsicc           B` s   e  Z d  Z d Z RS(   sÊ   
    shfl_sync_intrinsic(mask, mode, value, mode_offset, clamp)

    Nvvm intrinsic for shuffling data across a warp
    docs.nvidia.com/cuda/nvvm-ir-spec/index.html#nvvm-intrin-warp-level-datamove
    s   <shfl_sync()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR3   ×   s   t   vote_sync_intrinsicc           B` s   e  Z d  Z d Z RS(   sÊ   
    vote_sync_intrinsic(mask, mode, predictate)

    Nvvm intrinsic for performing a reduce and broadcast across a warp
    docs.nvidia.com/cuda/nvvm-ir-spec/index.html#nvvm-intrin-warp-level-vote
    s   <vote_sync()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR4   á   s   t   match_any_syncc           B` s   e  Z d  Z d Z RS(   sÒ   
    match_any_sync(mask, value)

    Nvvm intrinsic for performing a compare and broadcast across a warp.
    Returns a mask of threads that have same value as the given value from within the masked warp.
    s   <match_any_sync()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR5   ë   s   t   match_all_syncc           B` s   e  Z d  Z d Z RS(   sŽ  
    match_all_sync(mask, value)

    Nvvm intrinsic for performing a compare and broadcast across a warp.
    Returns a tuple of (mask, pred), where mask is a mask of threads that have
    same value as the given value from within the masked warp, if they
    all have the same value, otherwise it is 0. Pred is a boolean of whether
    or not all threads in the mask warp have the same warp.
    s   <match_all_sync()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR6   õ   s   	t   threadfence_blockc           B` s   e  Z d  Z d Z RS(   s.   
    A memory fence at thread block level
    s   <threadfence_block()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR7     s   t   threadfence_systemc           B` s   e  Z d  Z d Z RS(   s8   
    A memory fence at system level: across devices
    s   <threadfence_system()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR8     s   t   threadfencec           B` s   e  Z d  Z d Z RS(   s(   
    A memory fence at device level
    s   <threadfence()>(   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR9     s   c         C` sH   t  |  t ƒ r |  St  |  t ƒ r) |  f St d j t |  ƒ ƒ ƒ ‚ d  S(   Ns   invalid type for shape; got {0}(   t
   isinstancet   tuplet   intt	   TypeErrort   formatt   type(   t   shape(    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   _legalize_shape  s
    c         C` sv   t  |  ƒ }  t |  ƒ } d } t j | | d ƒ } t j | t j t j | ƒ t j ƒ } t	 j
 | | d |  | f ƒS(   Ns   ptx.smem.alloct   CR!   (   RA   t   lenR   t   ArrayR   R&   R#   R'   t   AnyR   R%   (   R@   t   dtypeR(   R)   R*   t   sig(    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   shared_array&  s    't   sharedc           B` s8   e  Z d  Z d Z e j d e d e d d d g ƒZ RS(   s"   
    Shared memory namespace.
    s   <shared>s   shared.arrayR,   t   argnamesR@   RF   (	   R   R   R   R   R   R   RH   t   Truet   array(    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRI   /  s
   	c         C` sv   t  |  ƒ }  t |  ƒ } d } t j | | d ƒ } t j | t j t j | ƒ t j ƒ } t	 j
 | | d |  | f ƒS(   Ns   ptx.lmem.allocRB   R!   (   RA   RC   R   RD   R   R&   R#   R'   RE   R   R%   (   R@   RF   R(   R)   R*   RG   (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   local_arrayF  s    't   localc           B` s8   e  Z d  Z d Z e j d e d e d d d g ƒZ RS(   s!   
    Local memory namespace.
    s   <local>s   local.arrayR,   RJ   R@   RF   (	   R   R   R   R   R   R   RM   RK   RL   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRN   O  s
   c         C` sS   d } d d l  m } | j j |  ƒ } t j | | ƒ } t j | | d |  g ƒS(   Ns   ptx.cmem.arylikei   (   t   CUDATargetDescR!   (   t
   descriptorRO   t	   typingctxt   resolve_argument_typeR   R&   R   R%   (   t   ndarrayR)   RO   t   arytyRG   (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   const_array_likeb  s
    t   constc           B` s5   e  Z d  Z d Z e j d e d e d d g ƒZ RS(   s$   
    Constant memory namespace.
    s   <const>s   const.array_likeR,   RJ   t   ary(	   R   R   R   R   R   R   RU   RK   t
   array_like(    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRV   l  s
   t   popcc           B` s   e  Z d  Z RS(   sK   
    popc(val)

    Returns the number of set bits in the given value.
    (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRY   |  s   t   brevc           B` s   e  Z d  Z RS(   ss   
    brev(val)

    Reverse the bitpattern of an integer value; for example 0b10110110
    becomes 0b01101101.
    (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRZ   „  s   t   clzc           B` s   e  Z d  Z RS(   sF   
    clz(val)

    Counts the number of leading zeros in a value.
    (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR[     s   t   ffsc           B` s   e  Z d  Z RS(   s^   
    ffs(val)

    Find the position of the least significant bit set to 1 in an integer.
    (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR\   •  s   t   selpc           B` s   e  Z d  Z RS(   sp   
    selp(a, b, c)

    Select between source operands, based on the value of the predicate source operand.
    (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR]   Ÿ  s   t   fmac           B` s   e  Z d  Z RS(   sE   
    fma(a, b, c)

    Perform the fused multiply-add operation.
    (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR^   ©  s   t   atomicc           B` sl   e  Z d  Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ RS(
   s$   Namespace for atomic operations
    s   <atomic>t   addc           B` s   e  Z d  Z RS(   sà   add(ary, idx, val)

        Perform atomic ary[idx] += val. Supported on int32, float32, and
        float64 operands only.

        Returns the old value at the index location as if it is loaded
        atomically.
        (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR`   ¸  s   t   maxc           B` s   e  Z d  Z RS(   sÒ  max(ary, idx, val)

        Perform atomic ary[idx] = max(ary[idx], val). NaN is treated as a
        missing value, so max(NaN, n) == max(n, NaN) == n. Note that this
        differs from Python and Numpy behaviour, where max(a, b) is always
        a when either a or b is a NaN.

        Supported on int32, int64, uint32, uint64, float32, float64 operands only.

        Returns the old value at the index location as if it is loaded
        atomically.
        (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRa   Â  s   t   minc           B` s   e  Z d  Z RS(   sv  min(ary, idx, val)

        Perform atomic ary[idx] = min(ary[idx], val). NaN is treated as a
        missing value, so min(NaN, n) == min(n, NaN) == n. Note that this
        differs from Python and Numpy behaviour, where min(a, b) is always
        a when either a or b is a NaN.

        Supported on int32, int64, uint32, uint64, float32, float64 operands only.
        (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRb   Ð  s   	t   compare_and_swapc           B` s   e  Z d  Z RS(   sê   compare_and_swap(ary, old, val)

        Conditionally assign ``val`` to the first element of an 1D array ``ary``
        if the current value matches ``old``.

        Returns the current value as if it is loaded atomically.
        (   R   R   R   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyRc   Û  s   (	   R   R   R   R   R   R`   Ra   Rb   Rc   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyR_   ³  s   
(?   R   t
   __future__R    R   R   t   operatort   numpyt   llvmlite.llvmpy.coret   llvmpyt   coret   lct   numbaR   R   R   R   t   cudadrvR   t   objectR   R&   R"   R   R   R   R   R   R   R   R   R   R    R+   RK   t   gridR-   t   gridsizeR.   R/   R0   R1   R2   R3   R4   R5   R6   R7   R8   R9   RA   RH   RI   RM   RN   RU   RV   RY   RZ   R[   R\   R]   R^   R_   (    (    (    s/   lib/python2.7/site-packages/numba/cuda/stubs.pyt   <module>   s\   "				


	



							
	


