Skip to content

Commit

Permalink
cabana: add +all, with new package "all"(A Load Balancing Library) (s…
Browse files Browse the repository at this point in the history
…pack#46852)

* Add libALL support

* cabana: also require ALL

* cabana: Bugfix: Fix spec for cmake>=3.26 to be @3.26: and HDF5 support requires MPI

* cabana: MPI requires C: Add depends_on("c", type="build", when="+mpi")

* cabana: +mpi requires C, but at least for some CMake versions, Cabana's enable of C is too late. Patch it.

* cabana: simplify disabling of find_package's for disabled options and improve comment

* cabana: +grid of 0.6.0 does not compile with gcc-13: It misses iostream includes

* cabana: +test requires googletest at build time: gtest is a linked library(not a plugin or tool)

* cabana: 0.6.0+cuda requires [email protected]:, see https://github.com/ECP-copa/Cabana/releases

* cabana: As 0.6.0+grid does not support gcc-13 and newer, I think it's good to add 0.6.1 and 0.7.0?

---------

Co-authored-by: Bernhard Kaindl <[email protected]>
  • Loading branch information
junghans and bernhardkaindl authored Oct 9, 2024
1 parent 0f3fea5 commit 6d67992
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 13 deletions.
48 changes: 48 additions & 0 deletions var/spack/repos/builtin/packages/all/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *


class All(CMakePackage):
"""A Load Balancing Library (ALL)
The library aims to provide an easy way to include dynamic domain-based
load balancing into particle based simulation codes.
"""

homepage = "http://slms.pages.jsc.fz-juelich.de/websites/all-website/"
url = "https://gitlab.jsc.fz-juelich.de/SLMS/loadbalancing/-/archive/v0.9.2/loadbalancing-v0.9.2.tar.gz"

maintainers("junghans")

license("BSD-3-Clause", checked_by="junghans")

version("0.9.2", sha256="2b4ef52c604c3c0c467712d0912a33c82177610b67edc14df1e034779c6ddb71")

variant("fortran", default=False, description="Build with fortran support")
variant("shared", default=True, description="Build shared libraries")
variant("vtk", default=False, description="Build with vtk support")

depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("fortran", type="build", when="+fortran")
depends_on("vtk", when="+vtk")

depends_on("mpi")

def cmake_args(self):
args = [
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
self.define_from_variant("CM_ALL_FORTRAN", "fortran"),
self.define_from_variant("CM_ALL_USE_F08", "fortran"),
self.define_from_variant("CM_ALL_VTK_OUTPUT", "vtk"),
]

if self.run_tests:
args.append("-DCM_ALL_TESTS=ON")
args.append("-DCM_ALL_TESTS_INTEGRATION=ON")

return args
41 changes: 28 additions & 13 deletions var/spack/repos/builtin/packages/cabana/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage):

homepage = "https://github.com/ECP-copa/Cabana"
git = "https://github.com/ECP-copa/Cabana.git"
url = "https://github.com/ECP-copa/Cabana/archive/0.6.0.tar.gz"
url = "https://github.com/ECP-copa/Cabana/archive/0.7.0.tar.gz"

maintainers("junghans", "streeve", "sslattery")

tags = ["e4s", "ecp"]

version("master", branch="master")
version("0.7.0", sha256="3d46532144ea9a3f36429a65cccb7562d1244f1389dd8aff0d253708d1ec9838")
version("0.6.1", sha256="fea381069fe707921831756550a665280da59032ea7914f7ce2a01ed467198bc")
version("0.6.0", sha256="a88a3f80215998169cdbd37661c0c0af57e344af74306dcd2b61983d7c69e6e5")
version("0.5.0", sha256="b7579d44e106d764d82b0539285385d28f7bbb911a572efd05c711b28b85d8b1")
version("0.4.0", sha256="c347d23dc4a5204f9cc5906ccf3454f0b0b1612351bbe0d1c58b14cddde81e85")
Expand All @@ -27,7 +29,8 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage):
version("0.1.0", sha256="3280712facf6932b9d1aff375b24c932abb9f60a8addb0c0a1950afd0cb9b9cf")
version("0.1.0-rc0", sha256="73754d38aaa0c2a1e012be6959787108fec142294774c23f70292f59c1bdc6c5")

depends_on("cxx", type="build") # generated
depends_on("c", type="build", when="+mpi")
depends_on("cxx", type="build")

