From 65cf00abf224af4487c542d4997f73711c19ccaa Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 2 Dec 2026 11:03:49 -0800 Subject: [PATCH 1/9] Test VecGeom 2.3 in CI and move Docker job to ghcr - Add a spack-based build-spack workflow testing VecGeom 2.3 (pinned wip/gpu-portability commit, overridable via workflow_dispatch) against Geant4 10.5 and 11.4, plus VecGeom 1.2.11 against Geant4 11.3. The spack setup is adapted from Celeritas so that Geant4 is pulled from the Celeritas spack buildcache. - Move the Docker job to ghcr.io/celeritas-project/ci-cuda:2026-11-12 (VecGeom 2.2 +cuda, CUDA 13) and build for sm_80. Co-Authored-By: Claude Opus 5.5 --- .github/actions/setup-spack/action.yml | 187 ++++++++++++++++++ .github/workflows/build-full.yml | 23 ++- .github/workflows/build-spack.yml | 136 +++++++++++++ .github/workflows/pr.yml | 7 +- .github/workflows/push.yml | 4 +- CMakePresets.json | 8 + scripts/ci/setup-spack-ci-env.sh | 99 ++++++++++ ...ci-rocky-cuda.json => ci-ubuntu-cuda.json} | 5 +- scripts/cmake-presets/ci-ubuntu-github.json | 63 ++++++ scripts/spack/env-ci-base.yaml | 26 +++ scripts/spack/ext-ubuntu24.yaml | 60 ++++++ scripts/spack/prefs-build.yaml | 25 +++ scripts/spack/reqs-ci.yaml | 54 +++++ 13 files changed, 682 insertions(+), 15 deletions(-) create mode 100644 .github/actions/setup-spack/action.yml create mode 100644 .github/workflows/build-spack.yml create mode 100755 scripts/ci/setup-spack-ci-env.sh rename scripts/cmake-presets/{ci-rocky-cuda.json => ci-ubuntu-cuda.json} (90%) create mode 100644 scripts/cmake-presets/ci-ubuntu-github.json create mode 100644 scripts/spack/env-ci-base.yaml create mode 100644 scripts/spack/ext-ubuntu24.yaml create mode 100644 scripts/spack/prefs-build.yaml create mode 100644 scripts/spack/reqs-ci.yaml diff --git a/.github/actions/setup-spack/action.yml b/.github/actions/setup-spack/action.yml new file mode 100644 index 0000000..f078da3 --- /dev/null +++ b/.github/actions/setup-spack/action.yml @@ -0,0 +1,187 @@ +#-------------------------------- -*- yaml -*- ---------------------------------# +# Bootstrap a Spack environment, install dependencies, and activate it. +# +# Adapted from Celeritas .github/actions/setup-spack: the spack and +# spack-packages commits and the scripts/spack config files must match the +# Celeritas ones so that dependencies are pulled from the Celeritas spack +# buildcache (ghcr.io/celeritas-project/spack-buildcache). Unlike Celeritas, +# G4VG never pushes to the buildcache. +#-----------------------------------------------------------------------------# + +name: "Set up Spack environment" +description: "Check out Spack, concretize/install deps, and activate the view" +inputs: + cxxstd: + description: "C++ standard to concretize Spack with" + required: true + env-file: + description: "Base environment file to use (optionally relative to scripts/spack/)" + required: false + add: + description: "Space-separated list of additional spack packages to add" + required: false + default: "" + +runs: + using: "composite" + steps: + - name: Set environment and local variables + id: vars + shell: sh + run: | + SPACK_ROOT=$GITHUB_WORKSPACE/spack-src + { + echo "G4VG_SPACK_ENV=$GITHUB_WORKSPACE/spack-env" + echo "G4VG_SPACK_VIEW=/opt/view" + # Used by spack + echo "SPACK_COLOR=always" + echo "SPACK_DISABLE_LOCAL_CONFIG=1" + echo "SPACK_ROOT=$SPACK_ROOT" + } >> "$GITHUB_ENV" + echo "SPACK_PACKAGES_ROOT=$GITHUB_WORKSPACE/spack-pkg" >> "$GITHUB_OUTPUT" + echo "$SPACK_ROOT/bin" >> "$GITHUB_PATH" + # NOTE: keep these refs in sync with Celeritas to reuse its buildcache + - name: Checkout Spack + uses: actions/checkout@v7 + with: + repository: spack/spack + path: ${{env.SPACK_ROOT}} + ref: 307d3b0a68316341401d311c1ef6442ed2f13868 # upstream/develop, 12 September 2026 + - name: Checkout Spack packages + uses: actions/checkout@v7 + with: + repository: spack/spack-packages + path: ${{steps.vars.outputs.SPACK_PACKAGES_ROOT}} + ref: fa11df3be41f58bac19b73346422e06b103ee5b5 # upstream/develop, 6 October 2026 + + - name: Initialize spack environment + id: init + shell: sh + env: + CXXSTD: ${{inputs.cxxstd}} + SPACK_ENV_FILE: ${{inputs.env-file}} + G4VG_SOURCE_DIR: "${{github.workspace}}" + G4VG_SPACK_OPT: "/opt/spack" + SPACK_PACKAGES_ROOT: "${{steps.vars.outputs.SPACK_PACKAGES_ROOT}}" + run: | + mkdir -p "$G4VG_SPACK_ENV" + cd "$G4VG_SPACK_ENV" + "${G4VG_SOURCE_DIR}/scripts/ci/setup-spack-ci-env.sh" ${{inputs.add}} + + # Prefix padding is only needed when pushing to a buildcache + spack -e . config add "config:install_tree:padded_length:False" + + # Dump config file, which encodes the full spack environment settings + { + spack -e . config get --json | jq -c '.["spack"]' + printf '{"repos": {"core": "%s", "builtin": "%s"}}\n' \ + "$(git -C "$SPACK_ROOT" rev-parse HEAD)" \ + "$(git -C "$SPACK_PACKAGES_ROOT" rev-parse HEAD)" + } > spack.config.jsonl + + { + echo "config-hash=$(sha256sum spack.config.jsonl | cut -d' ' -f1)" + echo "stage-dir=$(spack -e . location -S)" + } >> "$GITHUB_OUTPUT" + - name: Dump spack config blame + if: ${{runner.debug}} + shell: sh + working-directory: ${{env.G4VG_SPACK_ENV}} + run: | + spack -e . config blame + + - name: Restore cached lockfile + id: restore + uses: actions/cache/restore@v6 + with: + path: ${{env.G4VG_SPACK_ENV}}/spack.lock + key: lock-${{steps.init.outputs.config-hash}}-${{github.run_id}} + restore-keys: lock-${{steps.init.outputs.config-hash}} + - name: Concretize + if: ${{ !steps.restore.outputs.cache-matched-key }} + id: concretize + shell: sh + working-directory: ${{env.G4VG_SPACK_ENV}} + run: | + echo "::group::Bootstrapping spack" + spack bootstrap now + echo "::endgroup::" + echo "Using mirrors:" + spack -e . mirror list + echo "::group::Available buildcache that explicitly uses cxxstd=$CXXSTD" + spack -e . buildcache list -a -l cxxstd=$CXXSTD || true + echo "::endgroup::" + # NOTE: unlike Celeritas, *don't* use --fresh, so that matching specs + # in the Celeritas buildcache are reused + spack -e . -v concretize + env: + CXXSTD: ${{inputs.cxxstd}} + - name: Cache lockfile + if: ${{ steps.concretize.outcome == 'success' }} + uses: actions/cache/save@v6 + with: + path: ${{env.G4VG_SPACK_ENV}}/spack.lock + key: lock-${{steps.init.outputs.config-hash}}-${{github.run_id}} + - name: Install dependencies + id: install + shell: sh + working-directory: ${{env.G4VG_SPACK_ENV}} + run: | + spack ${{runner.debug && '-vd' || ''}} -e . \ + install -p 8 --use-buildcache=auto + - name: Upload spack config+lockfile on new concretization or failures + if: >- + ${{ !cancelled() + && (!steps.restore.outputs.cache-matched-key + || steps.concretize.outcome == 'failure' + || steps.install.outcome == 'failure') + }} + uses: actions/upload-artifact@v7 + with: + name: >- + ${{format( + 'spack-{0}-{1}-{2}', + steps.init.outputs.config-hash, + github.job || 'action', + strategy.job-index || 0 + )}} + path: "${{env.G4VG_SPACK_ENV}}/spack.*" + retention-days: 1 + - name: Upload logs only if install failed + if: ${{ !cancelled() && steps.install.outcome == 'failure' }} + uses: actions/upload-artifact@v7 + with: + name: >- + ${{format( + 'spack-logs-{0}-{1}-{2}', + steps.init.outputs.config-hash, + github.job || 'action', + strategy.job-index || 0 + )}} + path: "${{steps.init.outputs.stage-dir}}/*.log" + - name: List installed dependencies + if: ${{ !cancelled() }} + shell: sh + working-directory: ${{env.G4VG_SPACK_ENV}} + run: | + echo "::group::Local and concretized" + spack -e . find -lv -c + echo "::endgroup::" + { + echo '```' + spack -e . find -v + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + + - name: Update environment and create rc file + shell: sh + # NOTE: the env transformation might be sensitive to spack version changes + run: | + echo "$G4VG_SPACK_VIEW/bin" >> "$GITHUB_PATH" + spack env activate --sh "$G4VG_SPACK_ENV" > "${G4VG_SPACK_VIEW}/rc" + grep '^export ' "${G4VG_SPACK_VIEW}/rc" \ + | grep -v '^export PATH=' \ + | sed 's/^export \(.*\);\s*$/\1/' >> "$GITHUB_ENV" + echo "::group::Dump ${G4VG_SPACK_VIEW}/rc" + cat "${G4VG_SPACK_VIEW}/rc" + echo "::endgroup::" diff --git a/.github/workflows/build-full.yml b/.github/workflows/build-full.yml index fb99cf5..f0c3528 100644 --- a/.github/workflows/build-full.yml +++ b/.github/workflows/build-full.yml @@ -8,26 +8,27 @@ concurrency: cancel-in-progress: true jobs: - # TODO: this currently includes non-GPU builds as well - # and won't actually run on device - # TODO: need to add vecgeom~shared for testing + # NOTE: the container has a CUDA-enabled VecGeom but GitHub runners have no + # GPU, so tests run on host only gpu: - name: gpu + name: gpu-${{matrix.buildtype}}-${{matrix.image}} strategy: fail-fast: false matrix: special: [null] buildtype: ['debug', 'ndebug'] - image: ['rocky-cuda'] + image: ['ubuntu-cuda'] env: CELER_DISABLE_DEVICE: 1 # IMPORTANT CMAKE_PRESET: >- ${{matrix.buildtype}}${{matrix.special && '-' || ''}}${{matrix.special}} - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: + # Celeritas CI image: see celeritas scripts/spack/env-docker-cuda.yaml + # (Ubuntu 24.04, CUDA 13, VecGeom 2.2 +cuda cuda_arch=80, Geant4 11.3) image: >- - docker.io/celeritas/${{ - matrix.image == 'rocky-cuda' && 'ci-rocky-cuda12:2024-12-29' + ghcr.io/celeritas-project/${{ + matrix.image == 'ubuntu-cuda' && 'ci-cuda:2026-11-12' || null }} steps: @@ -36,12 +37,14 @@ jobs: . /etc/profile echo "/opt/view/bin" >> $GITHUB_PATH echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV + # NOTE: checkout must occur *after* setting up environment for git tags to work - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v7 + with: + fetch-depth: 0 - name: Configure run: | git config --global --add safe.directory ${PWD} - git fetch --tags ln -fs scripts/cmake-presets/ci-${{matrix.image}}.json CMakeUserPresets.json cmake --preset=${CMAKE_PRESET} --log-level=VERBOSE - name: Build diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml new file mode 100644 index 0000000..cf911ab --- /dev/null +++ b/.github/workflows/build-spack.yml @@ -0,0 +1,136 @@ +#-------------------------------- -*- yaml -*- ---------------------------------# +# Build and test G4VG against spack-installed Geant4 and VecGeom versions. +# +# Geant4 (and VecGeom releases) are pulled from the Celeritas spack buildcache; +# the unreleased VecGeom 2.3 is built from source at a pinned commit of the +# `wip/gpu-portability` branch (VecGeom MR 1689). Once VecGeom 2.3.0 is released +# and in spack-packages, replace the commit with `vecgeom@2.3`. +#-----------------------------------------------------------------------------# + +name: build-spack +on: + workflow_dispatch: + inputs: + vecgeom-commit: + description: >- + VecGeom 2.3 commit SHA, or 'latest' for the head of wip/gpu-portability + (default: the pinned commit) + type: string + required: false + default: "" + workflow_call: + inputs: + vecgeom-commit: + type: string + required: false + default: "" + +concurrency: + group: build-spack-${{github.event.pull_request.number || github.ref_name}}-${{github.workflow}} + cancel-in-progress: true + +env: + # Pinned VecGeom 2.3 development commit (wip/gpu-portability, 1 December 2026) + VECGEOM_2_3_COMMIT: 9cb15a8a6c776df385357688260567f1e714a434 + VECGEOM_2_3_BRANCH: wip/gpu-portability + +jobs: + spack: + name: vecgeom@${{matrix.vecgeom}}-g4@${{matrix.geant}} + strategy: + fail-fast: false + matrix: + include: + # Oldest and newest Geant4 supported by Celeritas against VecGeom 2.3 + - vecgeom: "2.3" + geant: "10.5" + cxxstd: 17 + - vecgeom: "2.3" + geant: "11.4" + cxxstd: 20 + # VecGeom 1.x compatibility (same specs as Celeritas 'vecgeom1' job) + - vecgeom: "1.2.11" + geant: "11.3" + cxxstd: 20 + env: + CMAKE_PRESET: debug + CC: "clang-18" + CXX: "clang++-18" + CXXSTD: ${{matrix.cxxstd}} + runs-on: ubuntu-24.04 + steps: + - name: Check out G4VG + uses: actions/checkout@v7 + with: + fetch-depth: 0 # G4VG version is derived from git tags + + - name: Select VecGeom spec + id: vecgeom + shell: bash + env: + VECGEOM_VERSION: ${{matrix.vecgeom}} + VECGEOM_INPUT: ${{inputs.vecgeom-commit}} + run: | + if [[ "$VECGEOM_VERSION" != "2.3" ]]; then + echo "spec=vecgeom@${VECGEOM_VERSION}~cuda" >> "$GITHUB_OUTPUT" + exit 0 + fi + vecgeom_sha="${VECGEOM_INPUT:-$VECGEOM_2_3_COMMIT}" + if [[ "$vecgeom_sha" == "latest" ]]; then + vecgeom_sha=$(git ls-remote --exit-code \ + https://gitlab.cern.ch/VecGeom/VecGeom.git \ + "refs/heads/${VECGEOM_2_3_BRANCH}" | cut -f1) + fi + printf "VecGeom: %s -> %s\n" "${VECGEOM_INPUT:-pinned}" "$vecgeom_sha" + if [[ ! "$vecgeom_sha" =~ ^[0-9a-f]{40}$ ]]; then + echo "::error::VecGeom revision must resolve to a full commit SHA" + exit 1 + fi + printf 'VecGeom: [%s](https://gitlab.cern.ch/VecGeom/VecGeom/-/commit/%s)\n' \ + "$vecgeom_sha" "$vecgeom_sha" >> "$GITHUB_STEP_SUMMARY" + # NOTE: '=master' gives the git commit a version for spack's + # dependency resolution; VecGeom's own CMake reports 2.3.0 + echo "spec=vecgeom@${vecgeom_sha}=master~cuda~surface" >> "$GITHUB_OUTPUT" + + - name: Set up Spack environment + uses: ./.github/actions/setup-spack + with: + cxxstd: ${{env.CXXSTD}} + add: >- + geant4@${{matrix.geant}} + ${{steps.vecgeom.outputs.spec}} + + - name: Configure + run: | + cp scripts/cmake-presets/ci-ubuntu-github.json CMakeUserPresets.json + cmake --preset=${CMAKE_PRESET} --log-level=VERBOSE + - name: Check VecGeom version + shell: bash + run: | + grep -h 'define G4VG_VECGEOM_VERSION' $(find build -name G4VGVersion.hh) \ + | tee -a "$GITHUB_STEP_SUMMARY" + - name: Build + run: | + cmake --build --preset=${CMAKE_PRESET} + - name: Test + run: | + ctest --preset=${CMAKE_PRESET} + - name: Install + run: | + cmake --install build + + - name: Upload diagnostics on failure + if: ${{ failure() }} + uses: actions/upload-artifact@v7 + with: + name: diagnostics-vecgeom@${{matrix.vecgeom}}-g4@${{matrix.geant}} + path: | + spack-env/spack.yaml + spack-env/spack.lock + build/CMakeCache.txt + build/CMakeFiles/CMakeConfigureLog.yaml + build/Testing/Temporary/LastTest.log + if-no-files-found: ignore + retention-days: 3 + +# vim: set nowrap tw=100: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 388ecc0..590f677 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -17,14 +17,17 @@ concurrency: cancel-in-progress: true jobs: - build: + build-full: uses: ./.github/workflows/build-full.yml + build-spack: + uses: ./.github/workflows/build-spack.yml # Specifying a dependent job allows us to select a single "requires" check in the project GitHub settings all: if: ${{ always() }} needs: - - build + - build-full + - build-spack runs-on: ubuntu-latest steps: - name: Decide whether the needed jobs succeeded or failed diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 149bab2..49e3338 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -12,8 +12,10 @@ concurrency: jobs: build-full: uses: ./.github/workflows/build-full.yml + build-spack: + uses: ./.github/workflows/build-spack.yml all: - needs: [build-full] + needs: [build-full, build-spack] runs-on: ubuntu-latest steps: - name: Success diff --git a/CMakePresets.json b/CMakePresets.json index a7abe00..e44bc89 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -21,6 +21,14 @@ "CMAKE_CUDA_ARCHITECTURES": {"type": "STRING", "value": "70"} } }, + { + "name": ".cuda-ampere", + "hidden": true, + "description": "Options to enable CUDA on Ampere (A100) architecture", + "cacheVariables": { + "CMAKE_CUDA_ARCHITECTURES": {"type": "STRING", "value": "80"} + } + }, { "name": ".ndebug", "hidden": true, diff --git a/scripts/ci/setup-spack-ci-env.sh b/scripts/ci/setup-spack-ci-env.sh new file mode 100755 index 0000000..94e503e --- /dev/null +++ b/scripts/ci/setup-spack-ci-env.sh @@ -0,0 +1,99 @@ +#!/bin/sh +#-------------------------------- -*- sh -*- ---------------------------------# +# Create a spack environment in the current directory for use in CI. +# Adapted from Celeritas scripts/ci/setup-spack-ci-env.sh: see +# :/.github/actions/setup-spack/action.yml +# +# Environment variables: +# - SPACK_ENV_FILE: base environment (default: env-ci-base.yaml, relative to +# ${G4VG_SOURCE_DIR}/scripts/spack) +# - SPACK_PACKAGES_ROOT: checkout of spack-packages to use as builtin repo +# - G4VG_SPACK_OPT: spack install tree root +# - G4VG_SPACK_VIEW: spack view directory +# - CXXSTD: preferred C++ standard +# +# Arguments are additional specs to add to the environment. +#-----------------------------------------------------------------------------# + +set -e +log() { + printf "%s: %s\n" "$1" "$2" >&2 +} + +SPACK=$(command -v spack 2>/dev/null || printf "") + +if [ -z "$SPACK" ]; then + log error "spack not found" + exit 1 +fi + +if [ -n "$SPACK_ENV" ]; then + log error "another spack environment is active: run despacktivate first" + exit 1 +fi + +if [ -z "$SPACK_ENV_FILE" ]; then + SPACK_ENV_FILE="env-ci-base.yaml" + log info "Using default SPACK_ENV_FILE: env-ci-base.yaml" +fi +if ! [ -e "${SPACK_ENV_FILE}" ]; then + if [ -z "$G4VG_SOURCE_DIR" ]; then + log error "Missing G4VG_SOURCE_DIR" + exit 1 + fi + SPACK_ENV_FILE="${G4VG_SOURCE_DIR}/scripts/spack/${SPACK_ENV_FILE}" +fi +if ! [ -f "${SPACK_ENV_FILE}" ]; then + log error "Environment file ${SPACK_ENV_FILE} does not exist" + exit 1 +fi + +# Configure separate packages repository *first*: otherwise the +# environment creation will do a lengthy unnecessary checkout +if [ -n "${SPACK_PACKAGES_ROOT}" ]; then + log info "Using custom builtin spack package repo: ${SPACK_PACKAGES_ROOT}" + $SPACK repo set --destination "${SPACK_PACKAGES_ROOT}" builtin +else + SPACK_PACKAGES_ROOT=$(spack location -P builtin) + log warning "Using default builtin spack repo: ${SPACK_PACKAGES_ROOT}" +fi + +# Create environment in current working directory +log status "Creating environment from ${SPACK_ENV_FILE}" +$SPACK env create . "${SPACK_ENV_FILE}" + +# Configure install prefix +if [ -n "${G4VG_SPACK_OPT}" ]; then + log info "Setting spack install prefix to ${G4VG_SPACK_OPT}" + $SPACK -e . config add "config:install_tree:root:${G4VG_SPACK_OPT}" +else + log warning "Omitting spack install prefix: G4VG_SPACK_OPT is not set" +fi + +# Configure view +if [ -n "${G4VG_SPACK_VIEW}" ]; then + log info "Setting spack view to ${G4VG_SPACK_VIEW}" +else + log warning "Omitting spack view: G4VG_SPACK_VIEW is not set" + G4VG_SPACK_VIEW=false +fi +$SPACK -e . config add "view:${G4VG_SPACK_VIEW}" + +# Configure C++ standard +if [ -n "${CXXSTD}" ]; then + log info "Setting cxxstd preference to ${CXXSTD}" + $SPACK -e . config add "packages:all:prefer:[cxxstd=${CXXSTD}]" +else + log warning "no cxxstd preference: CXXSTD not set" +fi + +if [ $# -ne 0 ] ; then + log info "Adding additional packages: $*" + $SPACK -e . add "$@" +fi + +# Add the spack ref so that updating spack will reconcretize +cat >> spack.yaml < Date: Wed, 2 Dec 2026 11:22:31 -0800 Subject: [PATCH 2/9] Avoid C++20 designated initializers in tests G4VG supports C++17 (required for Geant4 10.5), where designated initializers are a -pedantic error under clang. Co-Authored-By: Claude Opus 5.5 --- test/Custom.test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/Custom.test.cc b/test/Custom.test.cc index a6c8dac..839180e 100644 --- a/test/Custom.test.cc +++ b/test/Custom.test.cc @@ -176,8 +176,9 @@ G4VPhysicalVolume* TessellatedSolidTest::build_world() TEST_F(TessellatedSolidTest, absolute_vertices_are_preserved) { - auto converted - = g4vg::convert(this->g4world(), Options{.append_pointers = false}); + Options opts; + opts.append_pointers = false; + auto converted = g4vg::convert(this->g4world(), opts); ASSERT_TRUE(converted.world); auto& vg_manager = vecgeom::GeoManager::Instance(); @@ -387,7 +388,9 @@ G4VPhysicalVolume* NestedReplicaParametrizationTest::build_world() TEST_F(NestedReplicaParametrizationTest, default_options) { - auto result = this->run(Options{.verbose = true}); + Options opts; + opts.verbose = true; + auto result = this->run(opts); TestResult ref; ref.lv_name = { From b114966ab9957c6e641f5a8ad679eee431883da3 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 2 Dec 2026 11:29:56 -0800 Subject: [PATCH 3/9] Fix division volume multiplicity before Geant4 10.6 G4PVDivision only overrides GetMultiplicity since Geant4 10.6: before that the base class returns 1, so only one copy of each division was placed. Use the number of replicas from the replication data instead. Found by the new Geant4 10.5 CI job (ZnenvTest.default_options). Co-Authored-By: Claude Opus 5.5 --- src/g4vg_impl/Converter.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/g4vg_impl/Converter.cc b/src/g4vg_impl/Converter.cc index 38f17df..92a1bbe 100644 --- a/src/g4vg_impl/Converter.cc +++ b/src/g4vg_impl/Converter.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,27 @@ namespace g4vg { namespace { +//---------------------------------------------------------------------------// +//! Get the number of copies of a replicated or parameterised volume +int get_multiplicity(G4VPhysicalVolume const& pv) +{ +#if G4VERSION_NUMBER < 1060 + // Before Geant4 10.6, G4PVDivision doesn't override GetMultiplicity + // (which then returns 1): use the number of replicas instead + if (pv.IsReplicated()) + { + EAxis axis; + G4int num_replicas{0}; + G4double width; + G4double offset; + G4bool consuming; + pv.GetReplicationData(axis, num_replicas, width, offset, consuming); + return num_replicas; + } +#endif + return pv.GetMultiplicity(); +} + //---------------------------------------------------------------------------// //! Get the underlying volume if one exists (const-correct) G4LogicalVolume const* get_constituent_lv(G4LogicalVolume const& lv) @@ -176,7 +198,7 @@ class DaughterPlacer template void operator()(G4VPhysicalVolume* g4pv, F&& update_pv) const { - for (int j = 0, jmax = g4pv->GetMultiplicity(); j < jmax; ++j) + for (int j = 0, jmax = get_multiplicity(*g4pv); j < jmax; ++j) { // Modify the volume's position and place the copy update_pv(j, g4pv); From 78ce2f4c354400185ddbaf7af7137e8f966c1b23 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 2 Dec 2026 11:43:24 -0800 Subject: [PATCH 4/9] Restore Celeritas copyright in adapted CI files Co-Authored-By: Claude Opus 5.5 --- .github/actions/setup-spack/action.yml | 3 +++ scripts/ci/setup-spack-ci-env.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/actions/setup-spack/action.yml b/.github/actions/setup-spack/action.yml index f078da3..04892fd 100644 --- a/.github/actions/setup-spack/action.yml +++ b/.github/actions/setup-spack/action.yml @@ -1,4 +1,7 @@ #-------------------------------- -*- yaml -*- ---------------------------------# +# Copyright Celeritas contributors: see top-level COPYRIGHT file for details +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +#-----------------------------------------------------------------------------# # Bootstrap a Spack environment, install dependencies, and activate it. # # Adapted from Celeritas .github/actions/setup-spack: the spack and diff --git a/scripts/ci/setup-spack-ci-env.sh b/scripts/ci/setup-spack-ci-env.sh index 94e503e..87619f6 100755 --- a/scripts/ci/setup-spack-ci-env.sh +++ b/scripts/ci/setup-spack-ci-env.sh @@ -1,5 +1,8 @@ #!/bin/sh #-------------------------------- -*- sh -*- ---------------------------------# +# Copyright Celeritas contributors: see top-level COPYRIGHT file for details +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +#-----------------------------------------------------------------------------# # Create a spack environment in the current directory for use in CI. # Adapted from Celeritas scripts/ci/setup-spack-ci-env.sh: see # :/.github/actions/setup-spack/action.yml From 01bc3b31cffb06b05881728308a888a10681d671 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 2 Dec 2026 12:13:38 -0800 Subject: [PATCH 5/9] Add ROCm CI job building VecGeom 2.3 with HIP The Celeritas ci-rocm image has no VecGeom, so build the pinned VecGeom 2.3 development commit with VECGEOM_ENABLE_HIP (gfx90a, ROCm clang++) in the job and cache the installation. G4VG is built with the ROCm clang++ against it; VecGeom's config loads its HIP-capable CudaRdcUtils (v15). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build-full.yml | 71 +++++++++++++++++++++-- .github/workflows/build-spack.yml | 1 + scripts/cmake-presets/ci-ubuntu-rocm.json | 64 ++++++++++++++++++++ 3 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 scripts/cmake-presets/ci-ubuntu-rocm.json diff --git a/.github/workflows/build-full.yml b/.github/workflows/build-full.yml index f0c3528..6bb70a2 100644 --- a/.github/workflows/build-full.yml +++ b/.github/workflows/build-full.yml @@ -7,9 +7,17 @@ concurrency: group: build-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}-${{github.workflow}} cancel-in-progress: true +env: + # VecGeom 2.3 development commit built with HIP for the ROCm image. + # Keep in sync with VECGEOM_2_3_COMMIT in build-spack.yml. + VECGEOM_2_3_COMMIT: 9cb15a8a6c776df385357688260567f1e714a434 + VECGEOM_PREFIX: /opt/vecgeom + # Keep in sync with the image tags below + CI_IMAGE_DATE: 2026-11-12 + jobs: - # NOTE: the container has a CUDA-enabled VecGeom but GitHub runners have no - # GPU, so tests run on host only + # NOTE: the containers have GPU toolchains but GitHub runners have no GPU, + # so tests run on host only gpu: name: gpu-${{matrix.buildtype}}-${{matrix.image}} strategy: @@ -17,18 +25,20 @@ jobs: matrix: special: [null] buildtype: ['debug', 'ndebug'] - image: ['ubuntu-cuda'] + image: ['ubuntu-cuda', 'ubuntu-rocm'] env: CELER_DISABLE_DEVICE: 1 # IMPORTANT CMAKE_PRESET: >- ${{matrix.buildtype}}${{matrix.special && '-' || ''}}${{matrix.special}} runs-on: ubuntu-24.04 container: - # Celeritas CI image: see celeritas scripts/spack/env-docker-cuda.yaml - # (Ubuntu 24.04, CUDA 13, VecGeom 2.2 +cuda cuda_arch=80, Geant4 11.3) + # Celeritas CI images: see celeritas scripts/spack/env-docker-{cuda,rocm}.yaml + # - ci-cuda: Ubuntu 24.04, CUDA 13, VecGeom 2.2 +cuda cuda_arch=80, Geant4 11.3 + # - ci-rocm: Ubuntu 24.04, ROCm 7.2, Geant4 11.3, *no* VecGeom (built below) image: >- ghcr.io/celeritas-project/${{ matrix.image == 'ubuntu-cuda' && 'ci-cuda:2026-11-12' + || matrix.image == 'ubuntu-rocm' && 'ci-rocm:2026-11-12' || null }} steps: @@ -42,11 +52,62 @@ jobs: uses: actions/checkout@v7 with: fetch-depth: 0 + + ### VecGeom 2.3 with HIP (ROCm image only) ### + + - name: Restore VecGeom HIP installation + if: ${{matrix.image == 'ubuntu-rocm'}} + id: vecgeom-cache + uses: actions/cache@v6 + with: + path: ${{env.VECGEOM_PREFIX}} + key: vecgeom-hip-gfx90a-${{env.VECGEOM_2_3_COMMIT}}-ci-rocm-${{env.CI_IMAGE_DATE}} + - name: Build VecGeom with HIP + if: >- + ${{ matrix.image == 'ubuntu-rocm' + && steps.vecgeom-cache.outputs.cache-hit != 'true' }} + working-directory: /tmp + run: | + git clone --filter=blob:none --no-checkout \ + https://gitlab.cern.ch/VecGeom/VecGeom.git vecgeom-src + git -C vecgeom-src checkout --detach "${VECGEOM_2_3_COMMIT}" + cmake -S vecgeom-src -B vecgeom-build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="${VECGEOM_PREFIX}" \ + -DCMAKE_PREFIX_PATH=/opt/rocm \ + -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \ + -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ + -DCMAKE_HIP_ARCHITECTURES=gfx90a \ + -DCMAKE_CXX_STANDARD=17 \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_TESTING=OFF \ + -DVECGEOM_ENABLE_HIP=ON \ + -DVECGEOM_BUILTIN_VECCORE=ON \ + -DVECGEOM_GDML=ON + cmake --build vecgeom-build -j4 + cmake --install vecgeom-build + - name: Add VecGeom to environment + if: ${{matrix.image == 'ubuntu-rocm'}} + run: | + echo "CMAKE_PREFIX_PATH=${VECGEOM_PREFIX}:/opt/rocm:${CMAKE_PREFIX_PATH}" >> $GITHUB_ENV + { + printf 'VecGeom: [%s](https://gitlab.cern.ch/VecGeom/VecGeom/-/commit/%s) (HIP, %s)\n' \ + "${VECGEOM_2_3_COMMIT}" "${VECGEOM_2_3_COMMIT}" \ + "${{steps.vecgeom-cache.outputs.cache-hit == 'true' && 'cached' || 'built'}}" + } >> $GITHUB_STEP_SUMMARY + + ### G4VG ### + - name: Configure run: | git config --global --add safe.directory ${PWD} ln -fs scripts/cmake-presets/ci-${{matrix.image}}.json CMakeUserPresets.json cmake --preset=${CMAKE_PRESET} --log-level=VERBOSE + - name: Check VecGeom version + shell: bash + run: | + grep -h 'define G4VG_VECGEOM_VERSION' $(find build -name G4VGVersion.hh) \ + | tee -a "$GITHUB_STEP_SUMMARY" - name: Build working-directory: build run: | diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index cf911ab..f146132 100644 --- a/.github/workflows/build-spack.yml +++ b/.github/workflows/build-spack.yml @@ -31,6 +31,7 @@ concurrency: env: # Pinned VecGeom 2.3 development commit (wip/gpu-portability, 1 December 2026) + # Keep in sync with VECGEOM_2_3_COMMIT in build-full.yml (ROCm job) VECGEOM_2_3_COMMIT: 9cb15a8a6c776df385357688260567f1e714a434 VECGEOM_2_3_BRANCH: wip/gpu-portability diff --git a/scripts/cmake-presets/ci-ubuntu-rocm.json b/scripts/cmake-presets/ci-ubuntu-rocm.json new file mode 100644 index 0000000..32f38ef --- /dev/null +++ b/scripts/cmake-presets/ci-ubuntu-rocm.json @@ -0,0 +1,64 @@ +{ + "version": 6, + "cmakeMinimumRequired": {"major": 3, "minor": 24, "patch": 0}, + "configurePresets": [ + { + "name": "base", + "displayName": "Ubuntu 24/rocm-docker default options for ROCm clang", + "description": "VecGeom is built with HIP in the CI job (see build-full.yml)", + "inherits": ["default"], + "binaryDir": "${sourceDir}/build", + "generator": "Ninja", + "cacheVariables": { + "BUILD_SHARED_LIBS": {"type": "BOOL", "value": "ON"}, + "G4VG_BUILD_TESTS": {"type": "BOOL", "value": "ON"}, + "CMAKE_CXX_COMPILER": "/opt/rocm/llvm/bin/clang++", + "CMAKE_CXX_STANDARD": "17", + "CMAKE_CXX_EXTENSIONS": {"type": "BOOL", "value": "OFF"}, + "CMAKE_CXX_FLAGS": "-Wall -Wextra -pedantic -Werror -Wno-error=deprecated-declarations", + "CMAKE_EXE_LINKER_FLAGS": "-Wno-unused-command-line-argument", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/install" + } + }, + { + "name": "debug", + "description": "Debug build with G4VG assertions", + "inherits": [".debug", "base"] + }, + { + "name": "ndebug", + "description": "Release build without assertions", + "inherits": [".ndebug", "base"] + } + ], + "buildPresets": [ + { + "name": "base", + "configurePreset": "base", + "nativeToolOptions": ["-k0"], + "verbose": true, + "jobs": 4 + }, + {"name": "debug" , "configurePreset": "debug" , "inherits": "base"}, + {"name": "ndebug", "configurePreset": "ndebug", "inherits": "base"} + ], + "testPresets": [ + { + "name": "base", + "configurePreset": "base", + "execution": { + "noTestsAction": "error", + "stopOnFailure": false, + "jobs": 4, + "timeout": 180 + }, + "output": { + "maxFailedTestOutputSize": 1048576, + "maxPassedTestOutputSize": 65536, + "outputOnFailure": true + } + }, + {"name": "debug" , "configurePreset": "debug" , "inherits": "base"}, + {"name": "ndebug", "configurePreset": "ndebug", "inherits": "base"} + ] +} From 747a81be073c29761d6876f89f2c511a15728d5d Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 2 Dec 2026 12:19:58 -0800 Subject: [PATCH 6/9] Build VecGeom HIP as static libraries Linking the shared libvecgeom.so with HIP device code fails with ROCm 7.2 (undefined hidden __hip_gpubin_handle_* symbols). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build-full.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-full.yml b/.github/workflows/build-full.yml index 6bb70a2..9e64bc5 100644 --- a/.github/workflows/build-full.yml +++ b/.github/workflows/build-full.yml @@ -61,7 +61,9 @@ jobs: uses: actions/cache@v6 with: path: ${{env.VECGEOM_PREFIX}} - key: vecgeom-hip-gfx90a-${{env.VECGEOM_2_3_COMMIT}}-ci-rocm-${{env.CI_IMAGE_DATE}} + key: vecgeom-hip-static-gfx90a-${{env.VECGEOM_2_3_COMMIT}}-ci-rocm-${{env.CI_IMAGE_DATE}} + # NOTE: static, since linking the shared libvecgeom.so with HIP device + # code fails with ROCm 7.2 (undefined hidden __hip_gpubin_handle_*) - name: Build VecGeom with HIP if: >- ${{ matrix.image == 'ubuntu-rocm' @@ -79,7 +81,7 @@ jobs: -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ -DCMAKE_HIP_ARCHITECTURES=gfx90a \ -DCMAKE_CXX_STANDARD=17 \ - -DBUILD_SHARED_LIBS=ON \ + -DBUILD_SHARED_LIBS=OFF \ -DBUILD_TESTING=OFF \ -DVECGEOM_ENABLE_HIP=ON \ -DVECGEOM_BUILTIN_VECCORE=ON \ From 990e2a1e1b974520ea826aa7487d14eda08683fc Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 2 Dec 2026 12:27:56 -0800 Subject: [PATCH 7/9] Fix ROCm job: module scanning and cached VecCore - The image Geant4 requires C++20, so disable module scanning since ROCm has no clang-scan-deps. - VecGeom config points to its builtin VecCore in the build directory: build in /opt/vecgeom-build and cache its installExternals too. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build-full.yml | 15 ++++++++++----- scripts/cmake-presets/ci-ubuntu-rocm.json | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-full.yml b/.github/workflows/build-full.yml index 9e64bc5..1f54aa3 100644 --- a/.github/workflows/build-full.yml +++ b/.github/workflows/build-full.yml @@ -12,6 +12,7 @@ env: # Keep in sync with VECGEOM_2_3_COMMIT in build-spack.yml. VECGEOM_2_3_COMMIT: 9cb15a8a6c776df385357688260567f1e714a434 VECGEOM_PREFIX: /opt/vecgeom + VECGEOM_BUILD_DIR: /opt/vecgeom-build # Keep in sync with the image tags below CI_IMAGE_DATE: 2026-11-12 @@ -60,8 +61,12 @@ jobs: id: vecgeom-cache uses: actions/cache@v6 with: - path: ${{env.VECGEOM_PREFIX}} - key: vecgeom-hip-static-gfx90a-${{env.VECGEOM_2_3_COMMIT}}-ci-rocm-${{env.CI_IMAGE_DATE}} + # NOTE: VecGeom's config points to the builtin VecCore installed + # in its build directory, so that must be cached too + path: | + ${{env.VECGEOM_PREFIX}} + ${{env.VECGEOM_BUILD_DIR}}/installExternals + key: vecgeom-hip-static-v2-gfx90a-${{env.VECGEOM_2_3_COMMIT}}-ci-rocm-${{env.CI_IMAGE_DATE}} # NOTE: static, since linking the shared libvecgeom.so with HIP device # code fails with ROCm 7.2 (undefined hidden __hip_gpubin_handle_*) - name: Build VecGeom with HIP @@ -73,7 +78,7 @@ jobs: git clone --filter=blob:none --no-checkout \ https://gitlab.cern.ch/VecGeom/VecGeom.git vecgeom-src git -C vecgeom-src checkout --detach "${VECGEOM_2_3_COMMIT}" - cmake -S vecgeom-src -B vecgeom-build -G Ninja \ + cmake -S vecgeom-src -B "${VECGEOM_BUILD_DIR}" -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${VECGEOM_PREFIX}" \ -DCMAKE_PREFIX_PATH=/opt/rocm \ @@ -86,8 +91,8 @@ jobs: -DVECGEOM_ENABLE_HIP=ON \ -DVECGEOM_BUILTIN_VECCORE=ON \ -DVECGEOM_GDML=ON - cmake --build vecgeom-build -j4 - cmake --install vecgeom-build + cmake --build "${VECGEOM_BUILD_DIR}" -j4 + cmake --install "${VECGEOM_BUILD_DIR}" - name: Add VecGeom to environment if: ${{matrix.image == 'ubuntu-rocm'}} run: | diff --git a/scripts/cmake-presets/ci-ubuntu-rocm.json b/scripts/cmake-presets/ci-ubuntu-rocm.json index 32f38ef..9119104 100644 --- a/scripts/cmake-presets/ci-ubuntu-rocm.json +++ b/scripts/cmake-presets/ci-ubuntu-rocm.json @@ -15,6 +15,7 @@ "CMAKE_CXX_COMPILER": "/opt/rocm/llvm/bin/clang++", "CMAKE_CXX_STANDARD": "17", "CMAKE_CXX_EXTENSIONS": {"type": "BOOL", "value": "OFF"}, + "CMAKE_CXX_SCAN_FOR_MODULES": {"type": "BOOL", "value": "OFF"}, "CMAKE_CXX_FLAGS": "-Wall -Wextra -pedantic -Werror -Wno-error=deprecated-declarations", "CMAKE_EXE_LINKER_FLAGS": "-Wno-unused-command-line-argument", "CMAKE_INSTALL_PREFIX": "${sourceDir}/install" From b995bebb1f74071a9505665f99d6aabd3b61ea8e Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Thu, 3 Dec 2026 08:45:19 -0800 Subject: [PATCH 8/9] Move G4 10.5 division fix to a separate PR This reverts commit b114966, which will be submitted separately. The Geant4 10.5 job fails ZnenvTest until that fix is merged. Co-Authored-By: Claude Opus 5.5 --- src/g4vg_impl/Converter.cc | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/g4vg_impl/Converter.cc b/src/g4vg_impl/Converter.cc index 92a1bbe..38f17df 100644 --- a/src/g4vg_impl/Converter.cc +++ b/src/g4vg_impl/Converter.cc @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -33,27 +32,6 @@ namespace g4vg { namespace { -//---------------------------------------------------------------------------// -//! Get the number of copies of a replicated or parameterised volume -int get_multiplicity(G4VPhysicalVolume const& pv) -{ -#if G4VERSION_NUMBER < 1060 - // Before Geant4 10.6, G4PVDivision doesn't override GetMultiplicity - // (which then returns 1): use the number of replicas instead - if (pv.IsReplicated()) - { - EAxis axis; - G4int num_replicas{0}; - G4double width; - G4double offset; - G4bool consuming; - pv.GetReplicationData(axis, num_replicas, width, offset, consuming); - return num_replicas; - } -#endif - return pv.GetMultiplicity(); -} - //---------------------------------------------------------------------------// //! Get the underlying volume if one exists (const-correct) G4LogicalVolume const* get_constituent_lv(G4LogicalVolume const& lv) @@ -198,7 +176,7 @@ class DaughterPlacer template void operator()(G4VPhysicalVolume* g4pv, F&& update_pv) const { - for (int j = 0, jmax = get_multiplicity(*g4pv); j < jmax; ++j) + for (int j = 0, jmax = g4pv->GetMultiplicity(); j < jmax; ++j) { // Modify the volume's position and place the copy update_pv(j, g4pv); From 33a9aad0b5cb52522d37ef39ae3012e431c2dc0d Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Thu, 3 Dec 2026 08:45:37 -0800 Subject: [PATCH 9/9] Move G4VG CI package requirements into reqs-ci.yaml Co-Authored-By: Claude Opus 5.5 --- scripts/spack/env-ci-base.yaml | 11 +---------- scripts/spack/reqs-ci.yaml | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/spack/env-ci-base.yaml b/scripts/spack/env-ci-base.yaml index 1fbba95..349a83a 100644 --- a/scripts/spack/env-ci-base.yaml +++ b/scripts/spack/env-ci-base.yaml @@ -14,13 +14,4 @@ spack: specs: - cmake - ninja - - "googletest@1.10:" - - packages: - cmake: - require: "@3.21:" - geant4: - require: "@10.5:" - vecgeom: - require: - - +gdml + - googletest diff --git a/scripts/spack/reqs-ci.yaml b/scripts/spack/reqs-ci.yaml index 1ac7e69..82d65fe 100644 --- a/scripts/spack/reqs-ci.yaml +++ b/scripts/spack/reqs-ci.yaml @@ -2,8 +2,9 @@ # Copyright Celeritas contributors: see top-level COPYRIGHT file for details # SPDX-License-Identifier: (Apache-2.0 OR MIT) #-----------------------------------------------------------------------------# -# Copied unchanged (apart from this header) from Celeritas -# scripts/spack/reqs-ci.yaml at celeritas-project/celeritas@db9a1d4e6. +# Copied from Celeritas scripts/spack/reqs-ci.yaml at +# celeritas-project/celeritas@db9a1d4e6, with G4VG package requirements +# (from Celeritas scripts/spack/reqs-celer.yaml) appended at the end. # Keep it in sync with Celeritas so that the G4VG CI concretizes the same # specs as Celeritas and can reuse its spack buildcache. #-----------------------------------------------------------------------------# @@ -52,3 +53,13 @@ packages: require: "llvm@18" cxx: require: "llvm@18" + # G4VG requirements + cmake: + require: "@3.21:" + geant4: + require: "@10.5:" + googletest: + require: "@1.10:" + vecgeom: + require: + - +gdml