1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
U
O±d%‘ã    @sÆdZddlZddlZddlZddlZddlZddlZddlZddddgZGdd„dƒZ    Gd    d
„d
ƒZ
iZ Gd d „d ƒZ Gd d„dƒZ Gdd„dƒZGdd„dƒZGdd„de    e
e e eeƒZdd„ZdS)aProvides the `CCompilerOpt` class, used for handling the CPU/hardware
optimization, starting from parsing the command arguments, to managing the
relation between the CPU baseline and dispatch-able features,
also generating the required C headers and ending with compiling
the sources with proper compiler's flags.
 
`CCompilerOpt` doesn't provide runtime detection for the CPU features,
instead only focuses on the compiler side, but it creates abstract C headers
that can be used later for the final runtime dispatching process.éNz
-std=c++11z-D__STDC_VERSION__=0z-fno-exceptionsz    -fno-rttic'@sfeZdZdZdZdZdZdZej     
ej      ej      e ¡¡d¡ZiZdZdZeeddd    d
eddd d
ed dd    d
ed ddd
edddd
dZeddddddddZeeddddedddd ed!dd"d ed#d$d%d ed&d'd(d ed)d*d+d ed,d-d.ed/d0d1dd2ed3d4d5d ed6d4d5d ed7d4d.ed8d9d.ed:d9d.ed;d<dd=d>ed?d@d.edAdBdCdDddEedFdDdGdHddEedIdBdJdKddLdMedNdKdOdPdQedRdKdSdTddEedUdVdWdXddEeddYdZd[edd\dd]ed!d^dd]ed#d_dd`d>eddadbeddcdd]ed!dddd]eddedbeddfd.ed!dgd.ed#dhdd]ed&did.ed)did.ed,djd.dk#Zdldm„Zdndo„ZdS)pÚ_ConfigaÉAn abstract class holds all configurable attributes of `CCompilerOpt`,
    these class attributes can be used to change the default behavior
    of `CCompilerOpt` in order to fit other requirements.
 
    Attributes
    ----------
    conf_nocache : bool
        Set True to disable memory and file cache.
        Default is False.
 
    conf_noopt : bool
        Set True to forces the optimization to be disabled,
        in this case `CCompilerOpt` tends to generate all
        expected headers in order to 'not' break the build.
        Default is False.
 
    conf_cache_factors : list
        Add extra factors to the primary caching factors. The caching factors
        are utilized to determine if there are changes had happened that
        requires to discard the cache and re-updating it. The primary factors
        are the arguments of `CCompilerOpt` and `CCompiler`'s properties(type, flags, etc).
        Default is list of two items, containing the time of last modification
        of `ccompiler_opt` and value of attribute "conf_noopt"
 
    conf_tmp_path : str,
        The path of temporary directory. Default is auto-created
        temporary directory via ``tempfile.mkdtemp()``.
 
    conf_check_path : str
        The path of testing files. Each added CPU feature must have a
        **C** source file contains at least one intrinsic or instruction that
        related to this feature, so it can be tested against the compiler.
        Default is ``./distutils/checks``.
 
    conf_target_groups : dict
        Extra tokens that can be reached from dispatch-able sources through
        the special mark ``@targets``. Default is an empty dictionary.
 
        **Notes**:
            - case-insensitive for tokens and group names
            - sign '#' must stick in the begin of group name and only within ``@targets``
 
        **Example**:
            .. code-block:: console
 
                $ "@targets #avx_group other_tokens" > group_inside.c
 
            >>> CCompilerOpt.conf_target_groups["avx_group"] = \
            "$werror $maxopt avx2 avx512f avx512_skx"
            >>> cco = CCompilerOpt(cc_instance)
            >>> cco.try_dispatch(["group_inside.c"])
 
    conf_c_prefix : str
        The prefix of public C definitions. Default is ``"NPY_"``.
 
    conf_c_prefix_ : str
        The prefix of internal C definitions. Default is ``"NPY__"``.
 
    conf_cc_flags : dict
        Nested dictionaries defining several compiler flags
        that linked to some major functions, the main key
        represent the compiler name and sub-keys represent
        flags names. Default is already covers all supported
        **C** compilers.
 
        Sub-keys explained as follows:
 
        "native": str or None
            used by argument option `native`, to detect the current
            machine support via the compiler.
        "werror": str or None
            utilized to treat warning as errors during testing CPU features
            against the compiler and also for target's policy `$werror`
            via dispatch-able sources.
        "maxopt": str or None
            utilized for target's policy '$maxopt' and the value should
            contains the maximum acceptable optimization by the compiler.
            e.g. in gcc `'-O3'`
 
        **Notes**:
            * case-sensitive for compiler names and flags
            * use space to separate multiple flags
            * any flag will tested against the compiler and it will skipped
              if it's not applicable.
 
    conf_min_features : dict
        A dictionary defines the used CPU features for
        argument option `'min'`, the key represent the CPU architecture
        name e.g. `'x86'`. Default values provide the best effort
        on wide range of users platforms.
 
        **Note**: case-sensitive for architecture names.
 
    conf_features : dict
        Nested dictionaries used for identifying the CPU features.
        the primary key is represented as a feature name or group name
        that gathers several features. Default values covers all
        supported features but without the major options like "flags",
        these undefined options handle it by method `conf_features_partial()`.
        Default value is covers almost all CPU features for *X86*, *IBM/Power64*
        and *ARM 7/8*.
 
        Sub-keys explained as follows:
 
        "implies" : str or list, optional,
            List of CPU feature names to be implied by it,
            the feature name must be defined within `conf_features`.
            Default is None.
 
        "flags": str or list, optional
            List of compiler flags. Default is None.
 
        "detect": str or list, optional
            List of CPU feature names that required to be detected
            in runtime. By default, its the feature name or features
            in "group" if its specified.
 
        "implies_detect": bool, optional
            If True, all "detect" of implied features will be combined.
            Default is True. see `feature_detect()`.
 
        "group": str or list, optional
            Same as "implies" but doesn't require the feature name to be
            defined within `conf_features`.
 
        "interest": int, required
            a key for sorting CPU features
 
        "headers": str or list, optional
            intrinsics C header file
 
        "disable": str, optional
            force disable feature, the string value should contains the
            reason of disabling.
 
        "autovec": bool or None, optional
            True or False to declare that CPU feature can be auto-vectorized
            by the compiler.
            By default(None), treated as True if the feature contains at
            least one applicable flag. see `feature_can_autovec()`
 
        "extra_checks": str or list, optional
            Extra test case names for the CPU feature that need to be tested
            against the compiler.
 
            Each test case must have a C file named ``extra_xxxx.c``, where
            ``xxxx`` is the case name in lower case, under 'conf_check_path'.
            It should contain at least one intrinsic or function related to the test case.
 
            If the compiler able to successfully compile the C file then `CCompilerOpt`
            will add a C ``#define`` for it into the main dispatch header, e.g.
            ``#define {conf_c_prefix}_XXXX`` where ``XXXX`` is the case name in upper case.
 
        **NOTES**:
            * space can be used as separator with options that supports "str or list"
            * case-sensitive for all values and feature name must be in upper-case.
            * if flags aren't applicable, its will skipped rather than disable the
              CPU feature
            * the CPU feature will disabled if the compiler fail to compile
              the test file
    FNZchecksZNPY_ZNPY__z -march=nativez-O3z-Werror)ÚnativeÚoptÚwerrorz-Werror=switch -Werrorz-xHostz/QxHostz/O3z/Werrorz/O2z/WX)ÚgccÚclangÚiccÚiccwÚmsvczSSE SSE2z SSE SSE2 SSE3ÚzVSX VSX2zNEON NEON_FP16 NEON_VFPV4 ASIMD)Úx86Úx64Úppc64Úppc64leÚs390xÚarmhfÚaarch64éz xmmintrin.hÚSSE2)ÚinterestÚheadersÚimplieséÚSSEz emmintrin.h)rrréz pmmintrin.héÚSSE3z tmmintrin.héÚSSSE3z smmintrin.héÚSSE41zpopcntintrin.héÚPOPCNT)rréÚSSE42z immintrin.h)rrrÚimplies_detecté    ÚAVXz x86intrin.hé
