From abde580bdadb92d3fa1d1e6e2a7a3b0db4ca589a Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 17 Oct 2024 19:41:45 +0200 Subject: [PATCH 1/2] use TARGET=ARMV8 when building OpenBLAS for aarch64/generic --- .../20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml | 9 +++++++++ eb_hooks.py | 14 +++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml diff --git a/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml b/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml new file mode 100644 index 0000000000..4ba7983da6 --- /dev/null +++ b/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml @@ -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 diff --git a/eb_hooks.py b/eb_hooks.py index 33bdf53c52..ba6f9ad5da 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -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?!") From 188938ad2204f596667d26a673214605c7541ddb Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 17 Oct 2024 21:29:48 +0200 Subject: [PATCH 2/2] use updated OpenBLAS easyblock that sets DYNAMIC_ARCH=1 for generic builds + uses TARGET=ARMV8 for aarch64/generic --- ...1017-eb-4.9.4-OpenBLAS-aarch64-generic.yml | 15 +++++++++++--- eb_hooks.py | 20 +++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml b/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml index 4ba7983da6..d6d8f70143 100644 --- a/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml +++ b/easystacks/software.eessi.io/2023.06/rebuilds/20241017-eb-4.9.4-OpenBLAS-aarch64-generic.yml @@ -4,6 +4,15 @@ # 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 + - 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 diff --git a/eb_hooks.py b/eb_hooks.py index ba6f9ad5da..a3ae6bbc05 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -486,25 +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) 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 + target_armv8 = 'TARGET=ARMV8' for step in ('build', 'test', 'install'): - self.cfg.update(f'{step}opts', "TARGET=ARMV8") + 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 - 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) + 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?!")