a
    —§»aq
  ã                   @   sš   d dl Z d dlZ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Zertd dlmZ e d	d
¡ ee  ¡ dkdƒG dd„ deƒƒZdS )é    N)Útypes)ÚTestCaseÚskipIf)Úoverride_env_config)Úcompile_isolatedÚFlags)ÚFastMathOptionsF)ÚbindingÚ z--debug-only=loop-vectorizeÚx86_64zx86_64 only testc                   @   s2   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestVectorizationzP
    Tests to assert that code which should vectorize does indeed vectorize
    Fc              	   C   s”   t ddƒ�v t ddƒ�L tƒ }t|ƒ|_d|_t|||d�}|j ¡ W  d   ƒ W  d   ƒ S 1 sh0    Y  W d   ƒ n1 s†0    Y  d S )NZNUMBA_CPU_NAMEzskylake-avx512ZNUMBA_CPU_FEATURESr
   T)Úflags)r   r   r   ÚfastmathZnrtr   ZlibraryZget_llvm_str)ÚselfÚfuncZ
args_tupler   Ú_flagsZjitted© r   úX/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/numba/tests/test_vectorization.pyÚgen_ir   s    ÿþ
zTestVectorization.gen_irc                 C   sB   dd„ }| j |tjd d d… fdd�}|  d|¡ |  d|¡ d S )Nc                 S   s$   d}t  | ¡D ]}|| ¡ 7 }q|S )Nr   )ÚnpZnditerÚitem)ÚxÚaccÚvr   r   r   Údo_sum!   s    z2TestVectorization.test_nditer_loop.<locals>.do_sumé   T©r   úvector.bodyúllvm.loop.isvectorized)r   r   Úfloat64ÚassertIn)r   r   Úllvm_irr   r   r   Útest_nditer_loop   s    z"TestVectorization.test_nditer_loopc                 C   sD   dd„ }t j}| j||fd |d d d… f dd�}|  d|¡ d S )Nc                 S   sD   | | |  |d< |||  |d< | | |  |d< |||  |d< d S )Nr   r   é   é   r   )Za1Za2Úb1Úb2ÚAr   r   r   Úfoo/   s    z'TestVectorization.test_slp.<locals>.fooé   r   Tr   z
2 x double)r   r   r   r    )r   r(   Útyr!   r   r   r   Útest_slp+   s    &zTestVectorization.test_slpc                 C   s>   dd„ }| j |t tj¡fdd�}|  d|¡ |  d|¡ d S )Nc                 S   s    d}| D ]}|t  |¡7 }q|S )Ng        )r   Úsqrt)Úlstr   r   r   r   r   Úsum_sqrt_list@   s    z@TestVectorization.test_instcombine_effect.<locals>.sum_sqrt_listTr   r   r   )r   r   ZListTyper   r    )r   r.   r!   r   r   r   Útest_instcombine_effect9   s    ÿz)TestVectorization.test_instcombine_effectN)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r"   r+   r/   r   r   r   r   r      s
   

r   )ÚplatformÚnumpyr   Znumbar   Zunittestr   r   Znumba.tests.supportr   Znumba.core.compilerr   r   Znumba.core.cpu_optionsr   Z_DEBUGZllvmliter	   ZllvmZ
set_optionÚmachiner   r   r   r   r   Ú<module>   s   