From cfea2d10104477f7f3f81f2a119a552ffc3da513 Mon Sep 17 00:00:00 2001 From: Cory Bloor Date: Mon, 3 Apr 2023 12:28:24 -0600 Subject: hip: mathlibs inherit CudaPackage and ROCmPackage (#34586) Unless the amdgpu_target is overriden, the libraries will default to being built for cuda, since amdgpu_target=none is both default and in conflict with +rocm. This requires a custom Disjoint set to include both the 'auto' variant used by the rocm mathlibs and the 'none' variant used by ROCmPackage. * Fix search for hip+cuda in hipcub@5.1 and later This patch is not strictly necessary, but it may fix the search for HIP in certain environments. * Backport fix for CUDA 11.5 to hipsparse --- .../repos/builtin/packages/hipblas/package.py | 67 ++++++++++++++-------- .../packages/hipcub/find-hip-cuda-rocm-5.1.patch | 13 +++++ .../packages/hipcub/find-hip-cuda-rocm-5.3.patch | 13 +++++ var/spack/repos/builtin/packages/hipcub/package.py | 46 ++++++++++++--- var/spack/repos/builtin/packages/hipfft/package.py | 47 ++++++++++----- .../repos/builtin/packages/hipsolver/package.py | 54 +++++++++++++---- .../0a90ddc4c33ed409a938513b9dbdca8bfad65e06.patch | 30 ++++++++++ .../repos/builtin/packages/hipsparse/package.py | 51 ++++++++++++---- 8 files changed, 253 insertions(+), 68 deletions(-) create mode 100644 var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.1.patch create mode 100644 var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.3.patch create mode 100644 var/spack/repos/builtin/packages/hipsparse/0a90ddc4c33ed409a938513b9dbdca8bfad65e06.patch diff --git a/var/spack/repos/builtin/packages/hipblas/package.py b/var/spack/repos/builtin/packages/hipblas/package.py index 3679267148..7212facf07 100644 --- a/var/spack/repos/builtin/packages/hipblas/package.py +++ b/var/spack/repos/builtin/packages/hipblas/package.py @@ -8,7 +8,7 @@ import re from spack.package import * -class Hipblas(CMakePackage): +class Hipblas(CMakePackage, CudaPackage, ROCmPackage): """hipBLAS is a BLAS marshalling library, with multiple supported backends""" @@ -103,6 +103,22 @@ class Hipblas(CMakePackage): deprecated=True, ) + # default to an 'auto' variant until amdgpu_targets can be given a better default than 'none' + amdgpu_targets = ROCmPackage.amdgpu_targets + variant( + "amdgpu_target", + values=spack.variant.DisjointSetsOfValues(("auto",), ("none",), amdgpu_targets) + .with_default("auto") + .with_error( + "the values 'auto' and 'none' are mutually exclusive with any of the other values" + ) + .with_non_feature_values("auto", "none"), + sticky=True, + ) + variant("rocm", default=True, description="Enable ROCm support") + conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive") + conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required") + variant( "build_type", default="Release", @@ -124,14 +140,11 @@ class Hipblas(CMakePackage): exe = join_path(self.build_directory, "clients", "staging", "hipblas-test") self.run_test(exe, options=["--gtest_filter=-*known_bug*"]) - depends_on("hip@4.1.0:", when="@4.1.0:") - depends_on("rocm-cmake@master", type="build", when="@master:") + depends_on("rocm-cmake@5.2.0:", type="build", when="@5.2.0:") depends_on("rocm-cmake@4.5.0:", type="build", when="@4.5.0:") depends_on("rocm-cmake@3.5.0:", type="build") - for ver in ["master", "develop"]: - depends_on("rocblas@" + ver, when="@" + ver) - depends_on("rocsolver@" + ver, when="@" + ver) + depends_on("hip +cuda", when="+cuda") for ver in [ "3.5.0", @@ -157,10 +170,19 @@ class Hipblas(CMakePackage): "5.3.3", "5.4.0", "5.4.3", + "master", + "develop", ]: - depends_on("hip@" + ver, when="@" + ver) - depends_on("rocsolver@" + ver, when="@" + ver) - depends_on("rocblas@" + ver, when="@" + ver) + depends_on("rocsolver@" + ver, when="+rocm @" + ver) + depends_on("rocblas@" + ver, when="+rocm @" + ver) + + for tgt in ROCmPackage.amdgpu_targets: + depends_on( + "rocblas amdgpu_target={0}".format(tgt), when="+rocm amdgpu_target={0}".format(tgt) + ) + depends_on( + "rocsolver amdgpu_target={0}".format(tgt), when="+rocm amdgpu_target={0}".format(tgt) + ) @classmethod def determine_version(cls, lib): @@ -175,28 +197,27 @@ class Hipblas(CMakePackage): def cmake_args(self): args = [ - # Make sure find_package(HIP) finds the module. self.define("BUILD_CLIENTS_SAMPLES", "OFF"), self.define("BUILD_CLIENTS_TESTS", self.run_tests), ] - # hipblas actually prefers CUDA over AMD GPUs when you have it - # installed... if self.spec.satisfies("@:3.9.0"): - args.append(self.define("TRY_CUDA", "OFF")) + args.append(self.define_from_variant("TRY_CUDA", "cuda")) else: - args.append(self.define("USE_CUDA", "OFF")) - - if self.spec.satisfies("^cmake@3.21.0:3.21.2"): - args.append(self.define("__skip_rocmclang", "ON")) - if self.spec.satisfies("@:5.1"): - args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) - elif self.spec.satisfies("@5.2.0:"): + args.append(self.define_from_variant("USE_CUDA", "cuda")) + + # FindHIP.cmake was used for +rocm until 4.1.0 and is still used for +cuda + if self.spec.satisfies("@:4.0") or self.spec.satisfies("+cuda"): + if self.spec["hip"].satisfies("@:5.1"): + args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) + else: + args.append( + self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.lib.cmake.hip) + ) + + if self.spec.satisfies("@5.2.0:"): args.append(self.define("BUILD_FILE_REORG_BACKWARD_COMPATIBILITY", True)) if self.spec.satisfies("@5.3.0:"): args.append("-DCMAKE_INSTALL_LIBDIR=lib") return args - - def setup_build_environment(self, env): - env.set("CXX", self.spec["hip"].hipcc) diff --git a/var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.1.patch b/var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.1.patch new file mode 100644 index 0000000000..eacfcc645d --- /dev/null +++ b/var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.1.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/VerifyCompiler.cmake b/cmake/VerifyCompiler.cmake +index ca4d646..0256683 100644 +--- a/cmake/VerifyCompiler.cmake ++++ b/cmake/VerifyCompiler.cmake +@@ -22,8 +22,6 @@ + + list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip) + if(CMAKE_CXX_COMPILER MATCHES ".*/nvcc$" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") +- list(APPEND CMAKE_MODULE_PATH /opt/rocm/hip/cmake) +- find_package(hip QUIET CONFIG PATHS /opt/rocm) + if(NOT hip_FOUND) + find_package(HIP REQUIRED) + endif() diff --git a/var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.3.patch b/var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.3.patch new file mode 100644 index 0000000000..184289bd2c --- /dev/null +++ b/var/spack/repos/builtin/packages/hipcub/find-hip-cuda-rocm-5.3.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/VerifyCompiler.cmake b/cmake/VerifyCompiler.cmake +index 846072f..281ccdc 100644 +--- a/cmake/VerifyCompiler.cmake ++++ b/cmake/VerifyCompiler.cmake +@@ -22,8 +22,6 @@ + + list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip) + if(CMAKE_CXX_COMPILER MATCHES ".*nvcc$" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") +- list(APPEND CMAKE_MODULE_PATH /opt/rocm/hip/cmake) +- find_package(hip QUIET CONFIG PATHS /opt/rocm) + if(NOT hip_FOUND) + find_package(HIP REQUIRED) + endif() diff --git a/var/spack/repos/builtin/packages/hipcub/package.py b/var/spack/repos/builtin/packages/hipcub/package.py index 0c946897e0..95364a2a54 100644 --- a/var/spack/repos/builtin/packages/hipcub/package.py +++ b/var/spack/repos/builtin/packages/hipcub/package.py @@ -6,7 +6,7 @@ from spack.package import * -class Hipcub(CMakePackage): +class Hipcub(CMakePackage, CudaPackage, ROCmPackage): """Radeon Open Compute Parallel Primitives Library""" homepage = "https://github.com/ROCmSoftwarePlatform/hipCUB" @@ -96,6 +96,22 @@ class Hipcub(CMakePackage): deprecated=True, ) + # default to an 'auto' variant until amdgpu_targets can be given a better default than 'none' + amdgpu_targets = ROCmPackage.amdgpu_targets + variant( + "amdgpu_target", + values=spack.variant.DisjointSetsOfValues(("auto",), ("none",), amdgpu_targets) + .with_default("auto") + .with_error( + "the values 'auto' and 'none' are mutually exclusive with any of the other values" + ) + .with_non_feature_values("auto", "none"), + sticky=True, + ) + variant("rocm", default=True, description="Enable ROCm support") + conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive") + conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required") + variant( "build_type", default="Release", @@ -105,7 +121,9 @@ class Hipcub(CMakePackage): depends_on("cmake@3.10.2:", type="build", when="@4.2.0:") depends_on("cmake@3.5.1:", type="build") - depends_on("numactl", type="link", when="@3.7.0:") + + depends_on("hip +cuda", when="+cuda") + depends_on("googletest@1.10.0:", type="test") for ver in [ @@ -133,20 +151,32 @@ class Hipcub(CMakePackage): "5.4.0", "5.4.3", ]: - depends_on("hip@" + ver, when="@" + ver) - depends_on("rocprim@" + ver, when="@" + ver) + depends_on("rocprim@" + ver, when="+rocm @" + ver) depends_on("rocm-cmake@%s:" % ver, type="build", when="@" + ver) + # fix hardcoded search in /opt/rocm and broken config mode search + patch("find-hip-cuda-rocm-5.1.patch", when="@5.1:5.2 +cuda") + patch("find-hip-cuda-rocm-5.3.patch", when="@5.3: +cuda") + def setup_build_environment(self, env): - env.set("CXX", self.spec["hip"].hipcc) + if self.spec.satisfies("+rocm"): + env.set("CXX", self.spec["hip"].hipcc) def cmake_args(self): args = [self.define("BUILD_TEST", self.run_tests)] - if self.spec.satisfies("^cmake@3.21.0:3.21.2"): + if self.spec.satisfies("+rocm ^cmake@3.21.0:3.21.2"): args.append(self.define("__skip_rocmclang", "ON")) - if self.spec.satisfies("@:5.1"): - args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) + + # FindHIP.cmake was used for +rocm until 3.7.0 and is still used for +cuda + if self.spec.satisfies("@:3.7.0") or self.spec.satisfies("+cuda"): + if self.spec["hip"].satisfies("@:5.1"): + args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) + else: + args.append( + self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.lib.cmake.hip) + ) + if self.spec.satisfies("@5.2.0:"): args.append(self.define("BUILD_FILE_REORG_BACKWARD_COMPATIBILITY", True)) diff --git a/var/spack/repos/builtin/packages/hipfft/package.py b/var/spack/repos/builtin/packages/hipfft/package.py index b0058339ff..c0c15611c4 100644 --- a/var/spack/repos/builtin/packages/hipfft/package.py +++ b/var/spack/repos/builtin/packages/hipfft/package.py @@ -7,7 +7,7 @@ from spack.package import * -class Hipfft(CMakePackage): +class Hipfft(CMakePackage, CudaPackage, ROCmPackage): """hipFFT is an FFT marshalling library. Currently, hipFFT supports either rocFFT or cuFFT as backends.hipFFT exports an interface that does not require the client to change, regardless of the chosen backend. @@ -73,6 +73,22 @@ class Hipfft(CMakePackage): deprecated=True, ) + # default to an 'auto' variant until amdgpu_targets can be given a better default than 'none' + amdgpu_targets = ROCmPackage.amdgpu_targets + variant( + "amdgpu_target", + values=spack.variant.DisjointSetsOfValues(("auto",), ("none",), amdgpu_targets) + .with_default("auto") + .with_error( + "the values 'auto' and 'none' are mutually exclusive with any of the other values" + ) + .with_non_feature_values("auto", "none"), + sticky=True, + ) + variant("rocm", default=True, description="Enable ROCm support") + conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive") + conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required") + variant( "build_type", default="Release", @@ -82,6 +98,8 @@ class Hipfft(CMakePackage): depends_on("cmake@3.5:", type="build") + depends_on("hip +cuda", when="+cuda") + for ver in [ "4.1.0", "4.2.0", @@ -102,25 +120,28 @@ class Hipfft(CMakePackage): "5.4.3", ]: depends_on("rocm-cmake@%s:" % ver, type="build", when="@" + ver) - depends_on("hip@" + ver, when="@" + ver) - depends_on("rocfft@" + ver, when="@" + ver) + depends_on("rocfft@" + ver, when="+rocm @" + ver) - def setup_build_environment(self, env): - env.set("CXX", self.spec["hip"].hipcc) + for tgt in ROCmPackage.amdgpu_targets: + depends_on( + "rocfft amdgpu_target={0}".format(tgt), when="+rocm amdgpu_target={0}".format(tgt) + ) def cmake_args(self): - args = [ - # Make sure find_package(HIP) finds the module. - self.define("BUILD_CLIENTS_SAMPLES", "OFF") - ] + args = [self.define("BUILD_CLIENTS_SAMPLES", "OFF")] - if self.spec.satisfies("^cmake@3.21.0:3.21.2"): - args.append(self.define("__skip_rocmclang", "ON")) + if self.spec.satisfies("+rocm"): + args.append(self.define("BUILD_WITH_LIB", "ROCM")) + elif self.spec.satisfies("+cuda"): + args.append(self.define("BUILD_WITH_LIB", "CUDA")) - if self.spec.satisfies("@3.7.0:5.1"): + # FindHIP.cmake is still used for both +rocm and +cuda + if self.spec["hip"].satisfies("@:5.1"): args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) - elif self.spec.satisfies("@5.2.0:"): + else: args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.lib.cmake.hip)) + + if self.spec.satisfies("@5.2.0:"): args.append(self.define("BUILD_FILE_REORG_BACKWARD_COMPATIBILITY", True)) if self.spec.satisfies("@5.3.0:"): diff --git a/var/spack/repos/builtin/packages/hipsolver/package.py b/var/spack/repos/builtin/packages/hipsolver/package.py index 4aba7f36b3..58c5407954 100644 --- a/var/spack/repos/builtin/packages/hipsolver/package.py +++ b/var/spack/repos/builtin/packages/hipsolver/package.py @@ -8,7 +8,7 @@ import re from spack.package import * -class Hipsolver(CMakePackage): +class Hipsolver(CMakePackage, CudaPackage, ROCmPackage): """hipSOLVER is a LAPACK marshalling library, with multiple supported backends. It sits between the application and a 'worker' LAPACK library, marshalling inputs into the backend library and marshalling results back to the application. @@ -57,6 +57,22 @@ class Hipsolver(CMakePackage): deprecated=True, ) + # default to an 'auto' variant until amdgpu_targets can be given a better default than 'none' + amdgpu_targets = ROCmPackage.amdgpu_targets + variant( + "amdgpu_target", + values=spack.variant.DisjointSetsOfValues(("auto",), ("none",), amdgpu_targets) + .with_default("auto") + .with_error( + "the values 'auto' and 'none' are mutually exclusive with any of the other values" + ) + .with_non_feature_values("auto", "none"), + sticky=True, + ) + variant("rocm", default=True, description="Enable ROCm support") + conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive") + conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required") + variant( "build_type", default="Release", @@ -66,13 +82,10 @@ class Hipsolver(CMakePackage): depends_on("cmake@3.5:", type="build") - depends_on("hip@4.1.0:", when="@4.1.0:") - depends_on("rocm-cmake@master", type="build", when="@master:") + depends_on("rocm-cmake@5.2.0:", type="build", when="@5.2.0:") depends_on("rocm-cmake@4.5.0:", type="build") - for ver in ["master", "develop"]: - depends_on("rocblas@" + ver, when="@" + ver) - depends_on("rocsolver@" + ver, when="@" + ver) + depends_on("hip +cuda", when="+cuda") for ver in [ "4.5.0", @@ -88,10 +101,19 @@ class Hipsolver(CMakePackage): "5.3.3", "5.4.0", "5.4.3", + "master", + "develop", ]: - depends_on("hip@" + ver, when="@" + ver) - depends_on("rocblas@" + ver, when="@" + ver) - depends_on("rocsolver@" + ver, when="@" + ver) + depends_on("rocblas@" + ver, when="+rocm @" + ver) + depends_on("rocsolver@" + ver, when="+rocm @" + ver) + + for tgt in ROCmPackage.amdgpu_targets: + depends_on( + "rocblas amdgpu_target={0}".format(tgt), when="+rocm amdgpu_target={0}".format(tgt) + ) + depends_on( + "rocsolver amdgpu_target={0}".format(tgt), when="+rocm amdgpu_target={0}".format(tgt) + ) depends_on("googletest@1.10.0:", type="test") depends_on("netlib-lapack@3.7.1:", type="test") @@ -100,9 +122,6 @@ class Hipsolver(CMakePackage): exe = join_path(self.build_directory, "clients", "staging", "hipsolver-test") self.run_test(exe, options=["--gtest_filter=-*known_bug*"]) - def setup_build_environment(self, env): - env.set("CXX", self.spec["hip"].hipcc) - @classmethod def determine_version(cls, lib): match = re.search(r"lib\S*\.so\.\d+\.\d+\.(\d)(\d\d)(\d\d)", lib) @@ -120,6 +139,17 @@ class Hipsolver(CMakePackage): self.define("BUILD_CLIENTS_TESTS", self.run_tests), ] + args.append(self.define_from_variant("USE_CUDA", "cuda")) + + # FindHIP.cmake is still used for +cuda + if self.spec.satisfies("+cuda"): + if self.spec["hip"].satisfies("@:5.1"): + args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) + else: + args.append( + self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.lib.cmake.hip) + ) + if self.spec.satisfies("@5.2.0:"): args.append(self.define("BUILD_FILE_REORG_BACKWARD_COMPATIBILITY", True)) if self.spec.satisfies("@5.3.0:"): diff --git a/var/spack/repos/builtin/packages/hipsparse/0a90ddc4c33ed409a938513b9dbdca8bfad65e06.patch b/var/spack/repos/builtin/packages/hipsparse/0a90ddc4c33ed409a938513b9dbdca8bfad65e06.patch new file mode 100644 index 0000000000..4f8a4f1013 --- /dev/null +++ b/var/spack/repos/builtin/packages/hipsparse/0a90ddc4c33ed409a938513b9dbdca8bfad65e06.patch @@ -0,0 +1,30 @@ +From 0a90ddc4c33ed409a938513b9dbdca8bfad65e06 Mon Sep 17 00:00:00 2001 +From: James Sandham <33790278+jsandham@users.noreply.github.com> +Date: Tue, 29 Nov 2022 12:19:06 -0700 +Subject: [PATCH] Fix cuda compilation (#287) + +Co-authored-by: jsandham +--- + library/src/nvcc_detail/hipsparse.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/library/src/nvcc_detail/hipsparse.cpp b/library/src/nvcc_detail/hipsparse.cpp +index 4d692855..25d257a8 100644 +--- a/library/src/nvcc_detail/hipsparse.cpp ++++ b/library/src/nvcc_detail/hipsparse.cpp +@@ -360,6 +360,7 @@ cusparseSolvePolicy_t hipPolicyToCudaPolicy(hipsparseSolvePolicy_t policy) + } + } + ++#if CUDART_VERSION < 11050 + cusparseSideMode_t hipSideToCudaSide(hipsparseSideMode_t side) + { + switch(side) +@@ -385,6 +386,7 @@ hipsparseSideMode_t CudaSideToHIPSide(cusparseSideMode_t side) + throw "Non existent cusparseSideMode_t"; + } + } ++#endif + + #if CUDART_VERSION > 10000 + cudaDataType hipDataTypeToCudaDataType(hipDataType datatype) diff --git a/var/spack/repos/builtin/packages/hipsparse/package.py b/var/spack/repos/builtin/packages/hipsparse/package.py index e97fa9724e..51399c59d5 100644 --- a/var/spack/repos/builtin/packages/hipsparse/package.py +++ b/var/spack/repos/builtin/packages/hipsparse/package.py @@ -8,7 +8,7 @@ import re from spack.package import * -class Hipsparse(CMakePackage): +class Hipsparse(CMakePackage, CudaPackage, ROCmPackage): """hipSPARSE is a SPARSE marshalling library, with multiple supported backends""" @@ -100,6 +100,22 @@ class Hipsparse(CMakePackage): deprecated=True, ) + # default to an 'auto' variant until amdgpu_targets can be given a better default than 'none' + amdgpu_targets = ROCmPackage.amdgpu_targets + variant( + "amdgpu_target", + values=spack.variant.DisjointSetsOfValues(("auto",), ("none",), amdgpu_targets) + .with_default("auto") + .with_error( + "the values 'auto' and 'none' are mutually exclusive with any of the other values" + ) + .with_non_feature_values("auto", "none"), + sticky=True, + ) + variant("rocm", default=True, description="Enable ROCm support") + conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive") + conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required") + variant( "build_type", default="Release", @@ -107,6 +123,8 @@ class Hipsparse(CMakePackage): description="CMake build type", ) + depends_on("hip +cuda", when="+cuda") + depends_on("cmake@3.5:", type="build") depends_on("git", type="build") @@ -136,11 +154,16 @@ class Hipsparse(CMakePackage): "5.4.3", ]: depends_on("rocm-cmake@%s:" % ver, type="build", when="@" + ver) - depends_on("hip@" + ver, when="@" + ver) - depends_on("rocsparse@" + ver, when="@" + ver) + depends_on("rocsparse@" + ver, when="+rocm @" + ver) + + for tgt in ROCmPackage.amdgpu_targets: + depends_on( + "rocsparse amdgpu_target={0}".format(tgt), when="+rocm amdgpu_target={0}".format(tgt) + ) patch("e79985dccde22d826aceb3badfc643a3227979d2.patch", when="@3.5.0") patch("530047af4a0f437dafc02f76b3a17e3b1536c7ec.patch", when="@3.5.0") + patch("0a90ddc4c33ed409a938513b9dbdca8bfad65e06.patch") @classmethod def determine_version(cls, lib): @@ -155,22 +178,26 @@ class Hipsparse(CMakePackage): def cmake_args(self): args = [ - # Make sure find_package(HIP) finds the module. self.define("CMAKE_CXX_STANDARD", "14"), self.define("BUILD_CLIENTS_SAMPLES", "OFF"), self.define("BUILD_CLIENTS_TESTS", "OFF"), ] - if self.spec.satisfies("^cmake@3.21.0:3.21.2"): - args.append(self.define("__skip_rocmclang", "ON")) + args.append(self.define_from_variant("BUILD_CUDA", "cuda")) - if self.spec.satisfies("@:5.1"): - args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) - elif self.spec.satisfies("@5.2.0:"): + # FindHIP.cmake was used for +rocm until 5.0.0 and is still used for +cuda + if self.spec.satisfies("@:4") or self.spec.satisfies("+cuda"): + if self.spec["hip"].satisfies("@:5.1"): + args.append(self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.cmake)) + else: + args.append( + self.define("CMAKE_MODULE_PATH", self.spec["hip"].prefix.lib.cmake.hip) + ) + + if self.spec.satisfies("@5.2.0:"): args.append(self.define("BUILD_FILE_REORG_BACKWARD_COMPATIBILITY", True)) + if self.spec.satisfies("@5.3.0:"): args.append("-DCMAKE_INSTALL_LIBDIR=lib") - return args - def setup_build_environment(self, env): - env.set("CXX", self.spec["hip"].hipcc) + return args -- cgit v1.2.3-70-g09d2