U
    hâËd×  ã                   @   sž   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ	 d dl
Z
dZdZed	ƒe
 ejd
kd¡e
 e ¡  d¡G dd„ de
jƒƒƒƒZedkrše
 ¡  dS )é    )Únvvm)Úskip_on_cudasim)Úutils)Úir)ÚbindingNzNcall void @llvm.memset.p0i8.i64(i8* align 4 %arg.x.41, i8 0, i64 %0, i1 false)zFcall void @llvm.memset.p0i8.i64(i8* %arg.x.41, i8 0, i64 %0, i1 false)z"libNVVM not supported in simulatoré    zCUDA not support for 32-bitz
No libNVVMc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestNvvmWithoutCudac                 C   sD   t  t¡}|  d|¡ | ¡ D ] }d|kr|  |d dd¡¡ qdS )z²
        Test llvm.memset changes in llvm7.
        In LLVM7 the alignment parameter can be implicitly provided as
        an attribute to pointer in the first argument.
        zcall void @llvm.memsetzi32 4, i1 false\)ú z\s+N)r   Úllvm100_to_34_irÚoriginalÚassertInÚ
splitlinesZassertRegexpMatchesÚreplace)ÚselfZfixedÚln© r   úZ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/cuda/tests/nocuda/test_nvvm.pyÚtest_nvvm_memset_fixup_for_34   s    

þz1TestNvvmWithoutCuda.test_nvvm_memset_fixup_for_34c              	   C   s6   |   t¡�}t t¡ W 5 Q R X |  t|jƒd¡ dS )zy
        We require alignment to be specified as a parameter attribute to the
        dest argument of a memset.
        z+No alignment attribute found on memset destN)ÚassertRaisesÚ
ValueErrorr   r
   Úmissing_alignr   ÚstrÚ	exception)r   Úer   r   r   Ú+test_nvvm_memset_fixup_for_34_missing_align'   s
    ÿz?TestNvvmWithoutCuda.test_nvvm_memset_fixup_for_34_missing_alignc                 C   s¸   t  t  t  d¡d¡ttdƒƒ¡}t  ¡ }d|_t 	|¡ t  
||jd¡}d|_||_t ¡ j|_t t|ƒ¡}t t|ƒ¡}d dd„ tdƒD ƒ¡}d	|› d
� d¡}|  ||¡ d S )Né   é   znvptx64-nvidia-cudaÚ
myconstantTz, c                 S   s   g | ]}t |ƒ‘qS r   )r   )Ú.0Úir   r   r   Ú
<listcomp>L   s     zBTestNvvmWithoutCuda.test_nvvm_accepts_encoding.<locals>.<listcomp>zmyconstant[256] = {Ú}zutf-8)r   ÚConstantÚ	ArrayTypeZIntTypeÚ	bytearrayÚrangeÚModuleZtripler   Zadd_ir_versionZGlobalVariableÚtypeZglobal_constantZinitializerZNVVMZdata_layoutÚllvmZparse_assemblyr   Zllvm_to_ptxÚjoinÚencoder   )r   ÚcÚmÚgvÚparsedZptxÚelementsr   r   r   r   Útest_nvvm_accepts_encoding2   s    
ÿ
z.TestNvvmWithoutCuda.test_nvvm_accepts_encodingN)Ú__name__Ú
__module__Ú__qualname__r   r   r0   r   r   r   r   r      s   r   Ú__main__)Znumba.cuda.cudadrvr   Znumba.cuda.testingr   Z
numba.corer   Zllvmliter   r   r(   Zunittestr   r   ZskipIfZMACHINE_BITSZis_availableZTestCaser   r1   Úmainr   r   r   r   Ú<module>   s   <