-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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("[email protected]:", 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("[email protected]:", 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 |