é é ÚF16Cé éz    FMA3 AVX2ZAVX512F_REDUCE)rrr%Ú extra_checkséÚAVX512Fé(ÚAVX512CDzAVX512ER AVX512PFÚ
AVX512_KNL)rrÚgroupÚdetectr%é)z)AVX5124FMAPS AVX5124VNNIW AVX512VPOPCNTDQÚ
AVX512_KNMé*zAVX512VL AVX512BW AVX512DQÚ
AVX512_SKXzAVX512BW_MASK AVX512DQ_MASK)rrr4r5r%r.é+Z
AVX512VNNIÚ
AVX512_CLX)rrr4r5é,zAVX512IFMA AVX512VBMIÚ
AVX512_CNLé-zAVX512_CLX AVX512_CNLz(AVX512VBMI2 AVX512BITALG AVX512VPOPCNTDQÚ
AVX512_ICLz    altivec.hZVSX_ASM)rrr.ÚVSX)rrr%ÚVSX2ÚVSX3ZVSX4_MMAz vecintrin.h)rrÚVXÚVXEz
arm_neon.hÚNEONÚ    NEON_FP16zNEON_FP16 NEON_VFPV4ÚASIMDÚASIMDHP)#rrrrr r"r$r'ÚXOPÚFMA4r+ÚFMA3ÚAVX2r0r2r3r7r9r;r=r?r@rArBÚVSX4rCrDÚVXE2rErFÚ
NEON_VFPV4rGrHÚASIMDDPÚASIMDFHMcCsd|jr
iS|jp|j}|jp |j}|rÚ|rÚttddtddtddtddtddtddtddtd    dtd
dtd dtd dtd dtddtddtddtddtddtddtddtddtdddS|r”|jr”ttddtddtddtddtdditddtd    ditddtddtdddtdddtdddtd ddtd!dtd"dtd#dtd$dtd%dtd&ddS|rN|jrNttd'dtd(dtd)dtd*dtd+ditd,dtd-ditddtddtdd.dtdd.dtdd/dtd d/dtd0dtd1dtd2dtd3dtd4dtd5ddS|rü|jrüt|jrptd'dni|jr„td(dniiiitd6d7itd-ditd8d7td8d7tdd9dtd:d9dtd;d<dtd=d<dtd>dtd>dtd<diiidS|j    p|j
}|rˆtt|j    r d?nd@dAdtdBdCdDtdEdCdDtdFdCdDdG}|jr„dH|dIdJ<dK|d?dJ<dL|dMdJ<dN|dOdJ<|S|j }|r¼ttdPdtdQdCdDtdRdCdDdS}|S|j r|rttdTdUdVtdWdUdVtdXdUdVtdYdUdVtdZdtd[dtd\dd]S|j r`|r`ttd^dtd_dtd`dtdadtdZdtd[dtd\dd]SiS)ba7Return a dictionary of supported CPU features by the platform,
        and accumulate the rest of undefined options in `conf_features`,
        the returned dict has same rules and notes in
        class attribute `conf_features`, also its override
        any options that been set in 'conf_features'.
        z-msse)Úflagsz-msse2z-msse3z-mssse3z-msse4.1z-mpopcntz-msse4.2z-mavxz-mf16cz-mxopz-mfma4z-mfmaz-mavx2z-mavx512f -mno-mmxz
-mavx512cdz-mavx512er -mavx512pfz/-mavx5124fmaps -mavx5124vnniw -mavx512vpopcntdqz -mavx512vl -mavx512bw -mavx512dqz -mavx512vnniz-mavx512ifma -mavx512vbmiz.-mavx512vbmi2 -mavx512bitalg -mavx512vpopcntdq)rrrrr r"r$r'r+rIrJrKrLr0r2r3r7r9r;r=r?z!Intel Compiler doesn't support it)Údisablez    F16C AVX2z-march=core-avx2)rrRrKz AVX2 AVX512CDz-march=common-avx512z AVX2 AVX512Fz-xKNLz-xKNMz-xSKYLAKE-AVX512z -xCASCADELAKEz -xCANNONLAKEz-xICELAKE-CLIENTz    /arch:SSEz
/arch:SSE2z
/arch:SSE3z /arch:SSSE3z /arch:SSE4.1z /arch:SSE4.2z    /arch:AVXz/arch:CORE-AVX2z/Qx:COMMON-AVX512z/Qx:KNLz/Qx:KNMz/Qx:SKYLAKE-AVX512z/Qx:CASCADELAKEz/Qx:CANNONLAKEz/Qx:ICELAKE-CLIENTz nmmintrin.h)rz ammintrin.hz
/arch:AVX2z    F16C FMA3zAVX2 AVX512CD AVX512_SKXz /arch:AVX512zAVX512F AVX512_SKXz MSVC compiler doesn't support itrAr z-mvsxz -mcpu=power8F)rRr%z-mcpu=power9 -mtune=power9z-mcpu=power10 -mtune=power10)r@rArBrMz-maltivec -mvsxr@rRz-mpower8-vectorz-mpower9-vectorrBz-mpower10-vectorrMz-march=arch11 -mzvectorz -march=arch12z -march=arch13)rCrDrNzNEON_FP16 NEON_VFPV4 ASIMDT)rÚautoveczNEON NEON_VFPV4 ASIMDzNEON NEON_FP16 ASIMDzNEON NEON_FP16 NEON_VFPV4z-march=armv8.2-a+fp16z-march=armv8.2-a+dotprodz-march=armv8.2-a+fp16fml)rErFrOrGrHrPrQz
-mfpu=neonz"-mfpu=neon-fp16 -mfp16-format=ieeez-mfpu=neon-vfpv4z'-mfpu=neon-fp-armv8 -march=armv8-a+simd)Úcc_nooptÚ    cc_on_x86Ú    cc_on_x64Ú    cc_is_gccÚ cc_is_clangÚdictÚ    cc_is_iccÚ
cc_is_iccwÚ
cc_is_msvcÚ cc_on_ppc64leÚ cc_on_ppc64Ú cc_on_s390xÚ cc_on_aarch64Ú cc_on_armhf)ÚselfZon_x86Zis_unixZon_powerÚpartialZon_zarch©reúTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/distutils/ccompiler_opt.pyÚconf_features_partialIsØ  ÿÿéÿ
ÿÿãÿÿÿÿá!ÿÿÿÿÿÿÜ'þÿÿÿõ    ÿÿÿù ÿÿÿÿÿÿÿíÿÿÿÿÿÿÿíz_Config.conf_features_partialcsb|jdkr@ddl‰ddl}| ¡‰‡‡fdd„}t |¡ˆ|_|jdkr^tj     t
¡|j g|_dS)Nrcs(zˆ ˆ¡Wntk
r"YnXdS©N)ÚrmtreeÚOSErrorre©ÚshutilÚtmprerfÚrm_temp9sz!_Config.__init__.<locals>.rm_temp) Ú conf_tmp_pathrlÚtempfileÚmkdtempÚatexitÚregisterÚconf_cache_factorsÚosÚpathÚgetmtimeÚ__file__Ú conf_nocache)rcrprnrerkrfÚ__init__4s
 
 
 
þz_Config.__init__)Ú__name__Ú
__module__Ú __qualname__Ú__doc__ryÚ
conf_nooptrtrorurvÚjoinÚdirnameÚrealpathrxÚconf_check_pathÚconf_target_groupsÚ conf_c_prefixÚconf_c_prefix_rZÚ conf_cc_flagsÚconf_min_featuresÚ conf_featuresrgrzrerererfrs"ÿûø
ýýýä"ù    ü     
þ  
 
 
þ
þýýþþý   ÿ
 
 
 
 
 
 
¬Vlrc@sšeZdZdZdd„Zddd„Zgfdd„Zd    d
„Zed d „ƒZ    ed d„ƒZ
eddœdd„ƒZ edd„ƒZ edd„ƒZ ddd„Ze d¡Zeddd„ƒZdS)Ú
_Distutilsa¾A helper class that provides a collection of fundamental methods
    implemented in a top of Python and NumPy Distutils.
 
    The idea behind this class is to gather all methods that it may
    need to override in case of reuse 'CCompilerOpt' in environment
    different than of what NumPy has.
 
    Parameters
    ----------
    ccompiler : `CCompiler`
        The generate instance that returned from `distutils.ccompiler.new_compiler()`.
    cCs
||_dSrh)Ú
_ccompiler)rcÚ    ccompilerrererfrzTsz_Distutils.__init__NcKsLt|tƒst‚t|tƒst‚| dg¡|}|s6|j}|j|fd|i|—ŽS)zWrap CCompiler.compile()Zextra_postargs)Ú
isinstanceÚlistÚAssertionErrorÚpopr‹Úcompile)rcÚsourcesrRrŒÚkwargsrererfÚ dist_compileWs z_Distutils.dist_compilec
 
CsÐt|tƒst‚ddlm}|j}t|ddƒ}|rdt|jddƒ}|dkrVt|d|jƒnt|d|j    ƒd}z|j
|g|||j d    d
}Wn4|k
rº}    z|j t|    ƒd
d W5d}    ~    XYnX|rÌt|d|ƒ|S) zgReturn True if 'CCompiler.compile()' able to compile
        a source file with certain flags.
        r©Ú CompileErrorÚspawnNÚ compiler_typer )r
F)ÚmacrosÚ
output_dirT©Ústderr) rÚstrrÚdistutils.errorsr–r‹ÚgetattrÚsetattrÚ_dist_test_spawn_pathsÚ_dist_test_spawnr”roÚdist_log)
rcÚsourcerRr™r–ÚccZbk_spawnÚcc_typeÚtestÚerererfÚ    dist_testas.  ÿ$ z_Distutils.dist_testcCsît|dƒr|jSt|jddƒ}|dkr,d}n |dkr:d}ndd    lm}|ƒ}t|jd
t|jd dƒƒ}|rp|d krŽt|d ƒr„|d}q’t|ƒ}n|}t|d ƒr¼t|ƒdkr¼d |dd…¡}n t    j
  dd¡}|t    j
  dd¡7}|||f|_|jS)a!
        Return a tuple containing info about (platform, compiler, extra_args),
        required by the abstract class '_CCompiler' for discovering the
        platform environment. This is also used as a cache factor in order
        to detect any changes happening from outside.
        Ú
_dist_infor˜r )ZintelemZintelemwÚx86_64)ÚintelZintelwZinteler r)Ú get_platformÚcompilerÚ compiler_soÚunixÚ__iter__rú NÚCFLAGSÚCPPFLAGS) ÚhasattrrªrŸr‹Údistutils.utilr­rÚlenr€ruÚenvironÚget)rcr¦Úplatformr­Zcc_infor®Ú
extra_argsrererfÚ    dist_info{s*
 
 
 
 z_Distutils.dist_infocGsddlm}|tj|Žƒ‚dS)zRaise a compiler errorrr•N)ržr–rŠÚ    _dist_str)Úargsr–rererfÚ
dist_error s z_Distutils.dist_errorcGsddlm}|tj|Žƒ‚dS)zRaise a distutils errorr)ÚDistutilsErrorN)ržrÀrŠr½)r¾rÀrererfÚ
dist_fatal¦s z_Distutils.dist_fatalFr›cGs4ddlm}tj|Ž}|r&| |¡n
| |¡dS)zPrint a console messager)ÚlogN)Znumpy.distutilsrÂrŠr½ÚwarnÚinfo)rœr¾rÂÚoutrererfr£¬s
 
 z_Distutils.dist_logc
CsNddlm}z |||ƒWStk
rH}ztj|ddW5d}~XYnXdS)zALoad a module from file, required by the abstract class '_Cache'.r)Úexec_mod_from_locationTr›N)Z    misc_utilrÆÚ    ExceptionrŠr£)ÚnamervrÆr¨rererfÚdist_load_module¶s    z_Distutils.dist_load_modulecsJ‡fdd„‰t ¡d}d|j|jf}d ‡fdd„|˜Dƒ¡}||S)z+Return a string to print by log and errors.csJt|tƒsBt|dƒrBg}|D]}| ˆ|ƒ¡qdd |¡dSt|ƒS)Nr±ú(r²ú))rrrµÚappendr€)ÚargÚretÚa©Úto_strrerfrÑÃs z$_Distutils._dist_str.<locals>.to_strrzCCompilerOpt.%s[%d] : r²csg|] }ˆ|ƒ‘qSrere)Ú.0rÏrÐrerfÚ
<listcomp>Ísÿz(_Distutils._dist_str.<locals>.<listcomp>)ÚinspectÚstackÚfunctionÚlinenor€)r¾rÕÚstartrÅrerÐrfr½Às  þz_Distutils._dist_strc    CsRt|jdƒs| |¡dSt d¡}z|jjtjd<| |¡W5|tjd<XdS)zŠ
        Fix msvc SDK ENV path same as distutils do
        without it we get c1: fatal error C1356: unable to find mspdbcore.dll
        Ú_pathsNrv)rµr‹r¢ruÚgetenvr¸rÙ)rcÚcmdÚdisplayÚold_pathrererfr¡Ós 
 
z!_Distutils._dist_test_spawn_pathsz/.*(warning D9002|invalid argument for option).*c
Cs²z:tj|tjdd}|r8t tj|¡r8t d|d|¡WnXtjk
rj}z|j    }|j
}W5d}~XYn.t k
r’}z |}d}W5d}~XYnXdSt d|d||f¡dS)NT)rœÚtextzFlags in commandz/aren't supported by the compiler, output -> 
%séÚCommandz(failed with exit status %d output -> 
%s) Ú
subprocessÚ check_outputÚSTDOUTÚreÚmatchrŠÚ_dist_warn_regexr¿ÚCalledProcessErrorÚoutputÚ
returncoderj)rÛrÜÚoÚexcÚsr¨rererfr¢ês6
ÿÿÿÿÿz_Distutils._dist_test_spawn)N)N)N)r{r|r}r~rzr”r©r¼Ú staticmethodr¿rÁr£rÉr½r¡rär‘rær¢rerererfrŠGs* 
 
%
 
    
    
 
ýrŠc@sHeZdZdZe d¡Zddd„Zdd„Zdd    „Z    d
d „Z
e d d „ƒZ dS)Ú_Cachea'An abstract class handles caching functionality, provides two
    levels of caching, in-memory by share instances attributes among
    each other and by store attributes into files.
 
    **Note**:
        any attributes that start with ``_`` or ``conf_`` will be ignored.
 
    Parameters
    ----------
    cache_path : str or None
        The path of cache file, if None then cache in file will disabled.
 
    *factors :
        The caching factors that need to utilize next to `conf_cache_factors`.
 
    Attributes
    ----------
    cache_private : set
        Hold the attributes that need be skipped from "in-memory cache".
 
    cache_infile : bool
        Utilized during initializing this class, to determine if the cache was able
        to loaded from the specified cache path in 'cache_path'.
    z
^(_|conf_)NcGsni|_tƒ|_d|_d|_|jr.| d¡dS|j||jžŽ|_    ||_|rît
j   |¡rî| d|¡|  d|¡}|s‚|jdddnlt|dƒr–t|d    ƒs¦|jd
ddnH|j    |jkrä| d ¡|j ¡D]\}}t|||ƒqÆd|_n
| d ¡|jsTt |j    ¡}|rT| d ¡|j ¡D]6\}}||jkst |j|¡rDqt|||ƒq|t|j    <t |j¡dS)NFzcache is disabled by `Config`zload cache from file ->Úcachez)unable to load the cache file as a moduleTr›ÚhashÚdatazinvalid cache filezhit the file cachezmiss the file cachezhit the memory cache)Úcache_meÚsetÚ cache_privateÚ cache_infileÚ _cache_pathryr£Ú
cache_hashrtÚ _cache_hashrurvÚexistsrÉrµrðrñÚitemsr Ú _share_cacher¹Ú__dict__räråÚ _cache_ignorerrrsÚ cache_flush)rcÚ
cache_pathÚfactorsZ    cache_modÚattrÚvalZ other_cacherererfrzsP
   þ
ÿ 
 
 
  ÿ
z_Cache.__init__cCs,t ¡D]\}}||krt |¡q(qdSrh)rûrúr)rcÚhrêrererfÚ__del__Ls
z_Cache.__del__c    Csº|js
dS| d|j¡|j ¡}|j ¡D]}t |j|¡r,| |¡q,t    j
  |j¡}t    j
  |¡snt      |¡tj|dd}t|jdƒ(}| t d¡ |j¡¡| |¡W5QRXdS)z)
        Force update the cache.
        Nzwrite cache to path ->T)ÚcompactÚwz¿            # AUTOGENERATED DON'T EDIT
            # Please make changes to the code generator             (distutils/ccompiler_opt.py)
            hash = {}
            data = \
            )rör£rüÚcopyÚkeysrärårýrrurvrrùÚmakedirsÚpprintÚpformatÚopenÚwriteÚtextwrapÚdedentÚformatrø)rcZcdictrÚdÚ    repr_dictÚfrererfrþRs 
 
úz_Cache.cache_flushcGsDd}|D]6}t|ƒD](}t|ƒ|d>|d>|}|dM}qq|S)Nrrélÿÿ)rÚord)rcrZchashrÚcharrererfr÷ns   z_Cache.cache_hashcs‡fdd„}|S)zr
        A static method that can be treated as a decorator to
        dynamically cache certain methods.
        csNtˆjf|| ¡| ¡˜ƒ}||jkr0|j|Sˆ|f|ž|Ž}||j|<|Srh)rr{rÚvaluesrò)rcr¾r“Ú    cache_keyZccb©ÚcbrerfÚ cache_wrap_me~sÿÿ
 
 
z _Cache.me.<locals>.cache_wrap_mere)rrrerrfÚmexs
z    _Cache.me)N) r{r|r}r~rär‘rýrzrrþr÷rírrerererfrîs
 
-
rîc@sŒeZdZdZdd„Zejdd„ƒZejgfdd„ƒZdd    „Z    e
  d
¡Z e
  d ¡Z e
  d ¡Ze
  d ¡Zdd„Ze
  d¡Ze
  d¡Zdd„ZdS)Ú
_CCompilera2A helper class for `CCompilerOpt` containing all utilities that
    related to the fundamental compiler's functions.
 
    Attributes
    ----------
    cc_on_x86 : bool
        True when the target architecture is 32-bit x86
    cc_on_x64 : bool
        True when the target architecture is 64-bit x86
    cc_on_ppc64 : bool
        True when the target architecture is 64-bit big-endian powerpc
    cc_on_ppc64le : bool
        True when the target architecture is 64-bit litle-endian powerpc
    cc_on_s390x : bool
        True when the target architecture is IBM/ZARCH on linux
    cc_on_armhf : bool
        True when the target architecture is 32-bit ARMv7+
    cc_on_aarch64 : bool
        True when the target architecture is 64-bit Armv8-a+
    cc_on_noarch : bool
        True when the target architecture is unknown or not supported
    cc_is_gcc : bool
        True if the compiler is GNU or
        if the compiler is unknown
    cc_is_clang : bool
        True if the compiler is Clang
    cc_is_icc : bool
        True if the compiler is Intel compiler (unix like)
    cc_is_iccw : bool
        True if the compiler is Intel compiler (msvc like)
    cc_is_nocc : bool
        True if the compiler isn't supported directly,
        Note: that cause a fail-back to gcc
    cc_has_debug : bool
        True if the compiler has debug flags
    cc_has_native : bool
        True if the compiler has native flags
    cc_noopt : bool
        True if the compiler has definition 'DISABLE_OPT*',
        or 'cc_on_noarch' is True
    cc_march : str
        The target architecture name, or "unknown" if
        the architecture isn't supported
    cc_name : str
        The compiler name, or "unknown" if the compiler isn't supported
    cc_flags : dict
        Dictionary containing the initialized flags of `_Config.conf_cc_flags`
    cCsVt|dƒrdSd}d}d}| ¡}|\}}}|||fD] }|D]\}    }
} t||    dƒq>q6||f||ffD]N\} } | D]@\}    }
} |
r”t |
| tj¡s”qt| r¤| | ¡s¤qtt||    dƒqhqtqh|D]<\}    }
} |
rÜt |
|tj¡sÜq¼| rì| | ¡sìq¼t||    dƒq¼|jr|jd|›ddd    d|_    |j
r:|jd
dd    d|_    |j r^|jd |›ddd    d|_ d |_ d D]"}t|d|ƒrh||_ qŒqhd |_dD]"}t|d|ƒr–||_qºq–i|_|j |j¡}|dkrè| d|j¡| ¡D]Z\}}g|j|<}|rðt|tƒst‚| ¡}|D]}| |g¡r(| |¡q(qðd|_dS)NÚ cc_is_cached))rWz.*(x|x86_|amd)64.*r )rVz.*(win32|x86|i386|i686).*r )r^z&.*(powerpc|ppc)64(el|le).*|.*powerpc.*z4defined(__powerpc64__) && defined(__LITTLE_ENDIAN__))r_z.*(powerpc|ppc).*|.*powerpc.*z1defined(__powerpc64__) && defined(__BIG_ENDIAN__))raz.*(aarch64|arm64).*r )rbz.*arm.*z3defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))r`z    .*s390x.*r )Ú cc_on_noarchr r ))rXz.*(gcc|gnu\-g).*r )rYz    .*clang.*r )r\z.*(intelw|intelemw|iccw).*r )r[z.*(intel|icc).*r )r]z.*msvc.*r )Ú
cc_is_noccr r ))Ú cc_has_debugz$.*(O0|Od|ggdb|coverage|debug:full).*r )Ú cc_has_nativez".*(-march=native|-xHost|/QxHost).*r )rUz.*DISABLE_OPT.*r FTz]unable to detect CPU architecture which lead to disable the optimization. check dist_info:<<
z
>>r›z&Optimization is disabled by the Configzªunable to detect compiler type which leads to treating it as GCC. this is a normal behavior if you're using gcc-like compiler such as MinGW or IBM/XLC.check dist_info:<<
Úunknown)r r rrrrrZcc_on_)rrr    rr
Zcc_is_z=undefined flag for compiler '%s', leave an empty dict instead)rµr¼r räråÚ
IGNORECASEÚ cc_test_cexprrr£rUrr rXÚcc_marchrŸÚcc_nameÚcc_flagsr‡r¹rÁrúrrrÚsplitÚ cc_test_flagsrÌr)rcZ detect_archZdetect_compilerZ detect_argsr¼rºZ compiler_infor»ÚsectionrZrgexÚcexprr5ZsearchinÚarchrÈZcompiler_flagsrRZnflagsrrererfrz»s„
 
 
 
