From 9dada76d3442cf532d05712819d11938915c6ba9 Mon Sep 17 00:00:00 2001 From: Adrien Bernede <51493078+adrienbernede@users.noreply.github.com> Date: Wed, 19 Mar 2025 07:36:52 +0100 Subject: [PATCH] Update hip support in radiuss packages leveraging blt@0.7.0 (#49488) Co-authored-by: Chris White Co-authored-by: Massimiliano Culpo --- lib/spack/spack/build_systems/cached_cmake.py | 29 ++++++++++++------- .../repos/builtin/packages/blt/package.py | 1 + .../repos/builtin/packages/care/package.py | 2 +- .../repos/builtin/packages/chai/package.py | 2 +- .../builtin/packages/raja-perf/package.py | 2 +- .../repos/builtin/packages/raja/package.py | 2 +- .../repos/builtin/packages/umpire/package.py | 2 +- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index eb9bfb1d511..c9965bbc144 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -278,17 +278,24 @@ def initconfig_hardware_entries(self): entries.append("# ROCm") entries.append("#------------------{0}\n".format("-" * 30)) - # 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))) - llvm_bin = spec["llvm-amdgpu"].prefix.bin - llvm_prefix = spec["llvm-amdgpu"].prefix - # Some ROCm systems seem to point to //rocm-/ and - # others point to //rocm-/llvm - if os.path.basename(os.path.normpath(llvm_prefix)) != "llvm": - llvm_bin = os.path.join(llvm_prefix, "llvm/bin/") - entries.append( - cmake_cache_filepath("CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "clang++")) - ) + if spec.satisfies("^blt@0.7:"): + rocm_root = os.path.dirname(spec["llvm-amdgpu"].prefix) + entries.append(cmake_cache_path("ROCM_PATH", rocm_root)) + else: + # 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))) + llvm_bin = spec["llvm-amdgpu"].prefix.bin + llvm_prefix = spec["llvm-amdgpu"].prefix + # Some ROCm systems seem to point to //rocm-/ and + # others point to //rocm-/llvm + if os.path.basename(os.path.normpath(llvm_prefix)) != "llvm": + llvm_bin = os.path.join(llvm_prefix, "llvm/bin/") + entries.append( + cmake_cache_filepath( + "CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "amdclang++") + ) + ) + archs = self.spec.variants["amdgpu_target"].value if archs[0] != "none": arch_str = ";".join(archs) diff --git a/var/spack/repos/builtin/packages/blt/package.py b/var/spack/repos/builtin/packages/blt/package.py index 358ae60f7cc..ce055c4959a 100644 --- a/var/spack/repos/builtin/packages/blt/package.py +++ b/var/spack/repos/builtin/packages/blt/package.py @@ -72,6 +72,7 @@ class Blt(Package): # if you export targets this could cause problems in downstream # projects if not handled properly. More info here: # https://llnl-blt.readthedocs.io/en/develop/tutorial/exporting_targets.html + version("0.7.0", sha256="df8720a9cba1199d21f1d32649cebb9dddf95aa61bc3ac23f6c8a3c6b6083528") version("0.6.2", sha256="84b663162957c1fe0e896ac8e94cbf2b6def4a152ccfa12a293db14fb25191c8") version("0.6.1", sha256="205540b704b8da5a967475be9e8f2d1a5e77009b950e7fbf01c0edabc4315906") version("0.6.0", sha256="ede355e85f7b11d7c8442b51e4f7871c152093818606e00b1e1cf30f67ebdb23") diff --git a/var/spack/repos/builtin/packages/care/package.py b/var/spack/repos/builtin/packages/care/package.py index 89bd35c0f8e..0176f961068 100644 --- a/var/spack/repos/builtin/packages/care/package.py +++ b/var/spack/repos/builtin/packages/care/package.py @@ -186,7 +186,7 @@ def initconfig_compiler_entries(self): compiler = self.compiler entries = super().initconfig_compiler_entries() - if spec.satisfies("+rocm"): + if spec.satisfies("+rocm ^blt@:0.6"): entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) llnl_link_helpers(entries, spec, compiler) diff --git a/var/spack/repos/builtin/packages/chai/package.py b/var/spack/repos/builtin/packages/chai/package.py index 7d763e8fe67..6a14f8bc053 100644 --- a/var/spack/repos/builtin/packages/chai/package.py +++ b/var/spack/repos/builtin/packages/chai/package.py @@ -221,7 +221,7 @@ def initconfig_compiler_entries(self): # Default entries are already defined in CachedCMakePackage, inherit them: entries = super().initconfig_compiler_entries() - if spec.satisfies("+rocm"): + if spec.satisfies("+rocm ^blt@:0.6"): entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) llnl_link_helpers(entries, spec, compiler) diff --git a/var/spack/repos/builtin/packages/raja-perf/package.py b/var/spack/repos/builtin/packages/raja-perf/package.py index 2efd40864d8..652fe0c7bc7 100644 --- a/var/spack/repos/builtin/packages/raja-perf/package.py +++ b/var/spack/repos/builtin/packages/raja-perf/package.py @@ -176,7 +176,7 @@ def initconfig_compiler_entries(self): # Default entries are already defined in CachedCMakePackage, inherit them: entries = super().initconfig_compiler_entries() - if spec.satisfies("+rocm"): + if spec.satisfies("+rocm ^blt@:0.6"): entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) # adrienbernede-23-01 diff --git a/var/spack/repos/builtin/packages/raja/package.py b/var/spack/repos/builtin/packages/raja/package.py index d01019faea2..dfb11e93dda 100644 --- a/var/spack/repos/builtin/packages/raja/package.py +++ b/var/spack/repos/builtin/packages/raja/package.py @@ -295,7 +295,7 @@ def initconfig_compiler_entries(self): # Default entries are already defined in CachedCMakePackage, inherit them: entries = super().initconfig_compiler_entries() - if spec.satisfies("+rocm"): + if spec.satisfies("+rocm ^blt@:0.6"): entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) llnl_link_helpers(entries, spec, compiler) diff --git a/var/spack/repos/builtin/packages/umpire/package.py b/var/spack/repos/builtin/packages/umpire/package.py index cc25e5114e3..03e89fe4215 100644 --- a/var/spack/repos/builtin/packages/umpire/package.py +++ b/var/spack/repos/builtin/packages/umpire/package.py @@ -324,7 +324,7 @@ def initconfig_compiler_entries(self): # Default entries are already defined in CachedCMakePackage, inherit them: entries = super().initconfig_compiler_entries() - if "+rocm" in spec: + if spec.satisfies("+rocm ^blt@:0.6"): entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) option_prefix = "UMPIRE_" if spec.satisfies("@2022.03.0:") else ""