summaryrefslogtreecommitdiff
path: root/numpy/distutils/command/build.py
diff options
context:
space:
mode:
authorSayed Adel <seiko@imavr.com>2020-06-13 18:15:41 +0200
committerSayed Adel <seiko@imavr.com>2020-06-15 22:49:27 +0200
commit4c97add06371bf80f3bc02e0cfb0ee83737b909c (patch)
treeff6de3901d33d82d11b474b081e5d817850884b2 /numpy/distutils/command/build.py
parent8ccd582937a182391f49f412908fecf1770787d7 (diff)
downloadnumpy-4c97add06371bf80f3bc02e0cfb0ee83737b909c.tar.gz
ENH: [3/7] enable multi-platform SIMD compiler optimizations
- Put `CCompilerOpt` in action through add two command line arguments that passed directly to `CCompilerOpt`'s parameters which explained as follows: * `--cpu-baseline` minimal set of required optimizations, default is 'min' which provides the minimum CPU features that can safely run on a wide range of users platforms. * `--cpu-dispatch` dispatched set of additional optimizations, default is 'max-xop-fma4' which enables all CPU features, except for AMD legacy features. the new arguments can be reached from `build`, `build_clib`, `build_ext`, if `build_clib` or `build_ext` are not specified by the user the arguments of `build` will be used, which also hold the default values. - Activate the new compiler dispatcher that comes with `CCompilerOpt`, through adding a hock inside `build_clib` and `build_ext` that works as a filter taking any C source files ends with `.dispatch.c` and pass it directly to `CCompilerOpt` and then take returned objects and linked to the final C lib. - Add a third command-line argument `--disable-optimization` which explicitly disable the whole new infrastructure, also It adds a new compiler definition called `NPY_DISABLE_OPTIMIZATION`. when `--disable-optimization` is enabled the dispatch-able sources that end with `.dispatch.c` will be treated as a normal C sources, also due to this disabling any C headers that generated by `CCompilerOpt` must guard it with `NPY_DISABLE_OPTIMIZATION`, otherwise, it will definitely break the build. - New auto-generated C header located at `core/include/numpy/_cpu_dispatch.h`, the new header contains all definitions and headers of CPU features that enabled according to specified configuration in `--cpu-baseline` and `--cpu-dispatch`.
Diffstat (limited to 'numpy/distutils/command/build.py')
-rw-r--r--numpy/distutils/command/build.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/distutils/command/build.py b/numpy/distutils/command/build.py
index a156a7c6e..60ba4c917 100644
--- a/numpy/distutils/command/build.py
+++ b/numpy/distutils/command/build.py
@@ -16,6 +16,12 @@ class build(old_build):
"specify the Fortran compiler type"),
('warn-error', None,
"turn all warnings into errors (-Werror)"),
+ ('cpu-baseline=', None,
+ "specify a list of enabled baseline CPU optimizations"),
+ ('cpu-dispatch=', None,
+ "specify a list of dispatched CPU optimizations"),
+ ('disable-optimization', None,
+ "disable CPU optimized code(dispatch,simd,fast...)"),
]
help_options = old_build.help_options + [
@@ -27,6 +33,9 @@ class build(old_build):
old_build.initialize_options(self)
self.fcompiler = None
self.warn_error = False
+ self.cpu_baseline = "min"
+ self.cpu_dispatch = "max -xop -fma4" # drop AMD legacy features by default
+ self.disable_optimization = False
def finalize_options(self):
build_scripts = self.build_scripts