class documentation

class _Parse:

Known subclasses: numpy.distutils.ccompiler_opt.CCompilerOpt

View In Hierarchy

A helper class that parsing main arguments of CCompilerOpt, also parsing configuration statements in dispatch-able sources.

Parameters

cpu_baseline: str or None
minimal set of required CPU features or special options.
cpu_dispatch: str or None
dispatched set of additional CPU features or special options.
Special options can be:
  • MIN: Enables the minimum CPU features that utilized via _Config.conf_min_features
  • MAX: Enables all supported CPU features by the Compiler and platform.
  • NATIVE: Enables all CPU features that supported by the current machine.
  • NONE: Enables nothing
  • Operand +/-: remove or add features, useful with options MAX, MIN and NATIVE.
    NOTE: operand + is only added for nominal reason.
NOTES:
  • Case-insensitive among all CPU features and special options.
  • Comma or space can be used as a separator.
  • If the CPU feature is not supported by the user platform or compiler, it will be skipped rather than raising a fatal error.
  • Any specified CPU features to 'cpu_dispatch' will be skipped if its part of CPU baseline features
  • 'cpu_baseline' force enables implied features.

Attributes

parse_baseline_names : list
Final CPU baseline's feature names(sorted from low to high)
parse_baseline_flags : list
Compiler flags of baseline features
parse_dispatch_names : list
Final CPU dispatch-able feature names(sorted from low to high)
parse_target_groups : dict

Dictionary containing initialized target groups that configured through class attribute conf_target_groups.

The key is represent the group name and value is a tuple contains three items :

  • bool, True if group has the 'baseline' option.
  • list, list of CPU features.
  • list, list of extra compiler flags.
Method __init__ Undocumented
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
Method parse​_targets No summary
Class Variable ​_parse​_regex​_arg Undocumented
Class Variable ​_parse​_regex​_target Undocumented
Instance Variable ​_parse​_policies Undocumented
Instance Variable parse​_baseline​_flags Undocumented
Instance Variable parse​_baseline​_names Undocumented
Instance Variable parse​_dispatch​_names Undocumented
Instance Variable parse​_is​_cached Undocumented
Instance Variable parse​_target​_groups Undocumented
def __init__(self, cpu_baseline, cpu_dispatch):

Undocumented

def _parse_arg_features(self, arg_name, req_features):

Undocumented

def _parse_multi_target(self, targets):
validate multi targets that defined between parentheses()
def _parse_policy_autovec(self, has_baseline, final_targets, extra_flags):
skip features that has no auto-vectorized support by compiler
def _parse_policy_keepsort(self, has_baseline, final_targets, extra_flags):
leave a notice that $keep_sort is on
def _parse_policy_maxopt(self, has_baseline, final_targets, extra_flags):
append the compiler optimization flags
def _parse_policy_not_keepbase(self, has_baseline, final_targets, extra_flags):
skip all baseline features
def _parse_policy_not_keepsort(self, has_baseline, final_targets, extra_flags):
sorted depend on the highest interest
def _parse_policy_werror(self, has_baseline, final_targets, extra_flags):
force warnings to treated as errors
def _parse_target_tokens(self, tokens):

Undocumented

def _parse_token_group(self, token, has_baseline, final_targets, extra_flags):
validate group token
def _parse_token_policy(self, token):
validate policy token
def parse_targets(self, source):

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.

Configuration statements are sort of keywords representing CPU features names, group of statements and policies, combined together to determine the required optimization.

Parameters

source: str
the path of C source file.

Returns

  • bool, True if group has the 'baseline' option
  • list, list of CPU features
  • list, list of extra compiler flags
_parse_regex_arg =

Undocumented

_parse_regex_target =

Undocumented

_parse_policies =

Undocumented

parse_baseline_flags =

Undocumented

parse_baseline_names =

Undocumented

parse_dispatch_names =

Undocumented

parse_is_cached: bool =

Undocumented

parse_target_groups: dict =

Undocumented