Skip to content

Commit

Permalink
WarpX: Python on pyAMReX
Browse files Browse the repository at this point in the history
Long overdue update for WarpX: in 2024, we updated our Python
bindings to rely on the new pyAMReX package. This deprecates the old
`py-warpx` package and adds a new dependency and variant to WarpX.

Also deprecates old versions that we will not continue to support.
  • Loading branch information
ax3l committed Aug 17, 2024
1 parent 66e2836 commit 01ea687
Show file tree
Hide file tree
Showing 5 changed files with 464 additions and 112 deletions.
97 changes: 64 additions & 33 deletions var/spack/repos/builtin/packages/py-amrex/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,36 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.build_systems.python import PythonPipBuilder
from spack.package import *


class PyAmrex(PythonPackage, CudaPackage, ROCmPackage):
class PyAmrex(CMakePackage, PythonExtension, CudaPackage, ROCmPackage):
"""AMReX Python Bindings with pybind11"""

homepage = "https://amrex-codes.github.io/amrex/"
url = "https://github.com/AMReX-Codes/pyamrex/archive/refs/tags/24.04.tar.gz"
url = "https://github.com/AMReX-Codes/pyamrex/archive/refs/tags/24.08.tar.gz"
git = "https://github.com/AMReX-Codes/pyamrex.git"

maintainers("ax3l", "RTSandberg", "sayerhs", "WeiqunZhang")

license("BSD-3-Clause-LBNL")

version("develop", branch="development")
version("24.04", sha256="ab85695bb9644b702d0fc84e77205d264d27ba94999cab912c8a3212a7eb77fc")
version("24.03", sha256="bf85b4ad35b623278cbaae2c07e22138545dec0732d15c4ab7c53be76a7f2315")
version("24.08", sha256="e7179d88261f64744f392a2194ff2744fe323fe0e21d0742ba60458709a1b47e")
version(
"24.04",
sha256="ab85695bb9644b702d0fc84e77205d264d27ba94999cab912c8a3212a7eb77fc",
deprecated=True,
)

depends_on("cxx", type="build") # generated
version(
"24.03",
sha256="bf85b4ad35b623278cbaae2c07e22138545dec0732d15c4ab7c53be76a7f2315",
deprecated=True,
)

for v in ["24.04", "24.03"]:
for v in ["24.08", "24.04", "24.03"]:
depends_on("amrex@{0}".format(v), when="@{0}".format(v), type=("build", "link"))

variant(
Expand All @@ -33,6 +42,9 @@ class PyAmrex(PythonPackage, CudaPackage, ROCmPackage):
multi=True,
description="Dimensionality",
)
# Spack defaults to False but pybind11 defaults to True (and IPO is highly
# encouraged to be used with pybind11 projects)
variant("ipo", default=True, description="CMake interprocedural optimization")
variant("mpi", default=True, description="Build with MPI support")
variant("openmp", default=False, description="Build with OpenMP support")
variant(
Expand All @@ -42,14 +54,21 @@ class PyAmrex(PythonPackage, CudaPackage, ROCmPackage):
values=("single", "double"),
)
variant("tiny_profile", default=False, description="Enable tiny profiling")
variant("sycl", default=False, description="Enable SYCL backend")

extends("python")

depends_on("cxx", type="build")

depends_on("[email protected]:", type="build")
depends_on("[email protected]:", type=("build", "run"))
depends_on("[email protected]:1", type=("build", "run"))
depends_on("[email protected]:", type=("build", "run"), when="+mpi")
depends_on("[email protected]:1", type=("build", "run"))
depends_on("py-packaging@23:", type="build")
depends_on("py-pip@23:", type="build")
depends_on("py-setuptools@42:", type="build")
depends_on("[email protected]:3", type="build")
depends_on("py-[email protected]:", type="link")
depends_on("[email protected]:", type=("build", "link"))
depends_on("py-[email protected]:", type="build")

# AMReX options
# required variants
Expand All @@ -63,53 +82,65 @@ class PyAmrex(PythonPackage, CudaPackage, ROCmPackage):
depends_on("amrex dimensions=3")
with when("+mpi"):
depends_on("amrex +mpi")
with when("~mpi"):
depends_on("amrex ~mpi")
with when("+openmp"):
depends_on("amrex +openmp")
with when("~openmp"):
depends_on("amrex ~openmp")
with when("+tiny_profile"):
depends_on("amrex +tiny_profile")
with when("+cuda"):
depends_on("amrex +cuda")
# todo: how to forward cuda_arch?
with when("~cuda"):
depends_on("amrex ~cuda")
with when("+rocm"):
depends_on("amrex +rocm")
# todo: how to forward amdgpu_target?
with when("~rocm"):
depends_on("amrex ~rocm")
with when("+sycl"):
depends_on("amrex +sycl")
with when("~sycl"):
depends_on("amrex ~sycl")

