From f4f396745e165ae999f3f17eed0691412e51e4d9 Mon Sep 17 00:00:00 2001 From: Dewi <43684384+dyokelson@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:47:36 -0700 Subject: 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. --- .../repos/builtin/packages/amg2023/package.py | 80 +++++++--------------- 1 file changed, 24 insertions(+), 56 deletions(-) diff --git a/var/spack/repos/builtin/packages/amg2023/package.py b/var/spack/repos/builtin/packages/amg2023/package.py index 67042f4d7a..96b2dc335d 100644 --- a/var/spack/repos/builtin/packages/amg2023/package.py +++ b/var/spack/repos/builtin/packages/amg2023/package.py @@ -6,7 +6,7 @@ from spack.package import * -class Amg2023(MakefilePackage): +class Amg2023(CMakePackage, CudaPackage, ROCmPackage): """AMG2023 is a parallel algebraic multigrid solver for linear systems arising from problems on unstructured grids. The driver provided here builds linear systems for various 3-dimensional problems. It requires @@ -18,66 +18,34 @@ class Amg2023(MakefilePackage): git = "https://github.com/LLNL/AMG2023.git" 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("openmp", default=False, description="Enable OpenMP support") 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("adiak", when="+adiak") + depends_on("adiak", when="+caliper") depends_on("hypre+caliper", when="+caliper") depends_on("hypre@2.27.0:") - depends_on("mpi", when="+mpi") - - def flag_handler(self, name, flags): - if name == "ldlibs": - if self.spec.satisfies("+caliper"): - flags.append("-lcaliper") - if self.spec.satisfies("+adiak"): - flags.append("-ladiak") - return (flags, None, None) - - def edit(self, spec, prefix): - 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) + depends_on("hypre+cuda", when="+cuda") + requires("+cuda", when="^hypre+cuda") + depends_on("hypre+rocm", when="+rocm") + requires("+rocm", when="^hypre+rocm") + + def cmake_args(self): + cmake_options = [] + cmake_options.append(self.define_from_variant("AMG_WITH_CALIPER", "caliper")) + cmake_options.append(self.define_from_variant("AMG_WITH_OMP", "openmp")) + cmake_options.append("-DHYPRE_PREFIX={0}".format(self.spec["hypre"].prefix)) + if self.spec["hypre"].satisfies("+cuda"): + 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") + + return cmake_options -- cgit v1.2.3-60-g2f50