From 0b62974160d99c44e77366cac4bd2e8a1983505b Mon Sep 17 00:00:00 2001 From: Kevin Pedretti Date: Mon, 11 Oct 2021 16:55:45 -0600 Subject: [PATCH] openblas: fix build on riscv64 (#26565) OpenBLAS now has support for the riscv64 architecture. This commit extends the spack openblas package.py to handle building on riscv64. --- var/spack/repos/builtin/packages/openblas/package.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py index 1785b5105d..0c267eb931 100644 --- a/var/spack/repos/builtin/packages/openblas/package.py +++ b/var/spack/repos/builtin/packages/openblas/package.py @@ -191,7 +191,7 @@ def _microarch_target_args(self): # List of available architectures, and possible aliases openblas_arch = set(['alpha', 'arm', 'ia64', 'mips', 'mips64', - 'power', 'sparc', 'zarch']) + 'power', 'riscv64', 'sparc', 'zarch']) openblas_arch_map = { 'amd64': 'x86_64', 'powerpc64': 'power', @@ -220,7 +220,7 @@ def _microarch_target_args(self): arch_name = openblas_arch_map.get(arch_name, arch_name) args.append('ARCH=' + arch_name) - if microarch.vendor == 'generic': + if microarch.vendor == 'generic' and microarch.name != 'riscv64': # User requested a generic platform, or we couldn't find a good # match for the requested one. Allow OpenBLAS to determine # an optimized kernel at run time, including older CPUs, while @@ -238,6 +238,14 @@ def _microarch_target_args(self): if microarch.name == "skylake": # Special case for disabling avx512 instructions args.append('NO_AVX512=1') + + elif microarch.name == 'riscv64': + # Special case for renaming the generic riscv64 uarch to the + # corresponding OpenBLAS target. riscv64 does not yet support + # DYNAMIC_ARCH or TARGET=GENERIC. Once it does, this special + # case can go away. + args.append('TARGET=' + "RISCV64_GENERIC") + else: args.append('TARGET=' + microarch.name.upper())