U
    ûØf©O  ã                #   @   s   d dl Z d dlZd dlZd dlZd dlZd dlmZ dZdZG dd„ de	ƒZ
dd„ Zd	d
„ Zi Zdd„ ZdD ]LZee e¡je ƒ.ZeD ]"Ze d¡ršqŠe ¡ s¤qŠeeƒ qŠW 5 Q R X qldddddddddddddddddd d!d"gZd#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3gZd4gZd5d6d7gZd8d9gZd:d;d<d=d>d?d@dAdBg	ZdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSgZdTdUdVdWdXdYdZd[gZd\d]d^gZ d_d`gZ!d#d$d%d'd&d,d/d5d6g	Z"dddddddddd(d)dddd$dd#dddd&d%d'd,d-d.dd d!d"d*d+d/d0d3g#Z#dadb„ e#D ƒZ$dcdb„ e#D ƒZ%dddedfgZ&dgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|gZ'd}d~„ Z(dd€„ Z)dd‚„ Z*dƒd„„ Z+d…Z,d†d‡„ Z-dˆdˆdˆdˆdˆdˆdˆdˆd‰dŠd‹dŒddŽddgZ.d‘d’d“d”d•d–d—d˜gZ/d™dšd›dœd–dˆdˆdˆgZ0e0ddd… Z1dˆdˆdˆdˆdždŸd d¡d¢d£dˆdˆgZ2dˆdˆdˆdˆdždŸd d¡d¢d£dˆdˆdˆdˆdˆdˆgZ3d£d¢dˆdˆd¡d dŸdždˆdˆdˆdˆgZ4d£d¢d¤d¥d‹d¦dˆdˆdˆdˆdˆdˆdˆdˆdˆdˆgZ5e5ddd… Z6d™dšd›dœd–dˆdˆdˆgdˆgd§  Z7dˆdˆdˆd–dœd›dšd™gdˆgd§  Z8d¨d©„ Z9dªd«„ Z:dS )¬é    N)Úmingw32i	  é   c                   @   s   e Zd ZdS )ÚMismatchCAPIWarningN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú>/tmp/pip-target-lpfmz8o1/lib/python/numpy/core/setup_common.pyr   3   s   r   c                 C   sN   t j d|¡ z(tdƒ}tdƒ}| |j¡}| ¡ }W 5 t jd= X |||  fS )z°
    Return current C API checksum and the recorded checksum.

    Return current C API checksum and the recorded checksum for the given
    version of the C API version.

    r   ZgenapiÚ	numpy_api)ÚsysÚpathÚinsertÚ
__import__Zfullapi_hashZfull_apiZget_versions_hash)Ú
apiversionÚcodegen_dirÚmr
   Úcurapi_hashZ	apis_hashr   r   r	   Úget_api_versions7   s    

r   c                 C   s<   t | |ƒ\}}||ks8d}tj|| || |tf tdd dS )z@Emits a MismatchCAPIWarning if the C API version needs updating.a  API mismatch detected, the C API version numbers have to be updated. Current C api version is %d, with checksum %s, but recorded checksum for C API version %d in core/codegen_dir/cversions.txt is %s. If functions were added in the C API, you have to update C_API_VERSION in %s.é   )Ú
stacklevelN)r   ÚwarningsÚwarnÚ__file__r   )r   r   r   Zapi_hashÚmsgr   r   r	   Úcheck_api_versionL   s    ÿ þr   c                 C   s\   |   d¡\}}}| d¡d }| d¡d }dd„ | d¡D ƒ}d	 d
d„ |D ƒ¡t|< d S )Nú(ú)r   ú éÿÿÿÿc                 S   s   g | ]}|  ¡ ‘qS r   )Ústrip©Ú.0Úargr   r   r	   Ú
<listcomp>g   s     zset_sig.<locals>.<listcomp>ú,z, c                 s   s   | ]}d | V  qdS )z(%s) 0Nr   r    r   r   r	   Ú	<genexpr>h   s     zset_sig.<locals>.<genexpr>)Ú	partitionÚ
rpartitionÚsplitÚjoinÚFUNC_CALL_ARGS)ÚsigÚprefixÚ_ÚargsÚfuncnamer   r   r	   Úset_sigc   s
    r0   )zfeature_detection_locale.hzfeature_detection_math.hzfeature_detection_misc.hzfeature_detection_stdio.hú#ÚsinÚcosÚtanÚsinhÚcoshÚtanhÚfabsÚfloorÚceilÚsqrtÚlog10ÚlogÚexpÚasinÚacosÚatanÚfmodÚmodfÚfrexpÚldexpÚexpm1Úlog1pÚacoshÚasinhÚatanhZrintÚtruncZexp2Úlog2ÚhypotÚatan2ÚpowÚcopysignZ	nextafterZstrtollZstrtoullZcbrtZ	strtold_lZftelloZfseekoZ	fallocateZ	backtraceÚmadviseúxmmintrin.húemmintrin.húimmintrin.hz
