Skip to content

Commit

Permalink
add pre_single_extension_scipy hook to replace -mcpu=native with -mar…
Browse files Browse the repository at this point in the history
…ch=armv8.4-a when building scipy 1.10.1 on aarch64/neoverse_v1
  • Loading branch information
boegel committed Jan 12, 2024
1 parent f6ee972 commit b55efbf
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,6 @@ def pre_single_extension_hook(ext, *args, **kwargs):
PRE_SINGLE_EXTENSION_HOOKS[ext.name](ext, *args, **kwargs)


def pre_single_extension_testthat(ext, *args, **kwargs):
"""
Pre-extension hook for testthat R package, to fix build on top of recent glibc.
"""
if ext.name == 'testthat' and LooseVersion(ext.version) < LooseVersion('3.1.0'):
# use constant value instead of SIGSTKSZ for stack size,
# cfr. https://github.com/r-lib/testthat/issues/1373 + https://github.com/r-lib/testthat/pull/1403
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' inst/include/testthat/vendor/catch.h && "


def pre_single_extension_isoband(ext, *args, **kwargs):
"""
Pre-extension hook for isoband R package, to fix build on top of recent glibc.
Expand All @@ -404,6 +394,33 @@ def pre_single_extension_isoband(ext, *args, **kwargs):
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' src/testthat/vendor/catch.h && "


def pre_single_extension_scipy(ext, *args, **kwargs):
"""
Pre-extension hook for scipy, to change -march=native to -march=armv8.4-a for scipy 1.10.x when buidling for
aarch64/neoverse_v1 CPU target.
"""
cpu_target = get_eessi_envvar('EESSI_SOFTWARE_SUBDIR')
if ext.name == 'scipy' and ext.version == '1.10.1' and cpu_target == CPU_TARGET_NEOVERSE_V1:
cflags = os.getenv('CFLAGS')
if '-mcpu=native' in cflags:
cflags = cflags.replace('-mcpu=native', '-march=armv8.4-a')
ext.cfg.update('configopts', ' '.join([
"-Dc_args='%s'" % cflags,
"-Dcpp_args='%s'" % cflags,
"-Dfortran_args='%s'" % cflags,
]))


def pre_single_extension_testthat(ext, *args, **kwargs):
"""
Pre-extension hook for testthat R package, to fix build on top of recent glibc.
"""
if ext.name == 'testthat' and LooseVersion(ext.version) < LooseVersion('3.1.0'):
# use constant value instead of SIGSTKSZ for stack size,
# cfr. https://github.com/r-lib/testthat/issues/1373 + https://github.com/r-lib/testthat/pull/1403
ext.cfg['preinstallopts'] = "sed -i 's/SIGSTKSZ/32768/g' inst/include/testthat/vendor/catch.h && "


def post_sanitycheck_hook(self, *args, **kwargs):
"""Main post-sanity-check hook: trigger custom functions based on software name."""
if self.name in POST_SANITYCHECK_HOOKS:
Expand Down Expand Up @@ -531,6 +548,7 @@ def inject_gpu_property(ec):

PRE_SINGLE_EXTENSION_HOOKS = {
'isoband': pre_single_extension_isoband,
'scipy': pre_single_extension_scipy,
'testthat': pre_single_extension_testthat,
}

Expand Down

0 comments on commit b55efbf

Please sign in to comment.