ý
ü
 
 
ÿÿz_CCompiler.__init__cCsLt|tƒst‚| d|¡tj |jd¡}| ||¡}|sH|jddd|S)z@
        Returns True if the compiler supports 'flags'.
        z testing flagsz test_flags.cútesting failedTr›)    rrŽrr£rurvr€rƒr©)rcrRÚ    test_pathr§rererfr*/s  z_CCompiler.cc_test_flagsc    Csl| d|¡tj |jd¡}t|dƒ}| t d|›d¡¡W5QRX|     ||¡}|sh|jddd|S)    zJ
        Same as the above but supports compile-time expressions.
        ztesting compiler expressionznpy_dist_test_cexpr.crz               #if !(zq)
                   #error "unsupported expression"
               #endif
               int dummy;
            r.Tr›)
r£rurvr€ror r rrr©)rcr,rRr/Úfdr§rererfr%<s  
ÿ z_CCompiler.cc_test_cexprcCsDt|tƒst‚|js |js |jr*| |¡S|js6|jr@|     |¡S|S)a”
        Remove the conflicts that caused due gathering implied features flags.
 
        Parameters
        ----------
        'flags' list, compiler flags
            flags should be sorted from the lowest to the highest interest.
 
        Returns
        -------
        list, filtered from any conflicts.
 
        Examples
        --------
        >>> self.cc_normalize_flags(['-march=armv8.2-a+fp16', '-march=armv8.2-a+dotprod'])
        ['armv8.2-a+fp16+dotprod']
 
        >>> self.cc_normalize_flags(
            ['-msse', '-msse2', '-msse3', '-mssse3', '-msse4.1', '-msse4.2', '-mavx', '-march=core-avx2']
        )
        ['-march=core-avx2']
        )