depends_on("py-pytest", type="test")
depends_on("py-pandas", type="test")
depends_on("py-cupy", type="test", when="+cuda")

phases = ("cmake", "build", "install", "pip_install_nodeps")
build_targets = ["all", "pip_wheel"]

tests_src_dir = "tests/"

def setup_build_environment(self, env):
spec = self.spec

# disable superbuilds: use external dependencies
env.set("AMREX_INTERNAL", "OFF")
env.set("PYAMREX_CCACHE", "OFF")
env.set("PYAMREX_IPO", "ON")
env.set("PYBIND11_INTERNAL", "OFF")

# configure to require the exact AMReX configs provided by Spack
env.set("AMREX_SPACEDIM", ";".join(spec.variants["dimensions"].value))
env.set("AMREX_MPI", "ON" if spec.satisfies("+mpi") else "OFF")
env.set("AMREX_OMP", "ON" if spec.satisfies("+omp") else "OFF")
env.set("AMREX_PRECISION", spec.variants["precision"].value.upper())
with when("+cuda"):
env.set("AMREX_GPU_BACKEND", "CUDA")
with when("+rocm"):
env.set("AMREX_GPU_BACKEND", "HIP")
# with when("+sycl"):
# env.set("AMREX_GPU_BACKEND", "SYCL")

# control build parallelism
env.set("CMAKE_BUILD_PARALLEL_LEVEL", make_jobs)
def cmake_args(self):
args = ["-DpyAMReX_amrex_internal=OFF", "-DpyAMReX_pybind11_internal=OFF"]
return args

def pip_install_nodeps(self, spec, prefix):
"""Install everything from build directory."""
pip = spec["python"].command
pip.add_default_arg("-m", "pip")

args = PythonPipBuilder.std_args(self) + [
f"--prefix={prefix}",
"--find-links=amrex-whl",
"amrex",
]

with working_dir(self.build_directory):
pip(*args)

# todo: from PythonPipBuilder
# ....execute_install_time_tests()

def check(self):
"""Checks after the build phase"""
pytest = which("pytest")
pytest(join_path(self.stage.source_path, self.tests_src_dir))

@run_after("install")
@run_after("pip_install_nodeps")
def copy_test_sources(self):
"""Copy the example test files after the package is installed to an
install test subdirectory for use during `spack test run`."""
Expand Down
38 changes: 30 additions & 8 deletions var/spack/repos/builtin/packages/py-picmistandard/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,47 @@ class PyPicmistandard(PythonPackage):

homepage = "https://picmi-standard.github.io"
git = "https://github.com/picmi-standard/picmi.git"
pypi = "picmistandard/picmistandard-0.26.0.tar.gz"
pypi = "picmistandard/picmistandard-0.29.0.tar.gz"

maintainers("ax3l", "dpgrote", "RemiLehe")

version("master", branch="master")
version("0.29.0", sha256="dc0bf3ddd3635df9935ac569b3085de387150c4f8e9851897078bb12d123dde8")
version("0.28.0", sha256="aa980b0fb49fc3ff9c7e32b5927b3700c4660aefbf96567bac1f8c9c93bb7831")
version("0.26.0", sha256="b22689f576d064bf0cd8f435621e912359fc2ee9347350eab845d2d36ebb62eb")
version("0.25.0", sha256="3fe6a524822d382e52bfc9d3378249546075d28620969954c5ffb43e7968fb02")
version("0.24.0", sha256="55a82adcc14b41eb612caf0d9e47b0e2a56ffc196a58b41fa0cc395c6924be9a")
version("0.23.2", sha256="2853fcfaf2f226a88bb6063ae564832b7e69965294fd652cd2ac04756fa4599a")
version("0.23.1", sha256="c7375010b7a3431b519bc0accf097f2aafdb520e2a0126f42895cb96dcc7dcf1")
version("0.0.22", sha256="e234a431274254b22cd70be64d6555b383d98426b2763ea0c174cf77bf4d0890")
version("0.0.21", sha256="930056a23ed92dac7930198f115b6248606b57403bffebce3d84579657c8d10b")
version("0.0.20", sha256="9c1822eaa2e4dd543b5afcfa97940516267dda3890695a6cf9c29565a41e2905")
version("0.0.19", sha256="4b7ba1330964fbfd515e8ea2219966957c1386e0896b92d36bd9e134afb02f5a")
version("0.0.18", sha256="68c208c0c54b4786e133bb13eef0dd4824998da4906285987ddee84e6d195e71")
version(
"0.0.22",
sha256="e234a431274254b22cd70be64d6555b383d98426b2763ea0c174cf77bf4d0890",
deprecated=True,
)
version(
"0.0.21",
sha256="930056a23ed92dac7930198f115b6248606b57403bffebce3d84579657c8d10b",
deprecated=True,
)
version(
"0.0.20",
sha256="9c1822eaa2e4dd543b5afcfa97940516267dda3890695a6cf9c29565a41e2905",
deprecated=True,
)
version(
"0.0.19",
sha256="4b7ba1330964fbfd515e8ea2219966957c1386e0896b92d36bd9e134afb02f5a",
deprecated=True,
)
version(
"0.0.18",
sha256="68c208c0c54b4786e133bb13eef0dd4824998da4906285987ddee84e6d195e71",
deprecated=True,
)

