From f7241ef5083a265c41c1789163a3b4c2c0e25b64 Mon Sep 17 00:00:00 2001 From: Rick Nitsche Date: Wed, 9 Sep 2020 12:02:17 -0700 Subject: [PATCH] build(setup): add -march option Closes #85 --- setup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 15a880c7..cc70dfc7 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ VERSION = VERSION + ".dev%d" % VERSION_DEV -COMPILE_FLAGS = ['-O3', '-ffast-math', '-march=native', '-std=c99'] +COMPILE_FLAGS = ['-O3', '-ffast-math', '-std=c99'] # Cython breaks strict aliasing rules. COMPILE_FLAGS += ['-fno-strict-aliasing'] COMPILE_FLAGS += ['-fPIC'] @@ -40,6 +40,7 @@ H5PLUGINS_DEFAULT = '/usr/local/hdf5/lib/plugin' +MARCH_DEFAULT = 'native' # OSX's clang compliler does not support OpenMP. if sys.platform == 'darwin': @@ -223,13 +224,16 @@ def run(self): class build_ext(build_ext_): user_options = build_ext_.user_options + [ ('omp=', None, "Whether to compile with OpenMP threading. Default" - " on current system is %s." % str(OMP_DEFAULT)) + " on current system is %s." % str(OMP_DEFAULT)), + ('march=', None, + 'Generate instructions for a specific machine type. Default is %s.' % MARCH_DEFAULT), ] boolean_options = build_ext_.boolean_options + ['omp'] def initialize_options(self): build_ext_.initialize_options(self) self.omp = OMP_DEFAULT + self.march = MARCH_DEFAULT def finalize_options(self): # For some reason this gets run twice. Careful to print messages and @@ -269,7 +273,7 @@ def build_extensions(self): compileflags = COMPILE_FLAGS_MSVC else: openmpflag = '-fopenmp' - compileflags = COMPILE_FLAGS + compileflags = COMPILE_FLAGS + ['-march=%s' % self.march] for e in self.extensions: e.extra_compile_args = list(set(e.extra_compile_args).union(compileflags)) if openmpflag not in e.extra_compile_args: