class documentation

A helper class for CCompiler aims to provide extra build options to effectively control of compiler optimizations that are directly related to CPU features.

Method __init__ Undocumented
Method cpu_baseline_flags Returns a list of final CPU baseline compiler flags
Method cpu_baseline_names return a list of final CPU baseline feature names
Method cpu_dispatch_names return a list of final CPU dispatch feature names
Method generate_dispatch_header Generate the dispatch header which contains the #definitions and headers for platform-specific instruction-sets for the enabled CPU baseline and dispatch-able features.
Method is_cached Returns True if the class loaded from the cache file
Method report Undocumented
Method try_dispatch 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.
Instance Variable hit_cache Undocumented
Instance Variable sources_status Undocumented
Method _generate_config Undocumented
Method _wrap_target Undocumented
Instance Variable _requested_baseline Undocumented
Instance Variable _requested_dispatch Undocumented

Inherited from _Config:

Method conf_features_partial 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...
Instance Variable conf_c_prefix The prefix of public C definitions. Default is "NPY_".
Instance Variable conf_c_prefix_ The prefix of internal C definitions. Default is "NPY__".
Instance Variable conf_cache_factors 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 ...
Instance Variable conf_cc_flags 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 ...
Instance Variable conf_check_path 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 ...
Instance Variable conf_features 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 ...
Instance Variable conf_min_features 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.
Instance Variable conf_nocache Set True to disable memory and file cache. Default is False.
Instance Variable conf_noopt 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.
Instance Variable conf_target_groups Extra tokens that can be reached from dispatch-able sources through the special mark @targets. Default is an empty dictionary.
Instance Variable conf_tmp_path The path of temporary directory. Default is auto-created temporary directory via tempfile.mkdtemp().

Inherited from _Distutils (via _Config):

Static Method dist_error Raise a compiler error
Static Method dist_fatal Raise a distutils error
Static Method dist_load_module Load a module from file, required by the abstract class '_Cache'.
Static Method dist_log Print a console message
Method dist_compile Wrap CCompiler.compile()
Method dist_info 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.
Method dist_test Return True if 'CCompiler.compile()' able to compile a source file with certain flags.
Static Method _dist_str Return a string to print by log and errors.
Static Method _dist_test_spawn Undocumented
Method _dist_test_spawn_paths Fix msvc SDK ENV path same as distutils do without it we get c1: fatal error C1356: unable to find mspdbcore.dll
Class Variable _dist_warn_regex Undocumented
Instance Variable _ccompiler Undocumented
Instance Variable _dist_info Undocumented

Inherited from _Cache (via _Config, _Distutils):

Static Method me A static method that can be treated as a decorator to dynamically cache certain methods.
Method __del__ Undocumented
Method cache_flush Force update the cache.
Method cache_hash Undocumented
Instance Variable cache_infile Utilized during initializing this class, to determine if the cache was able to loaded from the specified cache path in 'cache_path'.
Instance Variable cache_me Undocumented
Instance Variable cache_private Hold the attributes that need be skipped from "in-memory cache".
Class Variable _cache_ignore Undocumented
Instance Variable _cache_hash Undocumented
Instance Variable _cache_path Undocumented

Inherited from _CCompiler (via _Config, _Distutils, _Cache):

Method cc_normalize_flags Remove the conflicts that caused due gathering implied features flags.
Method cc_test_cexpr Same as the above but supports compile-time expressions.
Method cc_test_flags Returns True if the compiler supports 'flags'.
Instance Variable cc_flags Dictionary containing the initialized flags of _Config.conf_cc_flags
Instance Variable cc_has_debug True if the compiler has debug flags
Instance Variable cc_has_native True if the compiler has native flags
Instance Variable cc_is_cached Undocumented
Instance Variable cc_is_clang True if the compiler is Clang
Instance Variable cc_is_gcc True if the compiler is GNU or if the compiler is unknown
Instance Variable cc_is_icc True if the compiler is Intel compiler (unix like)
Instance Variable cc_is_iccw True if the compiler is Intel compiler (msvc like)
Instance Variable cc_is_nocc True if the compiler isn't supported directly, Note: that cause a fail-back to gcc
Instance Variable cc_march The target architecture name, or "unknown" if the architecture isn't supported
Instance Variable cc_name The compiler name, or "unknown" if the compiler isn't supported
Instance Variable cc_noopt True if the compiler has definition 'DISABLE_OPT*', or 'cc_on_noarch' is True
Instance Variable cc_on_aarch64 True when the target architecture is 64-bit Armv8-a+
Instance Variable cc_on_armhf True when the target architecture is 32-bit ARMv7+
Instance Variable cc_on_noarch True when the target architecture is unknown or not supported
Instance Variable cc_on_ppc64 True when the target architecture is 64-bit big-endian powerpc
Instance Variable cc_on_ppc64le True when the target architecture is 64-bit litle-endian powerpc
Instance Variable cc_on_s390x True when the target architecture is IBM/ZARCH on linux
Instance Variable cc_on_x64 True when the target architecture is 64-bit x86
Instance Variable cc_on_x86 True when the target architecture is 32-bit x86
Method _cc_normalize_unix Undocumented
Method _cc_normalize_win Undocumented
Class Variable _cc_normalize_arch_ver Undocumented
Class Variable _cc_normalize_unix_frgx Undocumented
Class Variable _cc_normalize_unix_krgx Undocumented
Class Variable _cc_normalize_unix_mrgx Undocumented
Class Variable _cc_normalize_win_frgx Undocumented
Class Variable _cc_normalize_win_mrgx Undocumented

