Apply generic rocm handling to every project

This commit is contained in:
Adrien M. BERNEDE 2025-03-20 10:08:28 +01:00
parent 02f76a8ca6
commit df040fddd9

View File

@ -278,20 +278,15 @@ def initconfig_hardware_entries(self):
entries.append("# ROCm") entries.append("# ROCm")
entries.append("#------------------{0}\n".format("-" * 30)) entries.append("#------------------{0}\n".format("-" * 30))
# Starting with blt@0.7, support for hip is handled with rocm_root = os.path.dirname(spec["llvm-amdgpu"].prefix)
# CMake enable_language(HIP). entries.append(cmake_cache_path("ROCM_PATH", rocm_root))
# TODO: consider applying this all the time, and let package
# add specifics when necessary, e.g. when not using CMake
# support for HIP.
if spec.satisfies("^blt@0.7:"):
rocm_root = os.path.dirname(spec["llvm-amdgpu"].prefix)
entries.append(cmake_cache_path("ROCM_PATH", rocm_root))
archs = self.spec.variants["amdgpu_target"].value archs = self.spec.variants["amdgpu_target"].value
if archs[0] != "none": if archs[0] != "none":
arch_str = ";".join(archs) arch_str = ";".join(archs)
entries.append(cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str)) entries.append(cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str))
else:
if spec.satisfies("^blt@:0.6"):
# Explicitly setting HIP_ROOT_DIR may be a patch that is no longer necessary # 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_ROOT_DIR", "{0}".format(spec["hip"].prefix)))
llvm_bin = spec["llvm-amdgpu"].prefix.bin llvm_bin = spec["llvm-amdgpu"].prefix.bin
@ -304,10 +299,8 @@ def initconfig_hardware_entries(self):
cmake_cache_filepath("CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "clang++")) cmake_cache_filepath("CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "clang++"))
) )
archs = self.spec.variants["amdgpu_target"].value
if archs[0] != "none": if archs[0] != "none":
arch_str = ";".join(archs) arch_str = ";".join(archs)
entries.append(cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str))
entries.append(cmake_cache_string("AMDGPU_TARGETS", arch_str)) entries.append(cmake_cache_string("AMDGPU_TARGETS", arch_str))
entries.append(cmake_cache_string("GPU_TARGETS", arch_str)) entries.append(cmake_cache_string("GPU_TARGETS", arch_str))