ó
\K]c           @@ sÈ   d  d l  m Z m Z d  d l Z d  d l m Z m Z d  d l m	 Z	 m
 Z
 m Z d  d l m Z d  d l m Z m Z d „  Z e d ƒ d	 e e j f d
 „  ƒ  Yƒ Z e d k rÄ e j ƒ  n  d S(   i    (   t   print_functiont   absolute_importN(   t   skip_on_cudasimt   SerialMixin(   t   override_configt   captured_stderrt   captured_stdout(   t   unittest_support(   t   cudat   float64c         C@ s%   t  j d ƒ } |  | d | | <d  S(   Ni   g      ø?(   R   t   grid(   t   At   Bt   i(    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   simple_cuda   s    s&   Simulator does not produce debug dumpst   TestDebugOutputc           B@ s}   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z RS(   c         C@ s¼   t  ƒ  ” } t ƒ  ‚ } t j t t f ƒ t ƒ } t j d d d ƒ j t j ƒ } t j	 | ƒ } | d | | ƒ |  j
 t j | d | ƒ ƒ Wd  QXWd  QX|  j | j ƒ  ƒ | j ƒ  S(   Ni    i   i
   g      ø?(   i   i
   (   R   R   R   t   jitR	   R   t   npt   linspacet   astypet
   zeros_liket
   assertTruet   allcloset   assertFalset   getvalue(   t   selft   errt   outt   cfuncR   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   compile_simple_cuda   s    !)c         O@ s   |  j  t | | Ž d  S(   N(   t   assertRaisest   AssertionError(   R   t   argst   kwargs(    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   assert_fails!   s    c         C@ s®   t  j d d d d d g t ƒ } x* | D]" } | | k s@ t ‚ t | | <q( WxY t | j ƒ  ƒ D]E \ } } t |  d | ƒ } | r“ | | ƒ qa |  j t | | ƒ qa Wd  S(   Nt   bytecodet   cfgt   irt   llvmt   assemblys   _check_dump_%s(	   t   dictt   fromkeyst   FalseR   t   Truet   sortedt   itemst   getattrR   (   R   R   t   enabled_dumpst	   all_dumpst   namet   enabledt
   check_meth(    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   check_debug_output$   s    	c         C@ s   |  j  d | ƒ d  S(   Nt
   BINARY_ADD(   t   assertIn(   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   _check_dump_bytecode2   s    c         C@ s   |  j  d | ƒ d  S(   Ns   CFG dominators(   R6   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   _check_dump_cfg5   s    c         C@ s$   |  j  d | ƒ |  j  d | ƒ d  S(   Ns   --IR DUMP: simple_cuda--s   const(float, 1.5)(   R6   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   _check_dump_ir8   s    c         C@ s   |  j  d | ƒ d  S(   Ns   --LLVM DUMP(   R6   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   _check_dump_llvm<   s    c         C@ s$   |  j  d | ƒ |  j  d | ƒ d  S(   Ns   --ASSEMBLY simple_cudas!   Generated by NVIDIA NVVM Compiler(   R6   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   _check_dump_assembly?   s    c         C@ s9   t  d t ƒ  |  j ƒ  } Wd  QX|  j | d g ƒ d  S(   Nt   DUMP_BYTECODER#   (   R   R+   R   R4   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   test_dump_bytecodeC   s    c         C@ s9   t  d t ƒ  |  j ƒ  } Wd  QX|  j | d g ƒ d  S(   Nt   DUMP_IRR%   (   R   R+   R   R4   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   test_dump_irH   s    c         C@ s9   t  d t ƒ  |  j ƒ  } Wd  QX|  j | d g ƒ d  S(   Nt   DUMP_CFGR$   (   R   R+   R   R4   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   test_dump_cfgM   s    c         C@ s9   t  d t ƒ  |  j ƒ  } Wd  QX|  j | d g ƒ d  S(   Nt	   DUMP_LLVMR&   (   R   R+   R   R4   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   test_dump_llvmR   s    c         C@ s9   t  d t ƒ  |  j ƒ  } Wd  QX|  j | d g ƒ d  S(   Nt   DUMP_ASSEMBLYR'   (   R   R+   R   R4   (   R   R   (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   test_dump_assemblyW   s    (   t   __name__t
   __module__R   R"   R4   R7   R8   R9   R:   R;   R=   R?   RA   RC   RE   (    (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyR      s   												t   __main__(   t
   __future__R    R   t   numpyR   t   numba.cuda.testingR   R   t   numba.tests.supportR   R   R   t   numbaR   t   unittestR   R	   R   t   TestCaseR   RF   t   main(    (    (    sA   lib/python2.7/site-packages/numba/cuda/tests/cudapy/test_debug.pyt   <module>   s   	L