rrŽrrXrYr[Ú_cc_normalize_unixr]r\Ú_cc_normalize_win)rcrRrererfÚcc_normalize_flagsOs 
 
z_CCompiler.cc_normalize_flagsz^(-mcpu=|-march=|-x[A-Z0-9\-])zB^(?!(-mcpu=|-march=|-x[A-Z0-9\-]|-m[a-z0-9\-\.]*.$))|(?:-mzvector)z^(-mfpu|-mtune)z[0-9.]csP‡fdd„}t|ƒdkr|Stt|ƒƒD]Ä\}}t ˆj|¡s@q(|d|d …}|| d…}ttˆjj    |ƒƒ}||ƒ\}}    }
|dkrÎt|
ƒdkrÎ|D]"} || ƒ\} } }|| kr˜||
}
q˜|    dd 
|
¡}||g}|dkrè||7}qîq(g}t ƒ}t|ƒD]J}t ˆj |¡}|sn"|d|kr.qn|  |d¡| d|¡q|S)Nc    s@| d¡}tdd t ˆj|d¡¡ƒ}||d|dd…fS)Nú+Ú0r rr)r)Úfloatr€räÚfindallÚ_cc_normalize_arch_ver)rÚtokensÚver©rcrerfÚ    ver_flagss
 
ÿz0_CCompiler._cc_normalize_unix.<locals>.ver_flagsrrr4)r·Ú    enumerateÚreversedräråÚ_cc_normalize_unix_mrgxrŽÚfilterÚ_cc_normalize_unix_frgxÚsearchr€róÚ_cc_normalize_unix_krgxÚaddÚinsert)rcrRr<ÚiZcur_flagZ lower_flagsZ upper_flagsZfilterdr:r-ZsubflagsZxflagZxverÚ_Z    xsubflagsZ final_flagsÚmatchedrrårer;rfr1€sD      ÿ
 
 z_CCompiler._cc_normalize_unixz^(?!(/arch\:|/Qx\:))z ^(/arch|/Qx:)cCs^tt|ƒƒD]L\}}t |j|¡s$q |d7}tt|jj|d| …ƒƒ|| d…S|S)Nr)    r=r>räråÚ_cc_normalize_win_mrgxrŽr@Ú_cc_normalize_win_frgxrB)rcrRrFrrererfr2·s ÿ þz_CCompiler._cc_normalize_winN)r{r|r}r~rzrîrr*r%r3rär‘r?rArCr8r1rJrIr2rerererfrŠs60t
þýþÿ1ÿÿrc@sÈeZdZdZdd„Zddgfdd„Zdd„Zd%d
d „Zd&d d „Zdd„Z    dd„Z
dd„Z dd„Z dd„Z ejdd„ƒZejdgfdd„ƒZejdgfdd„ƒZejdd„ƒZejd d!„ƒZd'd#d$„ZdS)(Ú_FeatureaâA helper class for `CCompilerOpt` that managing CPU features.
 
    Attributes
    ----------
    feature_supported : dict
        Dictionary containing all CPU features that supported
        by the platform, according to the specified values in attribute
        `_Config.conf_features` and `_Config.conf_features_partial()`
 
    feature_min : set
        The minimum support of CPU features, according to
        the specified values in attribute `_Config.conf_min_features`.
    c    st|dƒrdS| ¡|_}t| ¡ƒD]Ž}||‰|j|}ˆ ‡fdd„| ¡Dƒ¡ˆ d¡}|dk    rŒ|     |¡|j
d||ddq(dD]$}ˆ |¡}t |t ƒr|  ¡ˆ|<qq(tƒ|_|j |jd    ¡}| ¡  ¡D]}||jkrÜ|j |¡qÜd|_dS)
NÚfeature_is_cachedcsi|]\}}|ˆkr||“qSrere)rÒÚkÚv©ÚfeaturererfÚ
<dictcomp>Ösz%_Feature.__init__.<locals>.<dictcomp>rSzfeature '%s' is disabled,Tr›)rr4r5rrRr.r )rµrgÚfeature_supportedrŽrr‰Úupdaterúr¹rr£rrr)róÚ feature_minrˆr&ÚupperrDrL)    rcZ    pfeaturesÚ feature_nameZcfeatureÚdisabledÚoptionZovalZmin_fÚFrerOrfrzÏs8
 
ÿ
 
þ
 
 
z_Feature.__init__NcCsv|dks t|tƒst|dƒs t‚|dks6t|tƒs6t‚|dkrH|j ¡}tƒ}|D]}|j|||drR|     |¡qR|S)aˆ
        Returns a set of CPU feature names that supported by platform and the **C** compiler.
 
        Parameters
        ----------
        names : sequence or None, optional
            Specify certain CPU features to test it against the **C** compiler.
            if None(default), it will test all current supported features.
            **Note**: feature names must be in upper-case.
 
        force_flags : list or None, optional
            If None(default), default compiler flags for every CPU feature will
            be used during the test.
 
        macros : list of tuples, optional
            A list of C macro definitions.
        Nr±©Ú force_flagsr™)
rrrµrrŽrRrróÚfeature_is_supportedrD)rcÚnamesr[r™Zsupported_namesrrererfÚ feature_namesñs$ÿþý
ÿ z_Feature.feature_namescCs| ¡s t‚||jkS)zÒ
        Returns True if a certain feature is exist and covered within
        `_Config.conf_features`.
 
        Parameters
        ----------
        'name': str
            feature name in uppercase.
        )Úisupperrr‰)rcrÈrererfÚfeature_is_exists
