Skip to content

Commit

Permalink
use DYNAMIC_ARCH=1 when building OpenBLAS with --optarch=GENERIC
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Oct 17, 2024
1 parent d26d7b7 commit d06d961
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions easybuild/easyblocks/o/openblas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
from easybuild.tools import LooseVersion
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.systemtools import POWER, get_cpu_architecture, get_shared_lib_ext
from easybuild.tools.build_log import EasyBuildError, print_warning
from easybuild.tools.config import ERROR
from easybuild.tools.config import ERROR, build_option
from easybuild.tools.run import run_cmd, check_log_for_errors
from easybuild.tools.systemtools import AARCH64, POWER, get_cpu_architecture, get_shared_lib_ext
from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC
import easybuild.tools.environment as env

LAPACK_TEST_TARGET = 'lapack-test'
TARGET = 'TARGET'
Expand Down Expand Up @@ -43,9 +45,9 @@ def configure_step(self):
'BINARY': '64',
'CC': os.getenv('CC'),
'FC': os.getenv('FC'),
'MAKE_NB_JOBS': '-1', # Disable internal parallelism to let EB choose
'USE_OPENMP': '1',
'USE_THREAD': '1',
'MAKE_NB_JOBS': '-1', # Disable internal parallelism to let EB choose
}

if '%s=' % TARGET in self.cfg['buildopts']:
Expand All @@ -59,6 +61,23 @@ def configure_step(self):
print_warning("OpenBLAS 0.3.5 and lower have known issues on POWER systems")
default_opts[TARGET] = 'POWER8'

# special care must be taken when performing a generic build of OpenBLAS
if build_option('optarch') == OPTARCH_GENERIC:
default_opts['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
default_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")
env.setvar('CFLAGS', cflags)

for key in sorted(default_opts.keys()):
for opts_key in ['buildopts', 'testopts', 'installopts']:
if '%s=' % key not in self.cfg[opts_key]:
Expand Down

0 comments on commit d06d961

Please sign in to comment.