diff options
author | Adrien Bernede <51493078+adrienbernede@users.noreply.github.com> | 2024-04-03 00:03:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 15:03:07 -0700 |
commit | 92b1c8f76321354fe278f3889768eb1b24787919 (patch) | |
tree | 04854ba48220bdf0ac3f01f19efd0d01bc587215 /lib | |
parent | 2b29ecd9b6c5cb6371a63bf87ef813d31c235947 (diff) | |
download | spack-92b1c8f76321354fe278f3889768eb1b24787919.tar.gz spack-92b1c8f76321354fe278f3889768eb1b24787919.tar.bz2 spack-92b1c8f76321354fe278f3889768eb1b24787919.tar.xz spack-92b1c8f76321354fe278f3889768eb1b24787919.zip |
RADIUSS packages update (Starting over #39613) (#41375)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/cached_cmake.py | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index ca9eae52b4..e142d76827 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections.abc import os +import re from typing import Tuple import llnl.util.filesystem as fs @@ -15,6 +16,12 @@ import spack.builder from .cmake import CMakeBuilder, CMakePackage +def spec_uses_toolchain(spec): + gcc_toolchain_regex = re.compile(".*gcc-toolchain.*") + using_toolchain = list(filter(gcc_toolchain_regex.match, spec.compiler_flags["cxxflags"])) + return using_toolchain + + def cmake_cache_path(name, value, comment="", force=False): """Generate a string for a cmake cache variable""" force_str = " FORCE" if force else "" @@ -132,6 +139,11 @@ class CachedCMakeBuilder(CMakeBuilder): "endif()\n", ] + # We defined hipcc as top-level compiler for packages when +rocm. + # This avoid problems coming from rocm flags being applied to another compiler. + if "+rocm" in spec: + entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", self.spec["hip"].hipcc)) + flags = spec.compiler_flags # use global spack compiler flags @@ -213,7 +225,7 @@ class CachedCMakeBuilder(CMakeBuilder): else: # starting with cmake 3.10, FindMPI expects MPIEXEC_EXECUTABLE # vs the older versions which expect MPIEXEC - if self.pkg.spec["cmake"].satisfies("@3.10:"): + if spec["cmake"].satisfies("@3.10:"): entries.append(cmake_cache_path("MPIEXEC_EXECUTABLE", mpiexec)) else: entries.append(cmake_cache_path("MPIEXEC", mpiexec)) @@ -248,12 +260,17 @@ class CachedCMakeBuilder(CMakeBuilder): # Include the deprecated CUDA_TOOLKIT_ROOT_DIR for supporting BLT packages entries.append(cmake_cache_path("CUDA_TOOLKIT_ROOT_DIR", cudatoolkitdir)) - archs = spec.variants["cuda_arch"].value - if archs[0] != "none": - arch_str = ";".join(archs) - entries.append( - cmake_cache_string("CMAKE_CUDA_ARCHITECTURES", "{0}".format(arch_str)) - ) + # CUDA_FLAGS + cuda_flags = [] + + if not spec.satisfies("cuda_arch=none"): + cuda_archs = ";".join(spec.variants["cuda_arch"].value) + entries.append(cmake_cache_string("CMAKE_CUDA_ARCHITECTURES", cuda_archs)) + + if spec_uses_toolchain(spec): + cuda_flags.append("-Xcompiler {}".format(spec_uses_toolchain(spec)[0])) + + entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS", " ".join(cuda_flags))) if "+rocm" in spec: entries.append("#------------------{0}".format("-" * 30)) @@ -262,9 +279,6 @@ class CachedCMakeBuilder(CMakeBuilder): # Explicitly setting HIP_ROOT_DIR may be a patch that is no longer necessary entries.append(cmake_cache_path("HIP_ROOT_DIR", "{0}".format(spec["hip"].prefix))) - entries.append( - cmake_cache_path("HIP_CXX_COMPILER", "{0}".format(self.spec["hip"].hipcc)) - ) llvm_bin = spec["llvm-amdgpu"].prefix.bin llvm_prefix = spec["llvm-amdgpu"].prefix # Some ROCm systems seem to point to /<path>/rocm-<ver>/ and @@ -277,11 +291,9 @@ class CachedCMakeBuilder(CMakeBuilder): archs = self.spec.variants["amdgpu_target"].value if archs[0] != "none": arch_str = ";".join(archs) - entries.append( - cmake_cache_string("CMAKE_HIP_ARCHITECTURES", "{0}".format(arch_str)) - ) - entries.append(cmake_cache_string("AMDGPU_TARGETS", "{0}".format(arch_str))) - entries.append(cmake_cache_string("GPU_TARGETS", "{0}".format(arch_str))) + entries.append(cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str)) + entries.append(cmake_cache_string("AMDGPU_TARGETS", arch_str)) + entries.append(cmake_cache_string("GPU_TARGETS", arch_str)) return entries |