z_Feature.feature_is_existFcs‡fdd„}t|||dS)az
        Sort a list of CPU features ordered by the lowest interest.
 
        Parameters
        ----------
        'names': sequence
            sequence of supported feature names in uppercase.
        'reverse': bool, optional
            If true, the sorted features is reversed. (highest interest)
 
        Returns
        -------
        list, sorted CPU features
        csBt|tƒrˆj|dSt‡fdd„|Dƒƒ}|t|ƒd7}|S)Nrcsg|]}ˆj|d‘qS)r)rR©rÒrr;rerfrÓ4sz<_Feature.feature_sorted.<locals>.sort_cb.<locals>.<listcomp>r)rrrRÚmaxr·)rMZrankr;rerfÚsort_cb0s
 
z(_Feature.feature_sorted.<locals>.sort_cb)ÚreverseÚkey)Úsorted)rcr]rdrcrer;rfÚfeature_sorted!s     z_Feature.feature_sortedcsltƒf‡‡fdd„    ‰t|tƒr.ˆ|ƒ}|g}n,t|dƒs<t‚tƒ}|D]}| ˆ|ƒ¡}qF|sh| |¡|S)aÇ
        Return a set of CPU features that implied by 'names'
 
        Parameters
        ----------
        names : str or sequence of str
            CPU feature name(s) in uppercase.
 
        keep_origins : bool
            if False(default) then the returned set will not contain any
            features from 'names'. This case happens only when two features
            imply each other.
 
        Examples
        --------
        >>> self.feature_implies("SSE3")
        {'SSE', 'SSE2'}
        >>> self.feature_implies("SSE2")
        {'SSE'}
        >>> self.feature_implies("SSE2", keep_origins=True)
        # 'SSE2' found here since 'SSE' and 'SSE2' imply each other
        {'SSE', 'SSE2'}
        csTtƒ}ˆj|}| dg¡D]2}| |¡||kr4q| |¡| ˆ||ƒ¡}q|S)Nr)rórRr¹rDÚunion)rÈZ_callerrrrF©Ú get_impliesrcrerfrjSs
 
 
z-_Feature.feature_implies.<locals>.get_impliesr±)rórrrµrrhÚdifference_update)rcr]Ú keep_originsrÚnrerirfÚfeature_implies;s
 
z_Feature.feature_impliescCs.t|tƒrt|fƒ}nt|ƒ}| | |¡¡S)z/same as feature_implies() but combining 'names')rrrórhrn)rcr]rererfÚfeature_implies_cls
 z_Feature.feature_implies_ccs^t|tƒst|dƒst‚|j|dd‰‡fdd„|Dƒ}t|ƒdkrZ|j|dddd    …}|S)
a
        Return list of features in 'names' after remove any
        implied features and keep the origins.
 
        Parameters
        ----------
        'names': sequence
            sequence of CPU feature names in uppercase.
 
        Returns
        -------
        list of CPU features sorted as-is 'names'
 
        Examples
        --------
        >>> self.feature_ahead(["SSE2", "SSE3", "SSE41"])
        ["SSE41"]
        # assume AVX2 and FMA3 implies each other and AVX2
        # is the highest interest
        >>> self.feature_ahead(["SSE2", "SSE3", "SSE41", "AVX2", "FMA3"])
        ["AVX2"]
        # assume AVX2 and FMA3 don't implies each other
        >>> self.feature_ahead(["SSE2", "SSE3", "SSE41", "AVX2", "FMA3"])
        ["AVX2", "FMA3"]
        r±T)rlcsg|]}|ˆkr|‘qSrere)rÒrm©rrerfrӓsz*_Feature.feature_ahead.<locals>.<listcomp>r©rdNr)rrrµrrnr·rg)rcr]ZaheadrerprfÚ feature_aheadtsÿþ z_Feature.feature_aheadcst|tƒst|dƒst‚g}|D]j‰ˆ ˆ¡‰‡‡‡fdd„|Dƒ}|r€ˆ |ˆg¡}ˆ|dd…krjq | |dd…d¡| ˆ¡q |S)am
        same as 'feature_ahead()' but if both features implied each other
        and keep the highest interest.
 
        Parameters
        ----------
        'names': sequence
            sequence of CPU feature names in uppercase.
 
        Returns
        -------
        list of CPU features sorted as-is 'names'
 
        Examples
        --------
        >>> self.feature_untied(["SSE2", "SSE3", "SSE41"])
        ["SSE2", "SSE3", "SSE41"]
        # assume AVX2 and FMA3 implies each other
        >>> self.feature_untied(["SSE2", "SSE3", "SSE41", "FMA3", "AVX2"])
        ["SSE2", "SSE3", "SSE41", "AVX2"]
        r±cs&g|]}|ˆkrˆˆ |¡kr|‘qSre)rn)rÒÚnn©rrmrcrerfrÓ·sÿz+_Feature.feature_untied.<locals>.<listcomp>rNr)rrrµrrnrgÚremoverÌ)rcr]ÚfinalZtiedrertrfÚfeature_untiedšs"ÿþ
ÿ z_Feature.feature_untiedcs^‡‡fdd„‰t|tƒs$t|ƒdkr8ˆ|ƒ}| ¡|Sˆ |¡}‡fdd„|Dƒ}ˆ |¡S)zÝ
        same as `feature_implies_c()` but stop collecting implied
        features when feature's option that provided through
        parameter 'keyisfalse' is False, also sorting the returned
        features.
        csTˆ |¡}ˆj|dd}t|ƒD].\}}ˆj| ˆd¡s |d|d…}qPq |S)NTrqr)rorgr=rRr¹)ZtnamesrFrm)Ú
keyisfalsercrerfÚtilÊs
z%_Feature.feature_get_til.<locals>.tilrcsh|]}ˆ|ƒD]}|’qqSrere)rÒrmÚt)ryrerfÚ    <setcomp>Ûs
z+_Feature.feature_get_til.<locals>.<setcomp>)rrr·rdrrrg)rcr]rxre)rxrcryrfÚfeature_get_tilÃs
 
z_Feature.feature_get_tilc    CsB| |d¡}g}|D](}|j|}|| d| d|g¡¡7}q|S)z€
        Return a list of CPU features that required to be detected
        sorted from the lowest to highest interest.
        r%r5r4)r|rRr¹)rcr]r5rmrrererfÚfeature_detectÞs  
z_Feature.feature_detectcCsV| | |¡¡}g}|D]2}|j|}| dg¡}|r| |¡sBq||7}q| |¡S)zi
        Return a list of CPU features flags sorted from the lowest
        to highest interest.
        rR)rgrorRr¹r*r3)rcr]rRrmrrrererfÚ feature_flagsês
 
z_Feature.feature_flagscCsŠ|dkr| |¡}| d|d |¡f¡tj |jd| ¡¡}tj |¡sZ| d|¡|j    |||j
d|d}|s†|jdd    d
|S) a­
        Test a certain CPU feature against the compiler through its own
        check file.
 
        Parameters
        ----------
        name : str
            Supported CPU feature name.
 
        force_flags : list or None, optional
            If None(default), the returned flags from `feature_flags()`
            will be used.
 
        macros : list of tuples, optional
            A list of C macro definitions.
        Nz$testing feature '%s' with flags (%s)r²zcpu_%s.czfeature test file is not existr©r™r.Tr›) r~r£r€rurvrƒÚlowerrùrÁr©r()rcrÈr[r™r/r§rererfÚ feature_testús,
ÿÿ
ÿ   ÿz_Feature.feature_testcCsn| ¡s t‚|dks"t|tƒs"t‚||jk}|rj| |¡D]}|j|||ds:dSq:|j|||dsjdS|S)aµ
        Check if a certain CPU feature is supported by the platform and compiler.
 
        Parameters
        ----------
        name : str
            CPU feature name in uppercase.
 
        force_flags : list or None, optional
            If None(default), default compiler flags for every CPU feature will
            be used during test.
 
        macros : list of tuples, optional
            A list of C macro definitions.
        NrF)r_rrrŽrRrnr)rcrÈr[r™Ú    supportedÚimplrererfr\"s 
z_Feature.feature_is_supportedcsVt|tƒst‚ˆj|}| dd¡}|dkrR‡fdd„| dg¡Dƒ}|oPt|ƒ}|S)zM
        check if the feature can be auto-vectorized by the compiler
        rTNcsg|]}ˆ |g¡‘qSre)r*rar;rerfrÓHsz0_Feature.feature_can_autovec.<locals>.<listcomp>rR)rrrrRr¹Úany)rcrÈrÚcanZ valid_flagsrer;rfÚfeature_can_autovec?s
 
 
ÿ z_Feature.feature_can_autovecc
CsÐt|tƒst‚|j|}| dg¡}|s,gS| d||¡| |¡}g}g}|D]d}tj     |j
d|  ¡¡}tj  |¡s†|  d|¡| |||jd¡}    |    r¬| |¡qR| |¡qR|rÌ|jd|dd|S)    zÐ
        Return a list of supported extra checks after testing them against
        the compiler.
 
        Parameters
        ----------
        names : str
            CPU feature name in uppercase.
        r.z%Testing extra checks for feature '%s'z
