class documentation

A helper class for CCompilerOpt that managing CPU features.

Method __init__ Undocumented
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()
def __init__(self): (source)

Undocumented

def feature_ahead(self, names): (source)

Return list of features in 'names' after remove any implied features and keep the origins.

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"]
Parameters
namesUndocumented
'names':sequencesequence of CPU feature names in uppercase.
Returns
list of CPU features sorted as-is 'names'
def feature_c_preprocessor(self, feature_name, tabs=0): (source)

Generate C preprocessor definitions and include headers of a CPU feature.

Examples

>>> self.feature_c_preprocessor("SSE3")
/** SSE3 **/
#define NPY_HAVE_SSE3 1
#include <pmmintrin.h>
Parameters
feature_nameUndocumented
tabsUndocumented
'feature_name':strCPU feature name in uppercase.
'tabs':intif > 0, align the generated strings to the right depend on number of tabs.
Returns
str, generated C preprocessor
@_Cache.me
def feature_can_autovec(self, name): (source)

check if the feature can be auto-vectorized by the compiler

def feature_detect(self, names): (source)

Return a list of CPU features that required to be detected sorted from the lowest to highest interest.

@_Cache.me
def feature_extra_checks(self, name): (source)

Return a list of supported extra checks after testing them against the compiler.

Parameters
nameUndocumented
names:strCPU feature name in uppercase.
@_Cache.me
def feature_flags(self, names): (source)

Return a list of CPU features flags sorted from the lowest to highest interest.

def feature_get_til(self, names, keyisfalse): (source)

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.

def feature_implies(self, names, keep_origins=False): (source)

Return a set of CPU features that implied by 'names'

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'}
Parameters
names:str or sequence of strCPU feature name(s) in uppercase.
keep_origins:boolif False(default) then the returned set will not contain any features from 'names'. This case happens only when two features imply each other.
def feature_implies_c(self, names): (source)

same as feature_implies() but combining 'names'

def feature_is_exist(self, name): (source)

Returns True if a certain feature is exist and covered within _Config.conf_features.

Parameters
nameUndocumented
'name':strfeature name in uppercase.
@_Cache.me
def feature_is_supported(self, name, force_flags=None, macros=[]): (source)

Check if a certain CPU feature is supported by the platform and compiler.

Parameters
name:strCPU feature name in uppercase.
force_flags:list or None, optionalIf None(default), default compiler flags for every CPU feature will be used during test.
macros:list of tuples, optionalA list of C macro definitions.
def feature_names(self, names=None, force_flags=None, macros=[]): (source)

Returns a set of CPU feature names that supported by platform and the C compiler.

Parameters
names:sequence or None, optionalSpecify 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, optionalIf None(default), default compiler flags for every CPU feature will be used during the test.
macros:list of tuples, optionalA list of C macro definitions.
def feature_sorted(self, names, reverse=False): (source)

Sort a list of CPU features ordered by the lowest interest.

Parameters
namesUndocumented
reverseUndocumented
'names':sequencesequence of supported feature names in uppercase.
'reverse':bool, optionalIf true, the sorted features is reversed. (highest interest)
Returns
list, sorted CPU features
@_Cache.me
def feature_test(self, name, force_flags=None, macros=[]): (source)

Test a certain CPU feature against the compiler through its own check file.

Parameters
name:strSupported CPU feature name.
force_flags:list or None, optionalIf None(default), the returned flags from feature_flags() will be used.
macros:list of tuples, optionalA list of C macro definitions.
def feature_untied(self, names): (source)

same as 'feature_ahead()' but if both features implied each other and keep the highest interest.

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"]
Parameters
namesUndocumented
'names':sequencesequence of CPU feature names in uppercase.
Returns
list of CPU features sorted as-is 'names'
feature_is_cached: bool = (source)

Undocumented

feature_min: set = (source)

The minimum support of CPU features, according to the specified values in attribute _Config.conf_min_features.

feature_supported: dict = (source)

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()