features.hz	xlocale.hzdlfcn.hz
execinfo.hzlibunwind.hz
sys/mman.h)Z__builtin_isnanú5.)Z__builtin_isinfrU   )Z__builtin_isfiniterU   )Z__builtin_bswap32Ú5u)Z__builtin_bswap64rV   )Z__builtin_expectz5, 0)Z__builtin_mul_overflowz5, 5, (int*)5)Z_m_from_int64Ú0rS   )Z_mm_load_psz	(float*)0rR   )Z_mm_prefetchz(float*)0, _MM_HINT_NTArR   )Z_mm_load_pdz
(double*)0rS   )Z__builtin_prefetchz(float*)0, 0, 3)ú__asm__ volatilez"vpand %xmm1, %xmm2, %xmm3"ústdio.hZLINK_AVX)rX   z"vpand %ymm1, %ymm2, %ymm3"rY   Z	LINK_AVX2)rX   z"vpaddd %zmm1, %zmm2, %zmm3"rY   ZLINK_AVX512F)rX   z²"vfpclasspd $0x40, %zmm15, %k6\n"                                             "vmovdqu8 %xmm0, %xmm1\n"                                             "vpbroadcastmb2q %k0, %xmm0\n"rY   ZLINK_AVX512_SKX)rX   z"xgetbv"rY   ZXGETBV)z)__attribute__((optimize("unroll-loops")))Zattribute_optimize_unroll_loops)z__attribute__((optimize("O3")))Zattribute_optimize_opt_3)z__attribute__((optimize("O2")))Zattribute_optimize_opt_2)z__attribute__((nonnull (1)))Zattribute_nonnull)z__attribute__((target ("avx")))Zattribute_target_avx)z __attribute__((target ("avx2")))Zattribute_target_avx2)z#__attribute__((target ("avx512f")))Zattribute_target_avx512f)úG__attribute__((target ("avx512f,avx512dq,avx512bw,avx512vl,avx512cd")))Zattribute_target_avx512_skx)z#__attribute__((target("avx2,fma")))Z%attribute_target_avx2_with_intrinsicszk__m256 temp = _mm256_set1_ps(1.0); temp =                                 _mm256_fmadd_ps(temp, temp, temp)rT   )z"__attribute__((target("avx512f")))Z(attribute_target_avx512f_with_intrinsicsz7__m512i temp = _mm512_castps_si512(_mm512_set1_ps(1.0))rT   )rZ   Z+attribute_target_avx512_skx_with_intrinsicsa"  __mmask8 temp = _mm512_fpclass_pd_mask(_mm512_set1_pd(1.0), 0x01);                                __m512i unused_temp =                                     _mm512_castps_si512(_mm512_set1_ps(1.0));                                _mm_mask_storeu_epi8(NULL, 0xFF, _mm_broadcastmb_epi64(temp))rT   Z__threadz__declspec(thread)c                 C   s   g | ]}|d  ‘qS )Úfr   ©r!   r[   r   r   r	   r#   õ   s     r#   c                 C   s   g | ]}|d  ‘qS )Úlr   r\   r   r   r	   r#   ö   s     zcomplex doublezcomplex floatzcomplex long doubleZcabsZcacosZcacoshZcargZcasinZcasinhZcatanZcatanhZccosZccoshZcexpZcimagZclogZconjZcpowZcprojZcrealZcsinZcsinhZcsqrtZctanZctanhc                 C   s   d|   ¡  S )NzHAVE_%s)Úupper)Únamer   r   r	   Ú	fname2def   s    r`   c                 C   s   |   dd¡}| ¡ S )Nr   Ú ©Úreplacer^   ©ÚsymbolZdefiner   r   r	   Úsym2def  s    rf   c                 C   s   |   dd¡}| ¡ S )Nr   r-   rb   rd   r   r   r	   Útype2def  s    rg   c              	   C   sN  |   ¡  tddi }tjdkrRtƒ sRz| jj d¡ W q  tt	fk
rN   Y q X nNtjdkr | jj
 d¡r d| jjkr | jj dd¡}| jj|||||d	 d
 |  |d d d¡\}}zŠztt|ƒƒ}|W W ¢tS  t	k