extra_%s.czextra check file does not existrztesting failed for checksTr›)rrrrRr¹r£r~rurvr€rƒr€rùrÁr©r(rÌ)
rcrÈrr.rRÚ    availableZ not_availableZchkr/Ú is_supportedrererfÚfeature_extra_checksNs. 
 
 
ÿ    z_Feature.feature_extra_checksrcs¾| ¡s t‚|j |¡}|dk    s$t‚d|d|j|fg}|dd„| dg¡Dƒ7}| dg¡}|| |¡7}|D]&}|d|j|fd    |j|fd
g7}qrˆd kr´‡fd d„|Dƒ}d  |¡S)a"
        Generate C preprocessor definitions and include headers of a CPU feature.
 
        Parameters
        ----------
        'feature_name': str
            CPU feature name in uppercase.
        'tabs': int
            if > 0, align the generated strings to the right depend on number of tabs.
 
        Returns
        -------
        str, generated C preprocessor
 
        Examples
        --------
        >>> self.feature_c_preprocessor("SSE3")
        /** SSE3 **/
        #define NPY_HAVE_SSE3 1
        #include <pmmintrin.h>
        Nz
/** %s **/z#define %sHAVE_%s 1cSsg|] }d|‘qS)z #include <%s>re)rÒrrererfrӓsz3_Feature.feature_c_preprocessor.<locals>.<listcomp>rr4z#ifndef %sHAVE_%sz    #define %sHAVE_%s 1z#endifrcsg|]}dˆ|‘qS)ú    re)rÒÚl©ÚtabsrerfrÓ£sÚ
)r_rrRr¹r…r‰r€)rcrVrrPZpreprZ
extra_defsZedefrerŒrfÚfeature_c_preprocessorus(    þ
ÿ   ýz_Feature.feature_c_preprocessor)F)F)r)r{r|r}r~rzr^r`rgrnrorrrwr|r}rîrr~rr\r†r‰rrerererfrKÁs, "#
 
1&) 
'
 
&rKc@sŒeZdZdZdd„Zdd„Ze d¡Zdd„Z    e d    ¡Z
d
d „Z d d „Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS)Ú_ParseaéA helper class that parsing main arguments of `CCompilerOpt`,
    also parsing configuration statements in dispatch-able sources.
 
    Parameters
    ----------
    cpu_baseline : str or None
        minimal set of required CPU features or special options.
 
    cpu_dispatch : str or None
        dispatched set of additional CPU features or special options.
 
    Special options can be:
        - **MIN**: Enables the minimum CPU features that utilized via `_Config.conf_min_features`
        - **MAX**: Enables all supported CPU features by the Compiler and platform.
        - **NATIVE**: Enables all CPU features that supported by the current machine.
        - **NONE**: Enables nothing
        - **Operand +/-**: remove or add features, useful with options **MAX**, **MIN** and **NATIVE**.
            NOTE: operand + is only added for nominal reason.
 
    NOTES:
        - Case-insensitive among all CPU features and special options.
        - Comma or space can be used as a separator.
        - If the CPU feature is not supported by the user platform or compiler,
          it will be skipped rather than raising a fatal error.
        - Any specified CPU features to 'cpu_dispatch' will be skipped if its part of CPU baseline features
        - 'cpu_baseline' force enables implied features.
 
    Attributes
    ----------
    parse_baseline_names : list
        Final CPU baseline's feature names(sorted from low to high)
    parse_baseline_flags : list
        Compiler flags of baseline features
    parse_dispatch_names : list
        Final CPU dispatch-able feature names(sorted from low to high)
    parse_target_groups : dict
        Dictionary containing initialized target groups that configured
        through class attribute `conf_target_groups`.
 
        The key is represent the group name and value is a tuple
        contains three items :
            - bool, True if group has the 'baseline' option.
            - list, list of CPU features.
            - list, list of extra compiler flags.
 
    c s¦tdˆjgfˆjˆjgfˆjdgfˆjdgfˆjddgfdˆ_tˆdƒrNdSgˆ_    gˆ_
gˆ_ iˆ_ ˆj rtd}}ˆ d¡|dk    rºˆ d|¡}ˆ |¡}ˆ |¡ˆ_
ˆ ˆ |¡¡ˆ_    ˆ d¡|dk    r$ˆ d|¡}‡fdd    „|Dƒ}| |¡}ˆ ˆ |¡¡ˆ_ t|ƒd
kr$ˆ d |d ¡ˆ d ¡ˆj ¡D]b\}}ˆ d|¡| ¡}|rd| ¡sxdggfˆj |<q8ˆ |¡\}    }
} |    |
| fˆj |<q8dˆ_dS)NÚMAXOPT)Z KEEP_BASELINEZ    KEEP_SORTr‘ZWERRORZAUTOVECÚparse_is_cachedzcheck requested baselineÚ cpu_baselinez&check requested dispatch-able featuresÚ cpu_dispatchcsh|]}|ˆjkr|’qSre©Úparse_baseline_namesrar;rerfr{s
ÿz"_Parse.__init__.<locals>.<setcomp>rz skip featureszsince its part of baselinezinitialize targets groupszparse target groupFT)rZÚ_parse_policy_not_keepbaseÚ_parse_policy_keepsortÚ_parse_policy_not_keepsortÚ_parse_policy_maxoptÚ_parse_policy_werrorÚ_parse_policy_autovecÚ_parse_policiesrµr–Úparse_baseline_flagsÚparse_dispatch_namesÚparse_target_groupsrUr£Ú_parse_arg_featuresr^r~rgroÚ
differencer·r„rúrUÚstripÚ_parse_target_tokensr’) rcr“r”Úbaseline_namesZ cpu_dispatch_Zconflict_baselineZ
group_namer9Z
GROUP_NAMEÚ has_baselineÚfeaturesÚ extra_flagsrer;rfrzÕsŽþýþþþí
 
 
 ÿ
 
 
ÿ
ÿÿ
 ÿ
ÿÿz_Parse.__init__c     Csü| d|¡t|ƒ }d}d}d}d}d}d}t|ƒD]x\}    }
|    |krT| d¡q°|dkr||
 |¡}|dkrpq6|t|ƒ7}||
7}|
 |¡}|dkr6|t|ƒt|
ƒ7}q°q6W5QRX|dkrÐ| d|¡|dkræ| d    |¡|||…}| |¡S)
aÖ
        Fetch and parse configuration statements that required for
        defining the targeted CPU features, statements should be declared
        in the top of source in between **C** comment and start
        with a special mark **@targets**.
 
        Configuration statements are sort of keywords representing
        CPU features names, group of statements and policies, combined
        together to determine the required optimization.
 
        Parameters
        ----------
        source : str
            the path of **C** source file.
 
        Returns
        -------
        - bool, True if group has the 'baseline' option
        - list, list of CPU features
        - list, list of extra compiler flags
        z!looking for '@targets' inside -> r ièz@targetséÿÿÿÿz*/zreached the max of linesz(expected to find '%s' within a C commentzexpected to end with '%s')r£r r=rÁÚfindr·r¤) rcr¤r0r9Z max_to_reachZ
start_withZ    start_posZend_withZend_posÚ current_lineÚlinerererfÚ parse_targets's8 
 
 
 
 z_Parse.parse_targetsz \s|,|([+-])c
Cs>t|tƒs| d|¡tƒ}ttdt |j|¡ƒƒ}d}|D]ú}|ddkrZ| |d¡|dkrhd}q>|dkrvd}q>|     ¡}tƒ}|d    krŽnŠ|d
krÂ|j
d }    |    s°| |d ¡|j |    d gd}nV|dkrÖ|j   ¡}nB|dkræ|j}n2||j krü| |¡n| |¡s| |d|¡|r*| |¡}n
| |¡}d}q>|S)Nzexpected a string in '%s'Tr)ú#ú$zYtarget groups and policies aren't allowed from arguments, only from dispatch-able sourcesr4ú-FÚNONEZNATIVErz-native option isn't supported by the compiler)ZDETECT_FEATURESrrZÚMAXZMINz&, '%s' isn't a known feature or option)rrrÁrórŽr@rär)Ú_parse_regex_argrUr(r^rRrrTrDr`rhr¢)
rcZarg_nameZ req_featuresZfinal_featuresr9rÌÚtokÚTOKZ features_torrererfr¡^s\
 ÿ
ÿÿ 
  ÿ 
z_Parse._parse_arg_featuresz\s|[*,/]|([()])cCsøt|tƒst‚g}g}d}tƒ}tƒ}d}ttdt |j|¡ƒƒ}|sP|     d¡|D]°}| 
¡}    |d}
|
dkr~|     d¡qT|
dkrª|dk    r˜|     d¡|  |  |    ¡¡qT|
dkrÜ|dk    rÄ|     d    ¡|  |    |||¡\}}}qT|
d
kr|dk    rø|     d ¡tƒ}qT|
d krx|dkr|     d ¡| |¡} | dkrB|  t|ƒ¡n0t| ƒdkrX| d} | rr| |krr| | ¡d}qT|    dkrœ|dk    r–|     d¡d}qT|dk    r²|  |    ¡qT| |    ¡sÌ|     d|    ¡|    |jkpà|    |jk} | rü|    |krT| |    ¡qT|  |    ¡qT|dk    r|     d ¡|r0| d|d¡| |¡}t|ƒD]L} |j| \}}}|D]0}||krlqZ| d| |f¡|  |¡qZqB|j ¡D]R\} \}}}d}| |krÊ|}| d| ¡n|}|sؐqš||||ƒ\}}}qš|||fS)NFzexpected one token at leastr)r4r°ze+/- are 'not' allowed from target's groups or @targets, only from cpu_baseline and cpu_dispatch parmsr¯zCpolicies aren't allowed inside multi-target '()', only CPU featuresr®zHtarget groups aren't allowed inside multi-target '()', only CPU featuresrÊz"unclosed multi-target, missing ')'rËz$multi-target opener '(' wasn't foundrZBASELINEz/baseline isn't allowed inside multi-target '()'Tzinvalid target name '%s'z skip targetsz.not part of baseline or dispatch-able featureszpolicy '%s' force enables '%s'zpolicy '%s' is ON)rrrrórŽr@rär)Ú_parse_regex_targetrÁrUrDÚ_parse_token_policyÚ_parse_token_groupÚ_parse_multi_targetÚtupler·rÌr`r–rŸr£rwrrú)rcr9Ú final_targetsr¨r¦ÚskippedZpoliciesZ multi_targetr´rµÚchÚtargetsÚ
is_enabledÚprGÚdepsrZhaveZnhaveÚfuncrererfr¤—sÄ
 
ÿÿÿÿ
 
 
 
 
 
 
 
 
 
 
 
 
 
  þ
 
 
þ
 
ÿÿ
ÿz_Parse._parse_target_tokenscCsZt|ƒdks |dd…|dkr*| d¡|dd…}||jkrV| d||j ¡¡|S)zvalidate policy tokenrr©Nrz*'$' must stuck in the begin of policy namez6'%s' is an invalid policy name, available policies are)r·rÁrr)rcÚtokenrererfr· s 
 
