U
    b2O                  #   @   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rqe sqee qW 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@gZdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQgZdRdSdTdUdVdWdXdYgZdZd[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#d_d` e#D Z$dad` e#D Z%dbdcddgZ&dedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzgZ'd{d| Z(d}d~ Z)dd Z*dd Z+dZ,dd Z-ddddddddddddddddgZ.ddddddddgZ/ddddddddgZ0e0ddd Z1ddddddddddddgZ2ddddddddddddddddgZ3ddddddddddddgZ4ddddddddddddddddgZ5e5ddd Z6ddddddddgdgd  Z7ddddddddgdgd  Z8dd Z9dd Z:dS )    N)mingw32i	     c                   @   s   e Zd ZdS )MismatchCAPIWarningN)__name__
__module____qualname__ r   r   W/home/fireinfo/NEWAFireInfo/venv/lib/python3.8/site-packages/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	backtraceZmadvisexmmintrin.hemmintrin.himmintrin.hz
features.hz	xlocale.hzdlfcn.hz
sys/mman.h)Z__builtin_isnan5.)Z__builtin_isinfrT   )Z__builtin_isfiniterT   )Z__builtin_bswap325u)Z__builtin_bswap64rU   )Z__builtin_expectz5, 0)Z__builtin_mul_overflowz5, 5, (int*)5)Z_m_from_int640rR   )Z_mm_load_psz	(float*)0rQ   )Z_mm_prefetchz(float*)0, _MM_HINT_NTArQ   )Z_mm_load_pdz
(double*)0rR   )Z__builtin_prefetchz(float*)0, 0, 3)__asm__ volatilez"vpand %xmm1, %xmm2, %xmm3"stdio.hZLINK_AVX)rW   z"vpand %ymm1, %ymm2, %ymm3"rX   Z	LINK_AVX2)rW   z"vpaddd %zmm1, %zmm2, %zmm3"rX   ZLINK_AVX512F)rW   z"vfpclasspd $0x40, %zmm15, %k6\n"                                             "vmovdqu8 %xmm0, %xmm1\n"                                             "vpbroadcastmb2q %k0, %xmm0\n"rX   ZLINK_AVX512_SKX)rW   z"xgetbv"rX   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)rS   )z"__attribute__((target("avx512f")))Z(attribute_target_avx512f_with_intrinsicsz7__m512i temp = _mm512_castps_si512(_mm512_set1_ps(1.0))rS   )rY   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))rS   Z__threadz__declspec(thread)c                 C   s   g | ]}|d  qS )fr   r!   rZ   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    re   c                 C   s   |  dd}| S )Nr   r-   ra   rc   r   r   r	   type2def  s    rf   c              	   C   sN  |    tddi }tjdkrRt sRz| jjd W q tt	fk
rN   Y qX nNtjdkr| jj
drd| jjkr| jjdd}| jj|||||d	 d
 | |d d d\}}zz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 -ipor`   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   rj   Zcompile_optionsremoveAttributeError
ValueErrorcompiler_type
startswithZcc_exerb   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#   _  s     zpyod.<locals>.<listcomp>r   r   z%07dr   Nc                 S   s   g | ]}d t | qS )z%03d)int)r!   ro   r   r   r	   r#   b  s     r   )	openreadrangelenr   r   extendr}   r)   )filenameoutZfidZyo2iliner   r   r	   r|   K  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363Z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	rtd| ntd| dS )zSGiven a binary dump as given by GNU od -b, look for long double
    representation.r`       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_BErv   )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;
                }
            }
        }
        )rq   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   parentrZ   r   rx   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_   re   rf   r   rr   r|   r   r   r   r   r   r   r   r   r   r   r   r{   r   r   r   r   r	   <module>   s  
           
          
                                                          /                             ;