_kokkos_backends = Kokkos.devices_variants
for _backend in _kokkos_backends:
Expand All @@ -36,6 +39,7 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage):

variant("shared", default=True, description="Build shared libraries")
variant("mpi", default=True, description="Build with mpi support")
variant("all", default=False, description="Build with ALL support")
variant("arborx", default=False, description="Build with ArborX support")
variant("heffte", default=False, description="Build with heFFTe support")
variant("hypre", default=False, description="Build with HYPRE support")
Expand All @@ -50,7 +54,7 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage):
depends_on("[email protected]:", type="build", when="@:0.4.0")
depends_on("[email protected]:", type="build", when="@0.5.0:")

depends_on("googletest", type="test", when="+testing")
depends_on("googletest", type="build", when="+testing")
_versions = {":0.2": "-legacy", "0.3:": "@3.1:", "0.4:": "@3.2:", "0.6:": "@3.7:"}
for _version in _versions:
_kk_version = _versions[_version]
Expand Down Expand Up @@ -84,9 +88,12 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage):
conflicts("+cuda", when="cuda_arch=none")
conflicts("+rocm", when="amdgpu_target=none")

depends_on("kokkos+cuda_lambda", when="+cuda")
# https://github.com/ECP-copa/Cabana/releases/tag/0.7.0
depends_on("[email protected]:", when="+cuda")
depends_on("[email protected]:", when="[email protected]:")

# Dependencies for subpackages
depends_on("all", when="@0.5.0:+all")
depends_on("arborx", when="@0.3.0:+arborx")
depends_on("[email protected]:", when="@0.4.0:+hypre")
depends_on("[email protected]:", when="@0.5.0:+hypre")
Expand All @@ -97,25 +104,35 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage):
depends_on("hdf5", when="@0.6.0:+hdf5")
depends_on("mpi", when="+mpi")

# Cabana automatically builds HDF5 support with newer cmake versions
# in version 0.6.0. This is fixed post-0.6
conflicts("~hdf5", when="@0.6.0 ^cmake@:3.26")
# CMakeLists.txt of Cabana>=0.6 always enables HDF5 with CMake >= 3.26 (not changed post-0.6):
conflicts("~hdf5", when="@0.6.0: ^[email protected]:")

# Cabana HDF5 support requires MPI.
conflicts("+hdf5 ~mpi")

# Cajita support requires MPI
conflicts("+cajita ~mpi")
conflicts("+grid ~mpi")

# The +grid does not support gcc>=13 (missing iostream/cstdint includes):
conflicts("+grid", when="@:0.6 %gcc@13:")

# Conflict variants only available in newer versions of cabana
conflicts("+rocm", when="@:0.2.0")
conflicts("+sycl", when="@:0.3.0")
conflicts("+silo", when="@:0.3.0")
conflicts("+hdf5", when="@:0.5.0")

@when("+mpi")
def patch(self):
# CMakeLists.txt tries to enable C when MPI is requsted, but too late:
filter_file("LANGUAGES CXX", "LANGUAGES C CXX", "CMakeLists.txt")

def cmake_args(self):
options = [self.define_from_variant("BUILD_SHARED_LIBS", "shared")]

enable = ["CAJITA", "TESTING", "EXAMPLES", "PERFORMANCE_TESTING"]
require = ["ARBORX", "HEFFTE", "HYPRE", "SILO", "HDF5"]
require = ["ALL", "ARBORX", "HEFFTE", "HYPRE", "SILO", "HDF5"]

# These variables were removed in 0.3.0 (where backends are
# automatically used from Kokkos)
Expand All @@ -136,12 +153,10 @@ def cmake_args(self):
cbn_option = "Cabana_{0}_{1}".format(cname, var)
options.append(self.define_from_variant(cbn_option, var.lower()))

# Only enable user-requested options.
# Attempt to disable find_package() calls for disabled options(if option supports it):
for var in require:
enabled_var = "+{0}".format(var.lower())
if enabled_var not in self.spec:
cbn_disable = "CMAKE_DISABLE_FIND_PACKAGE_{0}".format(var)
options.append(self.define(cbn_disable, "ON"))
if not self.spec.satisfies("+" + var.lower()):
options.append(self.define("CMAKE_DISABLE_FIND_PACKAGE_" + var, "ON"))

# Use hipcc for HIP.
if self.spec.satisfies("+rocm"):
Expand Down

0 comments on commit 6d67992

Please sign in to comment.