From bb5c2d791a0e31313b5e8d932fbea1a872895582 Mon Sep 17 00:00:00 2001 From: Simon Pintarelli Date: Tue, 9 May 2023 15:32:56 +0200 Subject: [PATCH] update spack recipe --- spack/packages/nlcglib/package.py | 72 +++++++++++++++++++------------ 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/spack/packages/nlcglib/package.py b/spack/packages/nlcglib/package.py index 9146973..41003e1 100644 --- a/spack/packages/nlcglib/package.py +++ b/spack/packages/nlcglib/package.py @@ -6,7 +6,7 @@ from spack.package import * -class Nlcglib(CMakePackage, CudaPackage, ROCmPackage): +class Nlcglib(CMakePackage, CudaPackage, ROCmPackage): """Nonlinear CG methods for wave-function optimization in DFT.""" homepage = "https://github.com/simonpintarelli/nlcglib" @@ -16,13 +16,31 @@ class Nlcglib(CMakePackage, CudaPackage, ROCmPackage): maintainers = ["simonpintarelli"] version("develop", branch="develop") + version("master", branch="master") + version("0.9", sha256="8d5bc6b85ee714fb3d6480f767e7f43e5e7d569116cf60e48f533a7f50a37a08") variant("openmp", default=True) variant("tests", default=False) - variant("build_type", - default="Release", - description="CMake build type", - values=("Debug", "Release", "RelWithDebInfo")) + variant( + "build_type", + default="Release", + description="CMake build type", + values=("Debug", "Release", "RelWithDebInfo"), + ) + + depends_on("cmake@3.21:", type="build") + depends_on("mpi") + depends_on("lapack") + + depends_on("kokkos~cuda~rocm", when="~cuda~rocm") + depends_on("kokkos+openmp", when="+openmp") + + depends_on("googletest", type="build", when="+tests") + depends_on("nlohmann-json") + + with when("@:0.9"): + conflicts("+rocm") + conflicts("^kokkos@4:") with when("+rocm"): variant("magma", default=True, description="Use magma eigenvalue solver (AMDGPU)") @@ -35,16 +53,6 @@ class Nlcglib(CMakePackage, CudaPackage, ROCmPackage): depends_on("kokkos+cuda+cuda_lambda+wrapper", when="%gcc") depends_on("kokkos+cuda") - depends_on("cmake@3.21:", type="build") - depends_on("mpi") - depends_on("lapack") - - depends_on("kokkos") - depends_on("kokkos+openmp", when="+openmp") - - depends_on("googletest", type="build", when="+tests") - depends_on("nlohmann-json") - def cmake_args(self): options = [ self.define_from_variant("USE_OPENMP", "openmp"), @@ -55,32 +63,40 @@ def cmake_args(self): ] if self.spec["blas"].name in ["intel-mkl", "intel-parallel-studio"]: - options.append("-DLAPACK_VENDOR=MKL") + options += [self.define("LAPACK_VENDOR", "MKL")] elif self.spec["blas"].name in ["intel-oneapi-mkl"]: - options.append("-DLAPACK_VENDOR=MKLONEAPI") + options += [self.define("LAPACK_VENDOR", "MKLONEAPI")] elif self.spec["blas"].name in ["openblas"]: - options.append("-DLAPACK_VENDOR=OpenBLAS") + options += [self.define("LAPACK_VENDOR", "OpenBLAS")] else: raise Exception("blas/lapack must be either openblas or mkl.") if "+cuda%gcc" in self.spec: - options.append( - "-DCMAKE_CXX_COMPILER=%s" % self.spec["kokkos-nvcc-wrapper"].kokkos_cxx - ) + options += [ + self.define( + "CMAKE_CXX_COMPILER", "{0}".format(self.spec["kokkos-nvcc-wrapper"].kokkos_cxx) + ) + ] if "+cuda" in self.spec: - cuda_arch = self.spec.variants["cuda_arch"].value - if cuda_arch[0] != "none": - options += ["-DCMAKE_CUDA_FLAGS=-arch=sm_{0}".format(cuda_arch[0])] + cuda_archs = self.spec.variants["cuda_arch"].value + if "@:0.9" in self.spec: + cuda_flags = " ".join( + ["-gencode arch=compute_{0},code=sm_{0}".format(x) for x in cuda_archs] + ) + options += [self.define("CMAKE_CUDA_FLAGS", cuda_flags)] + else: + options += [self.define("CMAKE_CUDA_ARCHITECTURES", cuda_archs)] if "^cuda+allow-unsupported-compilers" in self.spec: - options += ["-DCMAKE_CUDA_FLAGS=--allow-unsupported-compiler"] + options += [self.define("CMAKE_CUDA_FLAGS", "--allow-unsupported-compiler")] if "+rocm" in self.spec: - options.append(self.define( - "CMAKE_CXX_COMPILER", self.spec["hip"].hipcc)) + options.append(self.define("CMAKE_CXX_COMPILER", self.spec["hip"].hipcc)) archs = ",".join(self.spec.variants["amdgpu_target"].value) options.append("-DHIP_HCC_FLAGS=--amdgpu-target={0}".format(archs)) - options.append("-DCMAKE_CXX_FLAGS=--amdgpu-target={0} --offload-arch={0}".format(archs)) + options.append( + "-DCMAKE_CXX_FLAGS=--amdgpu-target={0} --offload-arch={0}".format(archs) + ) return options