|
| 1 | +# Copyright Spack Project Developers. See COPYRIGHT file for details. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: (Apache-2.0 OR MIT) |
| 4 | + |
| 5 | +from spack_repo.builtin.build_systems.autotools import AutotoolsPackage |
| 6 | + |
| 7 | +# flake8: noqa: F401,F403 |
| 8 | +from spack.package import * |
| 9 | + |
| 10 | + |
| 11 | +class Amg4psblas(AutotoolsPackage): |
| 12 | + """AMG4PSBLAS: Algebraic MultiGrid preconditioners for PSBLAS. |
| 13 | + Part of the Parallel Sparse Computation Toolkit (PSCToolkit), AMG4PSBLAS provides |
| 14 | + advanced preconditioners including Algebraic Multigrid (AMG) and Domain Decomposition |
| 15 | + methods for use with the PSBLAS sparse linear system solvers. |
| 16 | + """ |
| 17 | + |
| 18 | + homepage = "https://psctoolkit.github.io/" |
| 19 | + git = "https://github.com/sfilippone/amg4psblas.git" |
| 20 | + url = "https://github.com/sfilippone/amg4psblas/archive/refs/tags/v1.2.0.tar.gz" |
| 21 | + |
| 22 | + # List of GitHub accounts to notify when the package is updated. |
| 23 | + maintainers("pasquadambra", "cirdans-home", "sfilippone") |
| 24 | + |
| 25 | + # SPDX identifier of the project's license below. |
| 26 | + license("BSD-3-Clause", checked_by="cirdans-home") |
| 27 | + |
| 28 | + version("develop", branch="development") |
| 29 | + version("1.2.0", sha256="971cac9917a84dad97eccef76feb89b5ea66afa0b80d13f45a62dd5685c01878") |
| 30 | + version("1.2.0-rc3", sha256="589e23829ea569b984db964b0c40fdf2ae7165290c9118da45b0418514b5cf3a") |
| 31 | + |
| 32 | + # Variants for third-party libraries |
| 33 | + variant("mumps", default=False, description="Activates mumps interface") |
| 34 | + variant("umfpack", default=False, description="Activates UMFPACK interface") |
| 35 | + variant("superlu", default=False, description="Activates SuperLU interface") |
| 36 | + variant("superlu_dist", default=False, description="Activates SuperLU_dist interface") |
| 37 | + # Variants for psblas |
| 38 | + variant("mpi", default=True, description="Activates MPI support") |
| 39 | + variant( |
| 40 | + "cuda", |
| 41 | + default=False, |
| 42 | + description="Activate CUDA support, requires a CUDA-capable psblas with right" |
| 43 | + "cudacc flags", |
| 44 | + ) |
| 45 | + variant("openmp", default=False, description="Activate OpenMP support") |
| 46 | + # Additional configure options |
| 47 | + variant("ccopt", default="none", description="Additional CCOPT flags") |
| 48 | + variant("cxxopt", default="none", description="Additional CXXOPT flags") |
| 49 | + variant("fcopt", default="none", description="Additional FCOPT flags") |
| 50 | + variant("extra_opt", default="none", description="Additional EXTRA_OPT flags") |
| 51 | + variant("libs", default="none", description="Additional link flags") |
| 52 | + variant("clibs", default="none", description="Additional CLIBS flags") |
| 53 | + variant("flibs", default="none", description="Additional FLIBS flags") |
| 54 | + |
| 55 | + # Dependencies: |
| 56 | + depends_on("c", type="build") |
| 57 | + depends_on("cxx", type="build") |
| 58 | + depends_on("fortran", type="build") |
| 59 | + # psblas |
| 60 | + depends_on("psblas@develop", when="@develop") |
| 61 | + depends_on("psblas@3.9.0", when="@1.2.0") |
| 62 | + depends_on("psblas@3.9.0-rc3", when="@1.2.0-rc3") |
| 63 | + depends_on("psblas+mpi", when="+mpi") |
| 64 | + depends_on("psblas~mpi", when="~mpi") |
| 65 | + depends_on("psblas+cuda", when="+cuda") |
| 66 | + depends_on("psblas~cuda", when="~cuda") |
| 67 | + depends_on("psblas+openmp", when="+openmp") |
| 68 | + depends_on("psblas~openmp", when="~openmp") |
| 69 | + # third-party libraries |
| 70 | + depends_on("mumps+openmp", when="+openmp+mumps") |
| 71 | + depends_on("mumps~openmp", when="~openmp+mumps") |
| 72 | + depends_on("superlu", when="+superlu") |
| 73 | + depends_on("psblas+metis", when="+superlu") |
| 74 | + depends_on("superlu-dist+openmp", when="+openmp+superlu_dist") |
| 75 | + depends_on("superlu-dist~openmp", when="~openmp+superlu_dist") |
| 76 | + depends_on("suite-sparse", when="+umfpack") |
| 77 | + # Conflicts |
| 78 | + conflicts("~mpi", when="+mumps", msg="MUMPS requires MPI support") |
| 79 | + conflicts("~mpi", when="+superlu_dist", msg="SuperLU_dist requires MPI support") |
| 80 | + |
| 81 | + def configure_args(self): |
| 82 | + args = [f"--prefix={self.prefix}"] |
| 83 | + args.append(f"--with-psblas={self.spec['psblas'].prefix}") |
| 84 | + # Check external libraries |
| 85 | + if "+mumps" in self.spec: |
| 86 | + args.append(f"--with-mumpsdir={self.spec['mumps'].prefix}") |
| 87 | + args.append(f"--with-mumpsincdir={self.spec['mumps'].prefix.include}") |
| 88 | + args.append(f"--with-mumpslibdir={self.spec['mumps'].libs.directories[0]}") |
| 89 | + if "+umfpack" in self.spec: |
| 90 | + args.append(f"--with-umfpackdir={self.spec['suite-sparse'].prefix}") |
| 91 | + args.append(f"--with-umfpackincdir={self.spec['suite-sparse'].prefix.include}") |
| 92 | + args.append(f"--with-umfpacklibdir={self.spec['suite-sparse'].libs.directories[0]}") |
| 93 | + if "+superlu" in self.spec: |
| 94 | + args.append(f"--with-superludir={self.spec['superlu'].prefix}") |
| 95 | + args.append(f"--with-superluincdir={self.spec['superlu'].prefix.include}") |
| 96 | + args.append(f"--with-superlulibdir={self.spec['superlu'].libs.directories[0]}") |
| 97 | + if "+superlu_dist" in self.spec: |
| 98 | + args.append(f"--with-superludistdir={self.spec['superlu-dist'].prefix}") |
| 99 | + args.append(f"--with-superludistincdir={self.spec['superlu-dist'].prefix.include}") |
| 100 | + args.append( |
| 101 | + f"--with-superludistlibdir={self.spec['superlu-dist'].libs.directories[0]}" |
| 102 | + ) |
| 103 | + # All the other options |
| 104 | + for opt in ["ccopt", "cxxopt", "fcopt", "extra_opt", "libs", "clibs", "flibs"]: |
| 105 | + val = self.spec.variants[opt].value |
| 106 | + if val != "none": |
| 107 | + args.append(f"--with-{opt.replace('_', '-')}={val}") |
| 108 | + return args |
| 109 | + |
| 110 | + @run_after("install") |
| 111 | + def samples(self, spec, prefix): |
| 112 | + with working_dir(prefix.samples.advanced.fileread): |
| 113 | + make() |
| 114 | + with working_dir(prefix.samples.advanced.pdegen): |
| 115 | + make() |
0 commit comments