Skip to content

Commit

Permalink
use TARGET=ARMV8 when building OpenBLAS for aarch64/generic
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Oct 17, 2024
1 parent 8232a60 commit abde580
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 2024.10.17
# TARGET=ARMV8 must be used when building OpenBLAS for aarch64/generic,
# since otherwise "Illegal instruction" errors may happen in the driver part of OpenBLAS
# on systems that only support a minimal instruction set like Arm v8 (like Raspberry Pi SBCs);
# see also https://github.com/OpenMathLib/OpenBLAS/issues/4945
easyconfigs:
- OpenBLAS-0.3.21-GCC-12.2.0.eb
- OpenBLAS-0.3.23-GCC-12.3.0.eb
- OpenBLAS-0.3.24-GCC-13.2.0.eb
14 changes: 11 additions & 3 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,19 @@ def pre_configure_hook_openblas_optarch_generic(self, *args, **kwargs):
for step in ('build', 'test', 'install'):
self.cfg.update(f'{step}opts', "DYNAMIC_ARCH=1")

# use -mtune=generic rather than -mcpu=generic in $CFLAGS on aarch64,
# because -mcpu=generic implies a particular -march=armv* which clashes with those used by OpenBLAS
# when building with DYNAMIC_ARCH=1
if get_cpu_architecture() == AARCH64:
# when building for aarch64/generic, we also need to set TARGET=ARMV8 to make sure
# that the driver parts of OpenBLAS are compiled generically;
# see also https://github.com/OpenMathLib/OpenBLAS/issues/4945
for step in ('build', 'test', 'install'):
self.cfg.update(f'{step}opts', "TARGET=ARMV8")

# use -mtune=generic rather than -mcpu=generic in $CFLAGS for aarch64/generic,
# because -mcpu=generic implies a particular -march=armv* which clashes with those used by OpenBLAS
# when building with DYNAMIC_ARCH=1
cflags = os.getenv('CFLAGS').replace('-mcpu=generic', '-mtune=generic')
self.log.info("Replaced -mcpu=generic with -mtune=generic in $CFLAGS")
self.log.info("Updating $CFLAGS to: %s", cflags)
env.setvar('CFLAGS', cflags)
else:
raise EasyBuildError("OpenBLAS-specific hook triggered for non-OpenBLAS easyconfig?!")
Expand Down

0 comments on commit abde580

Please sign in to comment.