þz_Parse._parse_token_policycs°t|ƒdks |dd…|dkr*| d¡|dd…}|j |ddgf¡\}}}|dkrr| d|d|j ¡¡|rzd    }ˆ‡fd
d „|Dƒ7‰ˆ‡fd d „|Dƒ7‰|ˆˆfS) zvalidate group tokenrr©Nrz)'#' must stuck in the begin of group nameFz&'%s' is an invalid target group name, zavailable target groups areTcsg|]}|ˆkr|‘qSrerera)r»rerfrÓ)sz-_Parse._parse_token_group.<locals>.<listcomp>csg|]}|ˆkr|‘qSrerera)r¨rerfrÓ*s)r·rÁr r¹r)rcrÃr¦r»r¨Z ghas_baselineZgtargetsZ gextra_flagsre)r¨r»rfr¸s& 
 ÿ
ÿýz_Parse._parse_token_groupcsr|sˆ d¡t‡fdd„|Dƒƒs0ˆ d|¡t‡fdd„|DƒƒsJdSˆ |¡}|s\dSˆ |¡}t|ƒ}|S)z9validate multi targets that defined between parentheses()zempty multi-target '()'csg|]}ˆ |¡‘qSre)r`©rÒÚtarr;rerfrÓ2sz._Parse._parse_multi_target.<locals>.<listcomp>z#invalid target name in multi-targetcs g|]}|ˆjkp|ˆjk‘qSre)r–rŸrÄr;rerfrÓ6sý
N)rÁÚallrrrgrº)rcr¾rer;rfr¹-s 
 ÿ  û
 
z_Parse._parse_multi_targetcsxg}|dd…D]L}d}t|tƒr.|ˆjk}nt‡fdd„|Dƒƒ}|r| |¡| |¡q|rnˆ d|¡|||fS)zskip all baseline featuresNFcsg|]}|ˆjk‘qSrer•rar;rerfrÓOsÿz5_Parse._parse_policy_not_keepbase.<locals>.<listcomp>zskip baseline features)rrr–rÆrÌrur£)rcr¦r»r¨r¼rÅZis_baserer;rfr—Fs
  þ
  z!_Parse._parse_policy_not_keepbasecCs| d|d¡|||fS)z$leave a notice that $keep_sort is onz/policy 'keep_sort' is on, dispatch-able targetszo
are 'not' sorted depend on the highest interest butas specified in the dispatch-able source or the extra group)r£©rcr¦r»r¨rererfr˜\s ÿz_Parse._parse_policy_keepsortcCs|j|dd}|||fS)z%sorted depend on the highest interestTrq)rgrÇrererfr™esz!_Parse._parse_policy_not_keepsortcCsT|jr| d¡n8|jr$| d¡n&|jd}|sB|jdddn||7}|||fS)z&append the compiler optimization flagsz3debug mode is detected, policy 'maxopt' is skipped.z5optimization is disabled, policy 'maxopt' is skipped.rzOcurrent compiler doesn't support optimization flags, policy 'maxopt' is skippedTr›)r!r£rUr(©rcr¦r»r¨rRrererfršjs  
þz_Parse._parse_policy_maxoptcCs:|jd}|s|jdddn| d¡||7}|||fS)z#force warnings to treated as errorsrzTcurrent compiler doesn't support werror flags, warnings will 'not' treated as errorsTr›z'compiler warnings are treated as errors)r(r£rÈrererfr›{s
þ
z_Parse._parse_policy_werrorcstg}|dd…D]H}t|tƒr*ˆ |¡}nt‡fdd„|Dƒƒ}|s| |¡| |¡q|rjˆ d|¡|||fS)z=skip features that has no auto-vectorized support by compilerNcsg|]}ˆ |¡‘qSre)r†©rÒrzr;rerfrӏsÿz0_Parse._parse_policy_autovec.<locals>.<listcomp>z!skip non auto-vectorized features)rrr†rÆrurÌr£)rcr¦r»r¨r¼rÅr…rer;rfrœˆs
  þ
  z_Parse._parse_policy_autovecN)r{r|r}r~rzr­rär‘r³r¡r¶r¤r·r¸r¹r—r˜r™ršr›rœrerererfr¦s .R6
8
t      rc@sjeZdZdZddd„Zdd„Zd    d
„Zd d „Zd d„Zddd„Z    dd„Z
ddd„Z ddd„Z ddd„Z dS)Ú CCompilerOptz°
    A helper class for `CCompiler` aims to provide extra build options
    to effectively control of compiler optimizations that are directly
    related to CPU features.
    ÚminrbNcCsžt |¡t ||¡t ||| ¡||¡t |¡t |¡|jsZ|jrZ|     d¡d}t
 |||¡||_ ||_ t |diƒ|_|j d¡t|dƒ|_dS)NzSnative flag is specified through environment variables. force cpu-baseline='native'rÚsources_statusÚ    hit_cache)rrzrŠrîr¼rrKrUr"r£rÚ_requested_baselineÚ_requested_dispatchrŸrÌrôrDrµrÍ)rcrŒr“r”rÿrererfrz¢s 
 
 
 ÿ zCCompilerOpt.__init__cCs |jo
|jS)zF
        Returns True if the class loaded from the cache file
        )rõrÍr;rererfÚ    is_cached¼szCCompilerOpt.is_cachedcCs|jS)zE
        Returns a list of final CPU baseline compiler flags
        )ržr;rererfÚcpu_baseline_flagsÂszCCompilerOpt.cpu_baseline_flagscCs|jS)zC
        return a list of final CPU baseline feature names
        r•r;rererfÚcpu_baseline_namesÈszCCompilerOpt.cpu_baseline_namescCs|jS)zC
        return a list of final CPU dispatch feature names
        )rŸr;rererfÚcpu_dispatch_namesÎszCCompilerOpt.cpu_dispatch_namescKs&i}| ¡}| dg¡}|D]Î}tj |¡}    |rZ|     |¡sHtj ||    ¡}    |    |krZ| |    ¡| |¡\}
} } |     |    || |
¡} | D]:}|j
|    ||| d}t | |  |¡ƒ}| |g¡ |¡q~|
rÜt | |ƒ}| |g¡ |¡|
| f|j |<qg}| ¡D](\}}||j|t|ƒfd|i|—Ž7}qø|S)a”
        Compile one or more dispatch-able sources and generates object files,
        also generates abstract C config headers and macros that
        used later for the final runtime dispatching process.
 
        The mechanism behind it is to takes each source file that specified
        in 'sources' and branching it into several files depend on
        special configuration statements that must be declared in the
        top of each source which contains targeted CPU features,
        then it compiles every branched source with the proper compiler flags.
 
        Parameters
        ----------
        sources : list
            Must be a list of dispatch-able sources file paths,
            and configuration statements must be declared inside
            each file.
 
        src_dir : str
            Path of parent directory for the generated headers and wrapped sources.
            If None(default) the files will generated in-place.
 
        ccompiler : CCompiler
            Distutils `CCompiler` instance to be used for compilation.
            If None (default), the provided instance during the initialization
            will be used instead.
 
        **kwargs : any
            Arguments to pass on to the `CCompiler.compile()`
 
        Returns
        -------
        list : generated object files
 
        Raises
        ------
        CompileError
            Raises by `CCompiler.compile()` on compiling failure.
        DistutilsError
            Some errors during checking the sanity of configuration statements.
 
        See Also
        --------
        parse_targets :
            Parsing the configuration statements of dispatch-able sources.
        Ú include_dirs)ÚnochangerŒ)rÑÚ
setdefaultrurvrÚ
startswithr€rÌr­Ú_generate_configÚ _wrap_targetrºr~rÌrúr”rŽ)rcr’Úsrc_dirrŒr“Z
to_compileÚbaseline_flagsrÔÚsrcršr¦r¾r¨rÕrÅZtar_srcrRZobjectsZsrcsrererfÚ try_dispatchÔs>/  
 
 ÿÿÿ
zCCompilerOpt.try_dispatchc sZˆ d|¡ˆ ¡}ˆ ¡}t|ƒ}t|ƒ}tj |¡}tj |¡sfˆjd|›dddt |¡t    |dƒà}d 
‡fdd    „|Dƒ¡}d 
‡fd
d    „|Dƒ¡}    |  t   d ¡jˆjd  
|¡d  
|¡||||    d ¡d}
|D]} |
ˆj| ddd7}
qÜd} |D],} | t   d¡jˆj| ˆj| ddd7} q|  t   d¡jˆj|
| d¡W5QRXdS)ax
        Generate the dispatch header which contains the #definitions and headers
        for platform-specific instruction-sets for the enabled CPU baseline and
        dispatch-able features.
 
        Its highly recommended to take a look at the generated header
        also the generated source files via `try_dispatch()`
        in order to get the full picture.
        z"generate CPU dispatch header: (%s)zdispatch header dir z does not exist, creating itTr›rú \
csg|]}dˆj|f‘qS©z3    %sWITH_CPU_EXPAND_(MACRO_TO_CALL(%s, __VA_ARGS__))©r…rar;rerfrÓE    sþþz9CCompilerOpt.generate_dispatch_header.<locals>.<listcomp>csg|]}dˆj|f‘qSrßràrar;rerfrÓK    sþþaà               /*
                 * AUTOGENERATED DON'T EDIT
                 * Please make changes to the code generator (distutils/ccompiler_opt.py)
                */
                #define {pfx}WITH_CPU_BASELINE  "{baseline_str}"
                #define {pfx}WITH_CPU_DISPATCH  "{dispatch_str}"
                #define {pfx}WITH_CPU_BASELINE_N {baseline_len}
                #define {pfx}WITH_CPU_DISPATCH_N {dispatch_len}
                #define {pfx}WITH_CPU_EXPAND_(X) X
                #define {pfx}WITH_CPU_BASELINE_CALL(MACRO_TO_CALL, ...) \
                {baseline_calls}
                #define {pfx}WITH_CPU_DISPATCH_CALL(MACRO_TO_CALL, ...) \
                {dispatch_calls}
            r²)ÚpfxZ baseline_strZ dispatch_strÚ baseline_lenÚ dispatch_lenÚbaseline_callsÚdispatch_callsr rrŒrŽz†                #ifdef {pfx}CPU_TARGET_{name}
                {pre}
                #endif /*{pfx}CPU_TARGET_{name}*/
                )rárÈÚprez¢            /******* baseline features *******/
            {baseline_pre}
            /******* dispatch features *******/
            {dispatch_pre}
            )ráÚ baseline_preÚ dispatch_preN)r£rÒrÓr·rurvrrùr    r r€r rrrr…rr†) rcZ header_pathr¥Údispatch_namesrârãÚ
header_dirrrärårçrÈrèrer;rfÚgenerate_dispatch_header+    s\
 
þ
 üüî ÿû     ùz%CCompilerOpt.generate_dispatch_headerFc Csg}g}g}g}| d|f¡| d¡| d|f¡| d¡| d|f¡| d|jr^dn|jf¡| d|jrxdn|jf¡|jr”| d    ¡n| d
t|jƒf¡| ¡}| d |rÄd      |¡nd f¡| 
¡}| d|rèd      |¡nd f¡g}|D]}    ||  |    ¡7}qø| d|r"d      |¡nd f¡|jr>| d    ¡n| d
t|j ƒf¡|  ¡}
| d |
rpd      |
¡nd f¡i} |j ¡D],\} \} }|D]}|  |g¡ | ¡q–q†|rÀ| s4d}| | ¡D]@}| |}t|tƒrê|n dd      |¡}    ||    dt|ƒ7}qÎ| d|r(|dd…nd f¡n| d¡| | ¡D]}| |}t|tƒrf|n dd      |¡}d      | |¡¡}d      | | |¡¡¡}d      | |¡¡}g}t|tƒrÀ|fn|D]}    ||  |    ¡7}qÄ|rêd      |¡nd }| d¡| ||f¡| d|f¡| d|f¡| d|f¡|D]}| d|f¡q4qHg}dd„|Dƒ}dd„|Dƒ}d}tt|ƒt|ƒƒ}|D]~\}}|s¤| d¡qˆ|d |t|ƒ7}| ||d¡|D]4\}}|d |t|ƒ7}| ||d|¡qΐqˆd     |¡S)NÚPlatform)r r z CPU baselinez CPU dispatchZ ArchitectureÚ unsupportedZCompilerz    unix-like)Ú    Requestedzoptimization disabledrîZEnabledr²ÚnoneZFlagsz Extra checksr z(%s)z[%d] Ú    Generatedr©)rðr ZDetectcSsg|]\}}t|ƒ‘qSre©r·)rÒZsecsrGrererfrÓÛ    sz'CCompilerOpt.report.<locals>.<listcomp>cSs&g|]\}}|D]\}}t|ƒ‘qqSrerñ)rÒrGÚrowsÚcolrererfrÓÜ    sz  z: rŽ)rÌrr&r r'rUÚreprrÎrÒr€rÑr‰rÏrÓrÌrúrÖrgrrr·r~rnr}rb) rcÚfullÚreportZ platform_rowsZ baseline_rowsZ dispatch_rowsr¥rÛr.rÈréZtarget_sourcesr¤rGr¾rÅÚ    generatedr’Z pretty_namerRrr5rÜrÞZsecs_lenZcols_lenÚtabÚpadÚsecròrórrererfrö~    s®
 
ÿÿ ÿÿÿ ÿ  $
 
 
 zCCompilerOpt.reportc     st|ttfƒst‚t|tƒr&|}}nd |¡}d |¡}tj |tj |¡¡}djtj     |¡| 
¡fžŽ}|r€tj  |¡r€|S|  d|¡|  | |¡¡}d|j‰‡fdd„|Dƒ}    d |    ¡}    t|d    ƒ.}
|
 t d
¡j|j|tj |¡|    d ¡W5QRX|S) NÚ.Ú__z
{0}.{2}{1}zwrap dispatch-able target -> z#define %sCPU_TARGET_csg|] }ˆ|‘qSrerera©Z target_joinrerfrÓý    sz-CCompilerOpt._wrap_target.<locals>.<listcomp>rŽraR            /**
             * AUTOGENERATED DON'T EDIT
             * Please make changes to the code generator              (distutils/ccompiler_opt.py)
             */
            #define {pfx}CPU_TARGET_MODE
            #define {pfx}CPU_TARGET_CURRENT {target_name}
            {target_defs}
            #include "{path}"
            )ráÚ target_namervÚ target_defs)rrrºrr€rurvÚbasenamerÚsplitextr€rùr£rgror†r r rrÚabspath) rcršÚ dispatch_srcÚtargetrÕZext_namerþZ    wrap_pathr§rÿr0rerýrfrÙë    s,
 
 
 
 
 
 
ôzCCompilerOpt._wrap_targetc    Cs„tj |¡}tj |¡dd}tj ||¡}| ||¡}zRt|ƒ@}| ¡ d¡}t    |ƒdkr€t
|dƒ|kr€W5QR£WdSW5QRXWnt k
r YnXtj tj  |¡dd| d|¡g}    |D]\}
t|
tƒrà|
} nd     d
d „|
Dƒ¡} | |
¡} d  d d „| Dƒ¡} |     d|j| | f¡qÌd |    ¡}    |rFd|j} nd} t|dƒ&}| t d¡j|j| |    |d¡W5QRXdS)Nrz.hz cache_hash:rrT)Úexist_okzgenerate dispatched config -> rücSsg|]}|‘qSrererÉrererfrÓ'
sz1CCompilerOpt._generate_config.<locals>.<listcomp>z&&cSsg|] }d|‘qS)zCHK(%s)rerarererfrÓ)
sz2    %sCPU_DISPATCH_EXPAND_(CB((%s), %s, __VA_ARGS__))rÞz(    %sCPU_DISPATCH_EXPAND_(CB(__VA_ARGS__))r raZ            // cache_hash:{cache_hash}
            /**
             * AUTOGENERATED DON'T EDIT
             * Please make changes to the code generator (distutils/ccompiler_opt.py)
             */
            #ifndef {pfx}CPU_DISPATCH_EXPAND_
                #define {pfx}CPU_DISPATCH_EXPAND_(X) X
            #endif
            #undef {pfx}CPU_DISPATCH_BASELINE_CALL
            #undef {pfx}CPU_DISPATCH_CALL
            #define {pfx}CPU_DISPATCH_BASELINE_CALL(CB, ...) \
            {baseline_calls}
            #define {pfx}CPU_DISPATCH_CALL(CHK, CB, ...) \
            {dispatch_calls}
            )rárärår÷F)rurvrrr€r÷r Úreadliner)r·Úintrjr    rr£rrr}rÌr†r rrr)rcršrr¾r¦Z config_pathr÷rZ    last_hashrårÅrþZ
req_detecträr0rererfrØ
sV  
 
 
 
ÿÿÿ
þ ïzCCompilerOpt._generate_config)rËrbN)NN)F)F)F)r{r|r}r~rzrÐrÑrÒrÓrÝrërörÙrØrerererfrÊœs
 
WS
m
&rÊcKs.t|f|Ž}tj |¡r | ¡s*| |¡|S)aÏ
    Create a new instance of 'CCompilerOpt' and generate the dispatch header
    which contains the #definitions and headers of platform-specific instruction-sets for
    the enabled CPU baseline and dispatch-able features.
 
    Parameters
    ----------
    compiler : CCompiler instance
    dispatch_hpath : str
        path of the dispatch header
 
    **kwargs: passed as-is to `CCompilerOpt(...)`
    Returns
    -------
    new instance of CCompilerOpt
    )rÊrurvrùrÐrë)r®Zdispatch_hpathr“rrererfÚnew_ccompiler_optO
s 
r)r~rrrÔrur
rärárZ NPY_CXX_FLAGSrrŠrûrîrrKrrÊrrerererfÚ<module>sL
ü/;    9hy6