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

use TARGET=ARMV8 when building OpenBLAS for aarch64/generic #793

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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:
options:
# see https://github.com/easybuilders/easybuild-easyblocks/pull/3492
include-easyblocks-from-commit: d06d9617d9bfb63d338b6879eab9da81c8a312d8
- OpenBLAS-0.3.23-GCC-12.3.0.eb:
options:
# see https://github.com/easybuilders/easybuild-easyblocks/pull/3492
include-easyblocks-from-commit: d06d9617d9bfb63d338b6879eab9da81c8a312d8
- OpenBLAS-0.3.24-GCC-13.2.0.eb:
options:
# see https://github.com/easybuilders/easybuild-easyblocks/pull/3492
include-easyblocks-from-commit: d06d9617d9bfb63d338b6879eab9da81c8a312d8
28 changes: 22 additions & 6 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,33 @@ def pre_configure_hook_openblas_optarch_generic(self, *args, **kwargs):
"""
Pre-configure hook for OpenBLAS: add DYNAMIC_ARCH=1 to build/test/install options when using --optarch=GENERIC
"""
# note: OpenBLAS easyblock was updated in https://github.com/easybuilders/easybuild-easyblocks/pull/3492
# to take care of this already, so at some point this hook can be removed...
if self.name == 'OpenBLAS':
if build_option('optarch') == OPTARCH_GENERIC:
dynamic_arch = 'DYNAMIC_ARCH=1'
for step in ('build', 'test', 'install'):
self.cfg.update(f'{step}opts', "DYNAMIC_ARCH=1")
if dynamic_arch not in self.cfg[f'{step}opts']:
self.cfg.update(f'{step}opts', dynamic_arch)

# 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:
cflags = os.getenv('CFLAGS').replace('-mcpu=generic', '-mtune=generic')
env.setvar('CFLAGS', cflags)
# 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
target_armv8 = 'TARGET=ARMV8'
for step in ('build', 'test', 'install'):
if target_armv8 not in self.cfg[f'{step}opts']:
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
mcpu_generic = '-mcpu=generic'
cflags = os.getenv('CFLAGS')
if mcpu_generic in cflags:
cflags = cflags.replace(mcpu_generic, '-mtune=generic')
self.log.info("Replaced -mcpu=generic with -mtune=generic in $CFLAGS")
env.setvar('CFLAGS', cflags)
else:
raise EasyBuildError("OpenBLAS-specific hook triggered for non-OpenBLAS easyconfig?!")

Expand Down