depends_on("[email protected]:", type=("build", "run"))
depends_on("[email protected]:1", type=("build", "run"))
depends_on("[email protected]:1", type=("build", "run"))
depends_on("[email protected]:", type=("build", "run"))
depends_on("[email protected]:", type=("build", "run"))
depends_on("py-setuptools", type="build")

@property
Expand Down
4 changes: 4 additions & 0 deletions var/spack/repos/builtin/packages/py-pybind11/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class PyPybind11(CMakePackage, PythonExtension):
depends_on("py-wheel", type="build")
extends("python")

# Spack defaults to False but pybind11 defaults to True (and IPO is highly
# encouraged to be used)
variant("ipo", default=True, description="CMake interprocedural optimization")

with when("build_system=cmake"):
generator("ninja")
depends_on("[email protected]:", type="build")
Expand Down
128 changes: 105 additions & 23 deletions var/spack/repos/builtin/packages/py-warpx/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@


class PyWarpx(PythonPackage):
"""WarpX is an advanced electromagnetic Particle-In-Cell code. It supports
"""This package is deprecated. Please use `warpx +python`.
WarpX is an advanced electromagnetic Particle-In-Cell code. It supports
many features including Perfectly-Matched Layers (PML) and mesh refinement.
In addition, WarpX is a highly-parallel and highly-optimized code and
features hybrid OpenMP/MPI parallelization, advanced vectorization
Expand All @@ -21,34 +23,114 @@ class PyWarpx(PythonPackage):
url = "https://github.com/ECP-WarpX/WarpX/archive/refs/tags/23.08.tar.gz"
git = "https://github.com/ECP-WarpX/WarpX.git"

maintainers("ax3l", "dpgrote", "RemiLehe")
maintainers("ax3l", "dpgrote", "EZoni", "RemiLehe")

tags = ["e4s", "ecp"]

license("BSD-3-Clause-LBNL")

