Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpintarelli committed May 9, 2023
2 parents ea1ec7c + bb5c2d7 commit de851f0
Showing 1 changed file with 44 additions and 28 deletions.
72 changes: 44 additions & 28 deletions spack/packages/nlcglib/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)")
Expand All @@ -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"),
Expand All @@ -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

0 comments on commit de851f0

Please sign in to comment.