class documentation

class _Feature:

Known subclasses: numpy.distutils.ccompiler_opt.CCompilerOpt

View In Hierarchy

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.
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 No summary
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 Undocumented
Instance Variable feature​_supported Undocumented
def __init__(self):

Undocumented

def feature_ahead(self, names):

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"]
def feature_c_preprocessor(self, feature_name, tabs=0):

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>
@_Cache.me
def feature_can_autovec(self, name):
check if the feature can be auto-vectorized by the compiler
def feature_detect(self, names):
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):

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

Parameters

names: str
CPU feature name in uppercase.
@_Cache.me
def feature_flags(self, names):
Return a list of CPU features flags sorted from the lowest to highest interest.
def feature_get_til(self, names, keyisfalse):
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):

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'}
def feature_implies_c(self, names):
same as feature_implies() but combining 'names'
def feature_is_exist(self, name):

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

Parameters

'name': str
feature name in uppercase.
@_Cache.me
def feature_is_supported(self, name, force_flags=None, macros=[]):

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.
def feature_names(self, names=None, force_flags=None, macros=[]):

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.
def feature_sorted(self, names, reverse=False):

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

@_Cache.me
def feature_test(self, name, force_flags=None, macros=[]):

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.
def feature_untied(self, names):

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"]
feature_is_cached: bool =

Undocumented

feature_min: set =

Undocumented

feature_supported =

Undocumented