r:   | dd¡}|d7 }|  |d d d¡\}}| j d¡ | j |gd¡ ttdƒƒ}| Y W ¢S X W 5 |  ¡  X d S )NÚtypezlong doubleÚwin32z/GLÚintelz-ipoz -ipora   z -shared)ÚcompilerÚcompiler_soÚcompiler_cxxÚ
linker_exeÚ	linker_soÚcÚstructzvolatile structz)int main(void) { return foo.before[0]; }
Z_configtest)Ú_check_compilerÚLONG_DOUBLE_REPRESENTATION_SRCr   Úplatformr   rk   Zcompile_optionsÚremoveÚAttributeErrorÚ
ValueErrorÚcompiler_typeÚ
startswithZcc_exerc   Úset_executablesÚ_compileZ_cleanÚlong_double_representationÚpyodZ
temp_filesÚappendZlink_executable)ÚcmdÚbodyZnewcompilerÚsrcÚobjZltyper   r   r	   Ú check_long_double_representation  sB    
ÿ
þû	
rƒ   aA  
/* "before" is 16 bytes to ensure there's no padding between it and "x".
 *    We're not expecting any "long double" bigger than 16 bytes or with
 *       alignment requirements stricter than 16 bytes.  */
typedef %(type)s test_type;

struct {
        char         before[16];
        test_type    x;
        char         after[8];
} foo = {
        { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
          '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' },
        -123456789.0,
        { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' }
};
c              	   C   s   g }t | dƒ}dd„ | ¡ D ƒ}W 5 Q R X tdt|ƒdƒD ]N}dtt|ƒdd… ƒ g}| d	d„ |||d … D ƒ¡ | d
 |¡¡ q<|S )a£  Python implementation of the od UNIX utility (od -b, more exactly).

    Parameters
    ----------
    filename : str
        name of the file to get the dump from.

    Returns
    -------
    out : seq
        list of lines of od output

    Notes
    -----
    We only implement enough to get the necessary information for long double
    representation, this is not intended as a compatible replacement for od.
    Úrbc                 S   s   g | ]}t |ƒd d… ‘qS )r   N)Úoct)r!   Úor   r   r	   r#   a  s     zpyod.<locals>.<listcomp>r   r   z%07dr   Nc                 S   s   g | ]}d t |ƒ ‘qS )z%03d)Úint)r!   rp   r   r   r	   r#   d  s     r   )	ÚopenÚreadÚrangeÚlenr‡   r…   Úextendr~   r)   )ÚfilenameÚoutÚfidZyo2ÚiÚliner   r   r	   r}   M  s     r}   Z000Z001Z043Z105Z147Z211Z253Z315Z357Z376Z334Z272Z230Z166Z124Z062Z020Z301Z235Z157Z064r   Z240Z242Z171Z353Z031Z300Z326Z363Ú100é   c                 C   s®  dgd }d}| D ]p}|  ¡ dd… D ]X}| d¡ | |¡ |dd… tkr(t |¡}|dd… tdd… kr¦|dd… tkrŒ  d	S |dd… tkr¤  d
