MCPcopy Create free account
hub / github.com/numpy/numpy / CCompilerOpt

Class CCompilerOpt

numpy/distutils/ccompiler_opt.py:2213–2646  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2211 return has_baseline, final_targets, extra_flags
2212
2213class CCompilerOpt(_Config, _Distutils, _Cache, _CCompiler, _Feature, _Parse):
2214 """
2215 A helper class for `CCompiler` aims to provide extra build options
2216 to effectively control of compiler optimizations that are directly
2217 related to CPU features.
2218 """
2219 def __init__(self, ccompiler, cpu_baseline="min", cpu_dispatch="max", cache_path=None):
2220 _Config.__init__(self)
2221 _Distutils.__init__(self, ccompiler)
2222 _Cache.__init__(self, cache_path, self.dist_info(), cpu_baseline, cpu_dispatch)
2223 _CCompiler.__init__(self)
2224 _Feature.__init__(self)
2225 if not self.cc_noopt and self.cc_has_native:
2226 self.dist_log(
2227 "native flag is specified through environment variables. "
2228 "force cpu-baseline='native'"
2229 )
2230 cpu_baseline = "native"
2231 _Parse.__init__(self, cpu_baseline, cpu_dispatch)
2232 # keep the requested features untouched, need it later for report
2233 # and trace purposes
2234 self._requested_baseline = cpu_baseline
2235 self._requested_dispatch = cpu_dispatch
2236 # key is the dispatch-able source and value is a tuple
2237 # contains two items (has_baseline[boolean], dispatched-features[list])
2238 self.sources_status = getattr(self, "sources_status", {})
2239 # every instance should has a separate one
2240 self.cache_private.add("sources_status")
2241 # set it at the end to make sure the cache writing was done after init
2242 # this class
2243 self.hit_cache = hasattr(self, "hit_cache")
2244
2245 def is_cached(self):
2246 """
2247 Returns True if the class loaded from the cache file
2248 """
2249 return self.cache_infile and self.hit_cache
2250
2251 def cpu_baseline_flags(self):
2252 """
2253 Returns a list of final CPU baseline compiler flags
2254 """
2255 return self.parse_baseline_flags
2256
2257 def cpu_baseline_names(self):
2258 """
2259 return a list of final CPU baseline feature names
2260 """
2261 return self.parse_baseline_names
2262
2263 def cpu_dispatch_names(self):
2264 """
2265 return a list of final CPU dispatch feature names
2266 """
2267 return self.parse_dispatch_names
2268
2269 def try_dispatch(self, sources, src_dir=None, ccompiler=None, **kwargs):
2270 """

Callers 1

new_ccompiler_optFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected