← Back
Editing: ccompiler_opt.cpython-311.pyc
� ���c � � � d Z ddlZddlZddlZddlZddlZddlZddlZg d�Z G d� d� � Z G d� d� � Z i Z G d� d � � Z G d � d� � Z G d� d � � Z G d� d� � Z G d� de e ee ee� � Zd� ZdS )a Provides 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.� N)z -std=c++11z-D__STDC_VERSION__=0z-fno-exceptionsz -fno-rttic � � e Zd ZdZdZdZdZdZej � ej � ej � e � � � � d� � Zi ZdZdZ e eddd � � � eddd� � � eddd � � � ed dd� � � eddd� � � �� � Z eddddddd�� � Z edvi d eddd�� � �d eddd� � � �d! ed"dd#� � � �d$ ed%d!d&� � � �d' ed(d$d)� � � �d* ed+d'd,� � � �d- ed.d*�/� � �d0 ed1d-d2d�3� � �d4 ed5d0d6� � � �d7 ed8d0d6� � � �d9 ed:d0�/� � �d; ed<d9�/� � �d= ed>d9�/� � �d? ed@dAddB�C� � �dD edEd?�/� � �dF edGdDdHdFd�I� � �dJ edKdFdLdJd�I� � �dM edNdDdOdMddP�Q� � �dR edSdMdTdR�U� � �dV edWdMdXdVd�I� � �dY edZd[d\dYd�I� � �d] edd^d_�`� � �da edd]d�b� � �dc ed"dad�b� � �dd ed%dcdde�C� � �df eddg�h� � �di eddfd�b� � �dj ed"did�b� � �dk eddl�h� � �dm eddk�/� � �dn ed"dm�/� � �do ed%dpd�b� � �dq ed(do�/� � �dr ed+do�/� � �ds ed.dq�/� � ��Zdt� Zdu� ZdS )w�_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 FN�checks�NPY_�NPY__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�SSE� zxmmintrin.h�SSE2)�interest�headers�implies� zemmintrin.h)r r r �SSE3� zpmmintrin.h�SSSE3� ztmmintrin.h�SSE41� zsmmintrin.h�POPCNT� zpopcntintrin.h�SSE42� )r r �AVX� zimmintrin.h)r r r �implies_detect�XOP� zx86intrin.h�FMA4� �F16C� �FMA3� �AVX2� �AVX512F� z FMA3 AVX2�AVX512F_REDUCE)r r r+ �extra_checks�AVX512CD� � AVX512_KNL�( zAVX512ER AVX512PF)r r �group�detectr+ � AVX512_KNM�) z)AVX5124FMAPS AVX5124VNNIW AVX512VPOPCNTDQ� AVX512_SKX�* zAVX512VL AVX512BW AVX512DQzAVX512BW_MASK AVX512DQ_MASK)r r r>