Inherited from _Feature (via _Config, _Distutils, _Cache, _CCompiler):

Method feature_ahead Return list of features in 'names' after remove any implied features and keep the origins.
Method feature_c_preprocessor Generate C preprocessor definitions and include headers of a CPU feature.
Method feature_can_autovec check if the feature can be auto-vectorized by the compiler
Method feature_detect Return a list of CPU features that required to be detected sorted from the lowest to highest interest.
Method feature_extra_checks Return a list of supported extra checks after testing them against the compiler.
Method feature_flags Return a list of CPU features flags sorted from the lowest to highest interest.
Method feature_get_til 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.
Method feature_implies Return a set of CPU features that implied by 'names'
Method feature_implies_c same as feature_implies() but combining 'names'
Method feature_is_exist Returns True if a certain feature is exist and covered within _Config.conf_features.
Method feature_is_supported Check if a certain CPU feature is supported by the platform and compiler.
Method feature_names Returns a set of CPU feature names that supported by platform and the C compiler.
Method feature_sorted Sort a list of CPU features ordered by the lowest interest.
Method feature_test Test a certain CPU feature against the compiler through its own check file.
Method feature_untied same as 'feature_ahead()' but if both features implied each other and keep the highest interest.
Instance Variable feature_is_cached Undocumented
Instance Variable feature_min The minimum support of CPU features, according to the specified values in attribute _Config.conf_min_features.
Instance Variable feature_supported 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()

Inherited from _Parse (via _Config, _Distutils, _Cache, _CCompiler, _Feature):

Method parse_targets 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...
Instance Variable parse_baseline_flags Compiler flags of baseline features
Instance Variable parse_baseline_names Final CPU baseline's feature names(sorted from low to high)
Instance Variable parse_dispatch_names Final CPU dispatch-able feature names(sorted from low to high)
Instance Variable parse_is_cached Undocumented
Instance Variable parse_target_groups Dictionary containing initialized target groups that configured through class attribute conf_target_groups.
Method _parse_arg_features Undocumented
Method _parse_multi_target validate multi targets that defined between parentheses()
Method _parse_policy_autovec skip features that has no auto-vectorized support by compiler
Method _parse_policy_keepsort leave a notice that $keep_sort is on
Method _parse_policy_maxopt append the compiler optimization flags
Method _parse_policy_not_keepbase skip all baseline features
Method _parse_policy_not_keepsort sorted depend on the highest interest
Method _parse_policy_werror force warnings to treated as errors
Method _parse_target_tokens Undocumented
Method _parse_token_group validate group token
Method _parse_token_policy validate policy token
Class Variable _parse_regex_arg Undocumented
Class Variable _parse_regex_target Undocumented
Instance Variable _parse_policies Undocumented
def __init__(self, ccompiler, cpu_baseline='min', cpu_dispatch='max', cache_path=None): (source)
def cpu_baseline_flags(self): (source)

Returns a list of final CPU baseline compiler flags

def cpu_baseline_names(self): (source)

return a list of final CPU baseline feature names

def cpu_dispatch_names(self): (source)

return a list of final CPU dispatch feature names

def generate_dispatch_header(self, header_path): (source)

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.

def is_cached(self): (source)

Returns True if the class loaded from the cache file

def report(self, full=False): (source)

Undocumented

def try_dispatch(self, sources, src_dir=None, ccompiler=None, **kwargs): (source)

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.

See Also

parse_targets
Parsing the configuration statements of dispatch-able sources.
Parameters
sources:listMust be a list of dispatch-able sources file paths, and configuration statements must be declared inside each file.
src_dir:strPath of parent directory for the generated headers and wrapped sources. If None(default) the files will generated in-place.
ccompiler:CCompilerDistutils CCompiler instance to be used for compilation. If None (default), the provided instance during the initialization will be used instead.
**kwargs:anyArguments to pass on to the CCompiler.compile()
Returns
listgenerated object files
Raises
CompileErrorRaises by CCompiler.compile() on compiling failure.
DistutilsErrorSome errors during checking the sanity of configuration statements.
hit_cache = (source)

Undocumented

sources_status = (source)

Undocumented

def _generate_config(self, output_dir, dispatch_src, targets, has_baseline=False): (source)

Undocumented

def _wrap_target(self, output_dir, dispatch_src, target, nochange=False): (source)

Undocumented

_requested_baseline = (source)

Undocumented

_requested_dispatch = (source)

Undocumented