Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(setup): add -march option #86

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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':
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down