class documentation

class _Config:

Known subclasses: numpy.distutils.ccompiler_opt.CCompilerOpt

View In Hierarchy

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:
$ "@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
Method __init__ Undocumented
Method conf​_features​_partial No summary
Class Variable conf​_c​_prefix Undocumented
Class Variable conf​_c​_prefix​_ Undocumented
Class Variable conf​_cc​_flags Undocumented
Class Variable conf​_check​_path Undocumented
Class Variable conf​_features Undocumented
Class Variable conf​_min​_features Undocumented
Class Variable conf​_nocache Undocumented
Class Variable conf​_noopt Undocumented
Class Variable conf​_target​_groups Undocumented
Instance Variable conf​_cache​_factors Undocumented
Instance Variable conf​_tmp​_path Undocumented
def __init__(self):

Undocumented

def conf_features_partial(self):
Return 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'.
conf_c_prefix: str =

Undocumented

conf_c_prefix_: str =

Undocumented

conf_cc_flags =

Undocumented

conf_check_path =

Undocumented

conf_features =

Undocumented

conf_min_features =

Undocumented

conf_nocache: bool =

Undocumented

conf_noopt: bool =

Undocumented

conf_target_groups: dict =

Undocumented

conf_cache_factors =

Undocumented

conf_tmp_path =

Undocumented