amg2023 package: cmake build (#39618)

Switch from makefile to CMake-based build. CMake support is currently
in a specific branch of the amg2023 repo, so add this branch as a
version in the package.
This commit is contained in:
Dewi 2023-08-29 15:47:36 -07:00 committed by GitHub
parent f3c6d892b1
commit f4f396745e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@
from spack.package import * from spack.package import *
class Amg2023(MakefilePackage): class Amg2023(CMakePackage, CudaPackage, ROCmPackage):
"""AMG2023 is a parallel algebraic multigrid solver for linear systems """AMG2023 is a parallel algebraic multigrid solver for linear systems
arising from problems on unstructured grids. The driver provided here arising from problems on unstructured grids. The driver provided here
builds linear systems for various 3-dimensional problems. It requires builds linear systems for various 3-dimensional problems. It requires
@ -18,66 +18,34 @@ class Amg2023(MakefilePackage):
git = "https://github.com/LLNL/AMG2023.git" git = "https://github.com/LLNL/AMG2023.git"
version("develop", branch="main") version("develop", branch="main")
version("cmake-build", git="https://github.com/dyokelson/AMG2023.git", branch="cmake")
variant("mpi", default=True, description="Enable MPI support") variant("mpi", default=True, description="Enable MPI support")
variant("openmp", default=False, description="Enable OpenMP support") variant("openmp", default=False, description="Enable OpenMP support")
variant("caliper", default=False, description="Enable Caliper monitoring") variant("caliper", default=False, description="Enable Caliper monitoring")
variant("adiak", default=False, description="Enable Adiak metadata gathering")
depends_on("mpi", when="+mpi")
depends_on("hypre+mpi", when="+mpi")
requires("+mpi", when="^hypre+mpi")
depends_on("caliper", when="+caliper") depends_on("caliper", when="+caliper")
depends_on("adiak", when="+adiak") depends_on("adiak", when="+caliper")
depends_on("hypre+caliper", when="+caliper") depends_on("hypre+caliper", when="+caliper")
depends_on("hypre@2.27.0:") depends_on("hypre@2.27.0:")
depends_on("mpi", when="+mpi") depends_on("hypre+cuda", when="+cuda")
requires("+cuda", when="^hypre+cuda")
depends_on("hypre+rocm", when="+rocm")
requires("+rocm", when="^hypre+rocm")
def flag_handler(self, name, flags): def cmake_args(self):
if name == "ldlibs": cmake_options = []
if self.spec.satisfies("+caliper"): cmake_options.append(self.define_from_variant("AMG_WITH_CALIPER", "caliper"))
flags.append("-lcaliper") cmake_options.append(self.define_from_variant("AMG_WITH_OMP", "openmp"))
if self.spec.satisfies("+adiak"): cmake_options.append("-DHYPRE_PREFIX={0}".format(self.spec["hypre"].prefix))
flags.append("-ladiak") if self.spec["hypre"].satisfies("+cuda"):
return (flags, None, None) cmake_options.append("-DAMG_WITH_CUDA=ON")
if self.spec["hypre"].satisfies("+rocm"):
cmake_options.append("-DAMG_WITH_HIP=ON")
if self.spec["hypre"].satisfies("+mpi"):
cmake_options.append("-DAMG_WITH_MPI=ON")
def edit(self, spec, prefix): return cmake_options
makefile = FileFilter("Makefile")
if "+mpi" in spec:
makefile.filter(r"CC\s*=.*", f"CC = {spec['mpi'].mpicc}")
makefile.filter(r"CXX\s*=.*", f"CXX = {spec['mpi'].mpicxx}")
makefile.filter(r"#MPIPATH = .*", f"MPIPATH = {spec['mpi'].prefix}")
makefile.filter(r"#MPIINCLUDE", "MPIINCLUDE")
if spec["mpi"].extra_attributes and "ldflags" in spec["mpi"].extra_attributes:
makefile.filter(
"#MPILIBS = .*",
"MPILIBS = {0}".format(spec["mpi"].extra_attributes["ldflags"]),
)
else:
makefile.filter("#MPILIBDIRS", "MPILIBDIRS")
makefile.filter("#MPILIBS", "MPILIBS")
makefile.filter("#MPIFLAGS", "MPIFLAGS")
else:
makefile.filter(r"CC\s*=.*", "CC = {0}".format(spack_cc))
makefile.filter(r"CXX\s*=.*", "CXX = {0}".format(spack_cxx))
makefile.filter(r"HYPRE_DIR = .*", f'HYPRE_DIR = {spec["hypre"].prefix}')
if spec["hypre"].satisfies("+cuda"):
makefile.filter(
"HYPRE_CUDA_PATH = .*", "HYPRE_CUDA_PATH = %s" % (spec["cuda"].prefix)
)
makefile.filter("HYPRE_CUDA_INCLUDE = #", "HYPRE_CUDA_INCLUDE = ")
makefile.filter("HYPRE_CUDA_LIBS = #", "HYPRE_CUDA_LIBS = ")
makefile.filter("HYPRE_HIP_PATH =", "#HYPRE_HIP_PATH =")
makefile.filter("HYPRE_HIP_INCLUDE =", "#HYPRE_HIP_INCLUDE =")
makefile.filter("HYPRE_HIP_LIBS =", "#HYPRE_HIP_LIBS =")
if spec["hypre"].satisfies("+rocm"):
makefile.filter("HYPRE_HIP_PATH = .*", "HYPRE_HIP_PATH = ${ROCM_PATH}")
else:
makefile.filter("HYPRE_HIP_PATH =", "#HYPRE_HIP_PATH =")
makefile.filter("HYPRE_HIP_INCLUDE =", "#HYPRE_HIP_INCLUDE =")
makefile.filter("HYPRE_HIP_LIBS =", "#HYPRE_HIP_LIBS =")
def install(self, spec, prefix):
make()
mkdirp(prefix.bin)
install("amg", prefix.bin)