S q(|dd… tdd… kr@|dd… tkrØ  dS |dd… t	krð  dS |dd… t
kr
  dS |dd… tkr$  dS |dd… tkr‚  dS q(|dd… tkr(|dd… tkrj  dS |dd… tkr(  dS q(q|dk	ržtd| ƒ‚ntd| ƒ‚dS )zSGiven a binary dump as given by GNU od -b, look for long double
    representation.ra   é    Né   r   iøÿÿÿé   é   ZINTEL_EXTENDED_12_BYTES_LEZMOTOROLA_EXTENDED_12_BYTES_BEr“   ZINTEL_EXTENDED_16_BYTES_LEZIEEE_QUAD_BEZIEEE_QUAD_LEZIBM_DOUBLE_DOUBLE_LEZIBM_DOUBLE_DOUBLE_BEr   ZIEEE_DOUBLE_LEZIEEE_DOUBLE_BEzUnrecognized format (%s)zCould not lock sequences (%s))r(   Úpopr~   Ú
_AFTER_SEQÚcopyÚ_BEFORE_SEQÚ_INTEL_EXTENDED_12BÚ_MOTOROLA_EXTENDED_12BÚ_INTEL_EXTENDED_16BÚ_IEEE_QUAD_PREC_BEÚ_IEEE_QUAD_PREC_LEÚ_IBM_DOUBLE_DOUBLE_LEÚ_IBM_DOUBLE_DOUBLE_BEÚ_IEEE_DOUBLE_LEÚ_IEEE_DOUBLE_BErw   )Úlinesr‰   Zsawr‘   Úwr   r   r	   r|   }  s@    







r|   c                 C   s>   |   ¡  |  t d¡dd¡}|s$dS |  t d¡dd¡}| S )a‰  
    On our arm CI, this fails with an internal compilation error

    The failure looks like the following, and can be reproduced on ARM64 GCC 5.4:

        <source>: In function 'right_shift':
        <source>:4:20: internal compiler error: in expand_shift_1, at expmed.c:2349
               ip1[i] = ip1[i] >> in2;
                      ^
        Please submit a full bug report,
        with preprocessed source if appropriate.
        See <http://gcc.gnu.org/bugs.html> for instructions.
        Compiler returned: 1

    This function returns True if this compiler bug is present, and we need to
    turn off optimization for the function
    zF        __attribute__((optimize("O3"))) void right_shift() {}
        NFao          typedef long the_type;  /* fails also for unsigned and long long */
        __attribute__((optimize("O3"))) void right_shift(the_type in2, the_type *ip1, int n) {
            for (int i = 0; i < n; i++) {
                if (in2 < (the_type)sizeof(the_type) * 8) {
                    ip1[i] = ip1[i] >> in2;
                }
            }
        }
        )rr   Ztry_compileÚtextwrapÚdedent)r   Zhas_optimizeZno_errr   r   r	   Ú-check_for_right_shift_internal_compiler_error¸  s     þ	 ÷
r©   );rš   Úpathlibr   r§   r   Znumpy.distutils.misc_utilr   ZC_ABI_VERSIONZC_API_VERSIONÚWarningr   r   r   r*   r0   Úfilerˆ   ÚPathr   Úparentr[   r‘   ry   r   ZMANDATORY_FUNCSZOPTIONAL_STDFUNCSZOPTIONAL_LOCALE_FUNCSZOPTIONAL_FILE_FUNCSZOPTIONAL_MISC_FUNCSZOPTIONAL_HEADERSZOPTIONAL_INTRINSICSZOPTIONAL_FUNCTION_ATTRIBUTESZ,OPTIONAL_FUNCTION_ATTRIBUTES_WITH_INTRINSICSZOPTIONAL_VARIABLE_ATTRIBUTESZOPTIONAL_STDFUNCS_MAYBEZ	C99_FUNCSZC99_FUNCS_SINGLEZC99_FUNCS_EXTENDEDZC99_COMPLEX_TYPESZC99_COMPLEX_FUNCSr`   rf   rg   rƒ   rs   r}   r›   r™   r¤   r£   rœ   rž   r   rŸ   r    r¢   r¡   r|   r©   r   r   r   r	   Ú<module>   sÎ  
           þ
          þ
öçò÷       þ                              û  ÿ                   ý/       ÿ   ÿ       ÿ     ÿ       ÿÿÿ;