Skip to content

Commit

Permalink
environment variables in setup.py for AVX512 and FFP_CONTRACT_OFF to …
Browse files Browse the repository at this point in the history
…avoid clang issue
  • Loading branch information
hannorein committed Jul 20, 2023
1 parent 5ed7a59 commit 1df008f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
vars = sysconfig.get_config_vars()
vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '-shared')
extra_link_args=['-Wl,-install_name,@rpath/librebound'+suffix]

# Default compile args
extra_compile_args=['-fstrict-aliasing', '-O3','-std=c99','-Wno-unknown-pragmas', ghash_arg, '-DLIBREBOUND', '-D_GNU_SOURCE', '-fPIC']

# Option to disable FMA in CLANG.
FFP_CONTRACT_OFF = os.environ.get("FFP_CONTRACT_OFF", None)
if FFP_CONTRACT_OFF:
extra_compile_args.append('-ffp-contract=off')

# Option to enable AVX512 enabled integrators (WHFast512).
AVX512 = os.environ.get("AVX512", None)
if AVX512:
extra_compile_args.append('-march=native')
extra_compile_args.append('-DAVX512')

libreboundmodule = Extension('librebound',
sources = [ 'src/rebound.c',
Expand Down Expand Up @@ -57,11 +71,8 @@
],
include_dirs = ['src'],
define_macros=[ ('LIBREBOUND', None) ],
# Uncomment the following line for the non-AVX512 version of REBOUND
extra_compile_args=['-fstrict-aliasing', '-O3','-std=c99','-Wno-unknown-pragmas', ghash_arg, '-DLIBREBOUND', '-D_GNU_SOURCE', '-fPIC'],
# Uncomment the following line to enable AVX512
# extra_compile_args=['-fstrict-aliasing', '-O3','-std=c99','-Wno-unknown-pragmas', ghash_arg, '-DLIBREBOUND', '-D_GNU_SOURCE', '-fPIC', '-march=native', '-DAVX512'],
extra_link_args=extra_link_args,
extra_compile_args=extra_compile_args,
)

here = os.path.abspath(os.path.dirname(__file__))
Expand Down

0 comments on commit 1df008f

Please sign in to comment.