|
| 1 | +from spack.package import * |
| 2 | + |
| 3 | + |
| 4 | +class Ghex(CMakePackage, CudaPackage, ROCmPackage): |
| 5 | + """ |
| 6 | + GHEX is a generic halo-exchange library. |
| 7 | +
|
| 8 | + This Spack package was originally copied from: |
| 9 | + https://github.com/ghex-org/spack-repos/blob/main/packages/ghex/package.py |
| 10 | +
|
| 11 | + License: ghex-org |
| 12 | + """ |
| 13 | + |
| 14 | + homepage = "https://github.com/ghex-org/GHEX" |
| 15 | + url = "https://github.com/ghex-org/GHEX/archive/refs/tags/v0.3.0.tar.gz" |
| 16 | + git = "https://github.com/ghex-org/GHEX.git" |
| 17 | + maintainers = ["boeschf"] |
| 18 | + |
| 19 | + version("0.4.1", tag="v0.4.1", submodules=True) |
| 20 | + version("0.4.0", tag="v0.4.0", submodules=True) |
| 21 | + version("0.3.0", tag="v0.3.0", submodules=True) |
| 22 | + version("master", branch="master", submodules=True) |
| 23 | + |
| 24 | + depends_on("cxx", type="build") |
| 25 | + |
| 26 | + generator("ninja") |
| 27 | + |
| 28 | + backends = ("mpi", "ucx", "libfabric") |
| 29 | + variant( |
| 30 | + "backend", |
| 31 | + default="mpi", |
| 32 | + description="Transport backend", |
| 33 | + values=backends, |
| 34 | + multi=False, |
| 35 | + ) |
| 36 | + variant("xpmem", default=False, description="Use xpmem shared memory") |
| 37 | + variant("python", default=True, description="Build Python bindings") |
| 38 | + |
| 39 | + depends_on("cmake@3.21:", type="build") |
| 40 | + depends_on("mpi") |
| 41 | + depends_on("boost") |
| 42 | + depends_on("xpmem", when="+xpmem", type=("build", "run")) |
| 43 | + |
| 44 | + depends_on("oomph") |
| 45 | + for backend in backends: |
| 46 | + depends_on(f"oomph backend={backend}", when=f"backend={backend}") |
| 47 | + depends_on("oomph+cuda", when="+cuda") |
| 48 | + depends_on("oomph+rocm", when="+rocm") |
| 49 | + depends_on("oomph@0.3:", when="@0.3:") |
| 50 | + |
| 51 | + conflicts("+cuda+rocm") |
| 52 | + |
| 53 | + with when("+python"): |
| 54 | + extends("python") |
| 55 | + depends_on("python@3.7:", type="build") |
| 56 | + depends_on("py-pip", type="build") |
| 57 | + depends_on("py-pybind11", type="build") |
| 58 | + depends_on("py-mpi4py", type=("build", "run")) |
| 59 | + depends_on("py-numpy", type=("build", "run")) |
| 60 | + |
| 61 | + depends_on("py-pytest", when="+python", type=("test")) |
| 62 | + |
| 63 | + def cmake_args(self): |
| 64 | + spec = self.spec |
| 65 | + |
| 66 | + args = [ |
| 67 | + self.define("GHEX_USE_BUNDLED_LIBS", True), |
| 68 | + self.define("GHEX_USE_BUNDLED_GRIDTOOLS", True), |
| 69 | + self.define("GHEX_USE_BUNDLED_GTEST", self.run_tests), |
| 70 | + self.define("GHEX_USE_BUNDLED_OOMPH", False), |
| 71 | + self.define("GHEX_TRANSPORT_BACKEND", |
| 72 | + spec.variants["backend"].value.upper()), |
| 73 | + self.define_from_variant("GHEX_USE_XPMEM", "xpmem"), |
| 74 | + self.define_from_variant("GHEX_BUILD_PYTHON_BINDINGS", "python"), |
| 75 | + self.define("GHEX_WITH_TESTING", self.run_tests), |
| 76 | + ] |
| 77 | + |
| 78 | + if spec.satisfies("+python"): |
| 79 | + args.append(self.define("GHEX_PYTHON_LIB_PATH", python_platlib)) |
| 80 | + |
| 81 | + if self.run_tests and spec.satisfies("^openmpi"): |
| 82 | + args.append(self.define("MPIEXEC_PREFLAGS", "--oversubscribe")) |
| 83 | + |
| 84 | + if "+cuda" in spec and spec.variants["cuda_arch"].value != "none": |
| 85 | + arch_str = ";".join(spec.variants["cuda_arch"].value) |
| 86 | + args.append(self.define("CMAKE_CUDA_ARCHITECTURES", arch_str)) |
| 87 | + args.append(self.define("GHEX_USE_GPU", True)) |
| 88 | + args.append(self.define("GHEX_GPU_TYPE", "NVIDIA")) |
| 89 | + |
| 90 | + if "+rocm" in spec and spec.variants["amdgpu_target"].value != "none": |
| 91 | + arch_str = ";".join(spec.variants["amdgpu_target"].value) |
| 92 | + args.append(self.define("CMAKE_HIP_ARCHITECTURES", arch_str)) |
| 93 | + args.append(self.define("GHEX_USE_GPU", True)) |
| 94 | + args.append(self.define("GHEX_GPU_TYPE", "AMD")) |
| 95 | + |
| 96 | + if spec.satisfies("~cuda~rocm"): |
| 97 | + args.append(self.define("GHEX_USE_GPU", False)) |
| 98 | + |
| 99 | + return args |
0 commit comments