# NOTE: if you update the versions here, also see warpx
version("develop", branch="development")
version("23.08", sha256="67695ff04b83d1823ea621c19488e54ebaf268532b0e5eb4ea8ad293d7ab3ddc")
version("23.07", sha256="511633f94c0d0205013609bde5bbf92a29c2e69f6e69b461b80d09dc25602945")
version("23.06", sha256="75fcac949220c44dce04de581860c9a2caa31a0eee8aa7d49455fa5fc928514b")
version("23.05", sha256="34306a98fdb1f5f44ab4fb92f35966bfccdcf1680a722aa773af2b59a3060d73")
version("23.04", sha256="e5b285c73e13a0d922eba5d83760c168d4fd388e54a519830003b2e692dab823")
version("23.03", sha256="e1274aaa2a2c83d599d61c6e4c426db4ed5d4c5dc61a2002715783a6c4843718")
version("23.02", sha256="a6c63ebc38cbd224422259a814be501ac79a3b734dab7f59500b6957cddaaac1")
version("23.01", sha256="e853d01c20ea00c8ddedfa82a31a11d9d91a7f418d37d7f064cf8a241ea4da0c")
version("22.12", sha256="96019902cd6ea444a1ae515e8853048e9074822c168021e4ec1687adc72ef062")
version("22.11", sha256="528f65958f2f9e60a094e54eede698e871ccefc89fa103fe2a6f22e4a059515e")
version("22.10", sha256="3cbbbbb4d79f806b15e81c3d0e4a4401d1d03d925154682a3060efebd3b6ca3e")
version("22.09", sha256="dbef1318248c86c860cc47f7e18bbb0397818e3acdfb459e48075004bdaedea3")
version("22.08", sha256="5ff7fd628e8bf615c1107e6c51bc55926f3ef2a076985444b889d292fecf56d4")
version("22.07", sha256="0286adc788136cb78033cb1678d38d36e42265bcfd3d0c361a9bcc2cfcdf241b")
version("22.06", sha256="e78398e215d3fc6bc5984f5d1c2ddeac290dcbc8a8e9d196e828ef6299187db9")
version("22.05", sha256="2fa69e6a4db36459b67bf663e8fbf56191f6c8c25dc76301dbd02a36f9b50479")
version("22.04", sha256="9234d12e28b323cb250d3d2cefee0b36246bd8a1d1eb48e386f41977251c028f")
version("22.03", sha256="ddbef760c8000f2f827dfb097ca3359e7aecbea8766bec5c3a91ee28d3641564")
version("22.02", sha256="d74b593d6f396e037970c5fbe10c2e5d71d557a99c97d40e4255226bc6c26e42")
version("22.01", sha256="e465ffadabb7dc360c63c4d3862dc08082b5b0e77923d3fb05570408748b0d28")
version("develop", branch="development", deprecated=True)
version(
"23.08",
sha256="67695ff04b83d1823ea621c19488e54ebaf268532b0e5eb4ea8ad293d7ab3ddc",
deprecated=True,
)
version(
"23.07",
sha256="511633f94c0d0205013609bde5bbf92a29c2e69f6e69b461b80d09dc25602945",
deprecated=True,
)
version(
"23.06",
sha256="75fcac949220c44dce04de581860c9a2caa31a0eee8aa7d49455fa5fc928514b",
deprecated=True,
)
version(
"23.05",
sha256="34306a98fdb1f5f44ab4fb92f35966bfccdcf1680a722aa773af2b59a3060d73",
deprecated=True,
)
version(
"23.04",
sha256="e5b285c73e13a0d922eba5d83760c168d4fd388e54a519830003b2e692dab823",
deprecated=True,
)
version(
"23.03",
sha256="e1274aaa2a2c83d599d61c6e4c426db4ed5d4c5dc61a2002715783a6c4843718",
deprecated=True,
)
version(
"23.02",
sha256="a6c63ebc38cbd224422259a814be501ac79a3b734dab7f59500b6957cddaaac1",
deprecated=True,
)
version(
"23.01",
sha256="e853d01c20ea00c8ddedfa82a31a11d9d91a7f418d37d7f064cf8a241ea4da0c",
deprecated=True,
)
version(
"22.12",
sha256="96019902cd6ea444a1ae515e8853048e9074822c168021e4ec1687adc72ef062",
deprecated=True,
)
version(
"22.11",
sha256="528f65958f2f9e60a094e54eede698e871ccefc89fa103fe2a6f22e4a059515e",
deprecated=True,
)
version(
"22.10",
sha256="3cbbbbb4d79f806b15e81c3d0e4a4401d1d03d925154682a3060efebd3b6ca3e",
deprecated=True,
)
version(
"22.09",
sha256="dbef1318248c86c860cc47f7e18bbb0397818e3acdfb459e48075004bdaedea3",
deprecated=True,
)
version(
"22.08",
sha256="5ff7fd628e8bf615c1107e6c51bc55926f3ef2a076985444b889d292fecf56d4",
deprecated=True,
)
version(
"22.07",
sha256="0286adc788136cb78033cb1678d38d36e42265bcfd3d0c361a9bcc2cfcdf241b",
deprecated=True,
)
version(
"22.06",
sha256="e78398e215d3fc6bc5984f5d1c2ddeac290dcbc8a8e9d196e828ef6299187db9",
deprecated=True,
)
version(
"22.05",
sha256="2fa69e6a4db36459b67bf663e8fbf56191f6c8c25dc76301dbd02a36f9b50479",
deprecated=True,
)
version(
"22.04",
sha256="9234d12e28b323cb250d3d2cefee0b36246bd8a1d1eb48e386f41977251c028f",
deprecated=True,
)
version(
"22.03",
sha256="ddbef760c8000f2f827dfb097ca3359e7aecbea8766bec5c3a91ee28d3641564",
deprecated=True,
)
version(
"22.02",
sha256="d74b593d6f396e037970c5fbe10c2e5d71d557a99c97d40e4255226bc6c26e42",
deprecated=True,
)
version(
"22.01",
sha256="e465ffadabb7dc360c63c4d3862dc08082b5b0e77923d3fb05570408748b0d28",
deprecated=True,
)

depends_on("cxx", type="build") # generated

Expand Down
Loading

0 comments on commit 01ea687

Please sign in to comment.