Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5db800d
libcarbonpy: fix positional AccessToken init after ResourceKind was a…
massimim Nov 18, 2026
cb2cc0c
Add RegionMask: 256-bit user-defined sub-domain label set
massimim Nov 18, 2026
6617a29
Skeleton: region-mask (sub-field) dependencies
massimim Nov 18, 2026
539f4b0
Skeleton exporters: show region masks
massimim Nov 18, 2026
72c1760
Region masks: example and benchmark
massimim Nov 18, 2026
7f0c32e
Docs: region-mask dependencies
massimim Nov 18, 2026
4133e9f
Region masks: 2-rank distributed test
massimim Nov 18, 2026
433d3bb
halo: drain intra-node peer copies before any GPU writes again
massimim Nov 18, 2026
a384771
build: one SYCL .cu mirror helper with the source dir on the include …
massimim Nov 18, 2026
2e790c3
sycl: order cross-device copies with explicit events
massimim Nov 18, 2026
ad43352
sycl: enable ReduceHostCopy::Deferred
massimim Nov 18, 2026
b4d8a98
sycl: implement ReduceFinalize::BlockAtomic
massimim Nov 18, 2026
aaee3f7
halo: drain intra copies in HaloDisg/HaloBlock/HaloDistributed
massimim Nov 18, 2026
470f719
tests: order skeleton_scalar_pattern's re-upload after the async run
massimim Nov 18, 2026
c03dcf7
sycl-mpi: fix block_dist_stencil_parity probe; docker-build-all env/c…
massimim Nov 19, 2026
01aa41c
ci: add sycl/sycl-mpi gpu-ci cells and a 20x repeat lane; refresh AGE…
massimim Nov 19, 2026
26c7cb5
examples: add region_mask_cube, a minimal region-mask walk-through
massimim Nov 19, 2026
0872c39
examples: launch-matrix DOT and --overlap for the region-mask examples
massimim Nov 20, 2026
ae4a3e4
sub_grid: add SubGrid types, lane tables and fields (milestone 1)
massimim Nov 20, 2026
b958b29
sub_grid: SubGrid compute kernels and halo-less field rules (mileston…
massimim Nov 20, 2026
ab6b369
sub_grid: Skeleton integration tests; Kernel::compute dispatch (miles…
massimim Nov 20, 2026
1ae7df6
sub_grid: sub_grid_cube example, docs, CHANGELOG, AGENTS (milestone 5)
massimim Nov 20, 2026
ce95299
sub_grid: reductions over a SubGrid; SubGrid validated on HIP
massimim Nov 20, 2026
c3b78cd
block: a copied Block no longer shares the source's memoised host spans
massimim Nov 20, 2026
9fb70c6
sub_grid: SubGrid over a Block (block-sparse) parent
massimim Nov 20, 2026
d2ccb07
sub_grid: sub_grid_block_markers example; docs, CHANGELOG, AGENTS for…
massimim Nov 20, 2026
bccd14b
tests: Jacobi + AXPY with and without a SubGrid, on Dense and Block
massimim Nov 20, 2026
f44d512
tests: Jacobi+AXPY runs B and C in parallel, with and without OCC
massimim Nov 20, 2026
ee8ff24
docs: add PROJECT_REVIEW.md (2026-11 full-tree point of view)
massimim Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 59 additions & 7 deletions .github/workflows/gpu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
workflow_dispatch:
inputs:
configs:
description: 'Comma-separated configs to run (cuda,cuda-mpi). Defaults to both.'
description: 'Comma-separated configs to run (cuda,cuda-mpi,sycl,sycl-mpi). Defaults to all.'

Check notice on line 37 in .github/workflows/gpu-ci.yml

View check run for this annotation

Autodesk Chorus / security/checkov

CKV_GHA_7

The build output cannot be affected by user parameters other than the build entry point and the top-level source location. GitHub Actions workflow_dispatch inputs MUST be empty.
required: false
default: 'cuda,cuda-mpi'
default: 'cuda,cuda-mpi,sycl,sycl-mpi'

jobs:
gpu-matrix:
Expand All @@ -47,7 +47,7 @@
github.event_name != 'pull_request'
|| contains(github.event.pull_request.labels.*.name, 'gpu-ci')
runs-on: [self-hosted, linux, gpu, cuda]
timeout-minutes: 90
timeout-minutes: 150

strategy:
fail-fast: false
Expand All @@ -58,13 +58,32 @@
# carbon_halo_disg_dist, dist_transfer, dense_dist, halo_dist,
# halo_dist_periodic_z, native_io_dist, dist_reduce). Together
# the two cells cover both audit-flagged silent-bug classes.
config: [cuda, cuda-mpi]
# `sycl` / `sycl-mpi` are the same two cells on the AdaptiveCpp
# backend (cuda:<SM_ARCH>;omp targets) — SYCL has its own event /
# cross-device ordering code, so it needs its own GPU lane.
config: [cuda, cuda-mpi, sycl, sycl-mpi]

steps:
- name: Select config
id: select
# workflow_dispatch runs only the configs named in `inputs.configs`.
env:
EVENT: ${{ github.event_name }}
CONFIGS: ${{ inputs.configs }}
CONFIG: ${{ matrix.config }}
run: |
if [ "${EVENT}" != "workflow_dispatch" ] || [[ ",${CONFIGS}," == *",${CONFIG},"* ]]; then
echo "run=1" >> "${GITHUB_OUTPUT}"
else
echo "gpu-ci: ${{ matrix.config }} not in inputs.configs, skipping"
fi

- name: Checkout
if: steps.select.outputs.run == '1'
uses: actions/checkout@v4

- name: Preflight (docker + GPU)
if: steps.select.outputs.run == '1'
run: |
set -euo pipefail
command -v docker >/dev/null || { echo "docker not on PATH"; exit 1; }
Expand All @@ -83,7 +102,7 @@
else
# >= 2 GPUs: assert the multi-device coverage actually runs. carbon_multi_gpu_gate
# turns a mis-provisioned runner (driver hides a card, MIG partitioning, a stale
# CUDA_VISIBLE_DEVICES) into a red run instead of ~28 tests quietly self-skipping
# CUDA_VISIBLE_DEVICES) into a red run instead of ~30 tests quietly self-skipping
# to a pass. Enumerate the affected set with `ctest -L needs_multi_device`.
echo "CARBON_TEST_STRICT=1" >> "${GITHUB_ENV}"
fi
Expand All @@ -95,14 +114,21 @@
nvidia/cuda:12.6.3-base-ubuntu22.04

- name: Run docker matrix (${{ matrix.config }})
if: steps.select.outputs.run == '1'
env:
# Forwarded to scripts/docker-build-all.sh; override per-runner via
# repo / org Actions variables if a runner has a different SM arch.
# sm_80 (A100) is the safest default — Ampere covers >= sm_80
# forward; older cards need the var override.
SM_ARCH: ${{ vars.GPU_CI_SM_ARCH || 'sm_80' }}
# Space-separated KEY=VAL pairs forwarded into the container, e.g.
# `NCCL_P2P_DISABLE=1` on a runner whose PCIe peer DMA is unusable
# (NCCL's P2P transport hangs the distributed tests there).
DOCKER_ENV: ${{ vars.GPU_CI_DOCKER_ENV || '' }}
run: |
set -euo pipefail
env_args=()
for kv in ${DOCKER_ENV}; do env_args+=(--docker-env "${kv}"); done
# `--only cuda` / `--only cuda-mpi` builds the image (cached on the
# runner across runs) and runs ctest --output-on-failure inside the
# container with --gpus all wired in. format-check rides the `cuda`
Expand All @@ -113,15 +139,41 @@
scripts/docker-build-all.sh \
--only ${{ matrix.config }} \
--sm-arch "${SM_ARCH}" \
--werror
--werror \
"${env_args[@]}"

- name: Repeat GPU tests (${{ matrix.config }})
# Cross-device ordering bugs are intermittent: each fixed so far passed
# a single ctest run most of the time. Re-run every GPU test 20x in
# the build tree the previous step left behind (incremental: no
# rebuild). The MPI cells would repeat the same single-process tests,
# so the lane rides the non-MPI cells only. The orchestrator tees to
# docker-logs/run-<config>.log, so the first run's log is kept aside.
if: steps.select.outputs.run == '1' && (matrix.config == 'cuda' || matrix.config == 'sycl')
env:
SM_ARCH: ${{ vars.GPU_CI_SM_ARCH || 'sm_80' }}
DOCKER_ENV: ${{ vars.GPU_CI_DOCKER_ENV || '' }}
run: |
set -euo pipefail
env_args=()
for kv in ${DOCKER_ENV}; do env_args+=(--docker-env "${kv}"); done
cp docker-logs/run-${{ matrix.config }}.log docker-logs/run-${{ matrix.config }}-main.log
scripts/docker-build-all.sh \
--only ${{ matrix.config }} \
--sm-arch "${SM_ARCH}" \
--werror \
--skip-build-images \
--ctest-args "-L gpu -E format_check --repeat until-fail:20" \
"${env_args[@]}"

- name: Upload build + test logs
if: always()
if: always() && steps.select.outputs.run == '1'
uses: actions/upload-artifact@v4
with:
name: gpu-ci-${{ matrix.config }}-logs
path: |
docker-logs/run-${{ matrix.config }}.log
docker-logs/run-${{ matrix.config }}-main.log
docker-logs/${{ matrix.config }}/build/Testing/Temporary/LastTest.log
if-no-files-found: ignore
retention-days: 14
112 changes: 80 additions & 32 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,24 @@ same public API; what differs is which `detail/backend/<name>/` headers are pull
and which toolchain compiles the per-cell device code.

- **CUDA** is the historical and feature-complete backend. `nvcc` compiles `.cu` TUs;
per-cell launches go through `cudaLaunchKernel`. 90/90 default tests pass and all
per-cell launches go through `cudaLaunchKernel`. All 126 default tests pass (apart from
the `carbon_format_check` caveat in the snapshot below) and all
example programs build and run.
- **SYCL** is supported through [AdaptiveCpp](https://github.com/AdaptiveCpp/AdaptiveCpp)
(a.k.a. `acpp`, formerly hipSYCL). Per-cell launches go through
`sycl::queue::parallel_for`; reductions through `sycl::reduction` over
`q.parallel_for` (single-stage, no per-block partials); cross-device peer copies via
a process-wide shared `sycl::context` (so `q.memcpy(dst_gpu_ptr, src_gpu_ptr, n)` does
the right thing whether `src`/`dst` sit on the same or different devices). 89/89
default SYCL tests pass with cross-backend numerical parity. The 4-test delta vs
`sycl::queue::parallel_for`; `ReduceFinalize::DeviceReduce` through `sycl::reduction`
over `q.parallel_for` (single-stage, no per-block partials), `ReduceFinalize::BlockAtomic`
through a work-group `reduce_over_group` plus one `atomic_ref` add per group
(`detail/backend/sycl/block_atomic_reduce.h`), and `ReduceHostCopy::Deferred` is
supported. Cross-device peer copies go through a process-wide shared `sycl::context`
(so `q.memcpy(dst_gpu_ptr, src_gpu_ptr, n)` works whether `src`/`dst` sit on the same or
different devices); `System::async_copy` brackets a cross-device memcpy with explicit
custom-operation events, because AdaptiveCpp 25.02 does not order later submissions on
the in-order queue after it. Cross-backend gotcha: device code must not read a host
`static` (even `constexpr`) array — nvcc copes, AdaptiveCpp reads a zero-filled copy;
use literals or captured values. 108/108 default SYCL tests pass with cross-backend
numerical parity (every `gpu` test also 100× idle + 50× under GPU load, 2026-11).
The 4-test delta vs
CUDA is exactly the `carbon_add_cuda_only_unit_test` gate — the explicit opt-out
for tests that need raw CUDA-runtime APIs in their *body*: `block_cuda` (a smoke
test pinning the `cudaMalloc` / `cudaMemset` / `cudaDeviceSynchronize` /
Expand All @@ -114,11 +123,12 @@ and which toolchain compiles the per-cell device code.
`-DCARBON_ENABLE_MPI=ON` on top of this does not configure on the dev box: the local
MPI wrappers are built for g++ and `find_package(MPI)` fails its `MPI_CXX_WORKS`
compile check under the pixi clang. SYCL+MPI is validated in the container matrix
(`scripts/docker-build-all.sh --only sycl-mpi`), not natively here.
(`scripts/docker-build-all.sh --only sycl-mpi --docker-env NCCL_P2P_DISABLE=1`,
136 tests), not natively here.

Adding `-DCARBON_ENABLE_MPI=ON` registers **26** further distributed tests (ctest
Adding `-DCARBON_ENABLE_MPI=ON` registers **28** further distributed tests (ctest
label `distributed`, one file per grid family × transport concern) on either
backend, for **116** total on CUDA. They cover intra-process multi-GPU + cross-rank
backend, for **140** total on CUDA and **136** on SYCL. They cover intra-process multi-GPU + cross-rank
for every grid family, the `OverlapMode` matrix on every grid family
(`skeleton_dist_overlap{,_disg,_block}`), multi-format I/O round-trip (`io_dist`),
non-`Sum` reduction shapes on every grid family (`*_dist_reduce_ops`), and the
Expand Down Expand Up @@ -198,7 +208,7 @@ cmake --build build --target format-check
>
> **Test labels.** `ctest -L cpu` selects the tests that do real work with zero visible
> devices (the CPU CI lane); `-L gpu` needs at least one device; `-L needs_multi_device`
> lists the ~28 tests that self-skip below two GPUs; `-L warp` lists the 31 Python/Warp
> lists the ~30 tests that self-skip below two GPUs; `-L warp` lists the 31 Python/Warp
> tests (`-DCARBON_ENABLE_PYTHON=ON`). Set `CARBON_TEST_STRICT=1` to make those self-skips
> hard failures (`carbon_multi_gpu_gate`, `carbon_warp_gate`) instead of passes.
>
Expand Down Expand Up @@ -274,7 +284,11 @@ container (NVIDIA: `--gpus all` via the nvidia-container-toolkit; AMD:
`docker-logs/run-<config>.log` and the build trees are mirrored under
`docker-logs/<config>/build/` for post-mortem inspection. Common knobs:
`--only hip`, `--only sycl-rccl`, `--sm-arch sm_89`, `--gfx-arch gfx90a`,
`--no-cache`, `--skip-build-images`.
`--no-cache`, `--skip-build-images`, `--docker-env KEY=VAL` (repeatable; forwarded
into every container) and `--ctest-args "..."` (appended to the in-container ctest).
The NVIDIA `*-mpi` configs run with `--ipc=host`. On a host whose PCIe peer DMA is
unusable (carbon already leaves peer access off there) NCCL's P2P transport hangs the
distributed tests; pass `--docker-env NCCL_P2P_DISABLE=1`.

### CI workflows

Expand All @@ -297,24 +311,29 @@ Two GitHub Actions workflows live under `.github/workflows/`:
- **`gpu-ci.yml` — GPU validation lane (P1.γ).** Runs on a **self-hosted**
runner labelled `[self-hosted, linux, gpu, cuda]` and is triggered by
(a) the `gpu-ci` label on a PR or (b) `workflow_dispatch` (manual
re-run from the Actions tab) or (c) pushes to `main` / `master`. The
workflow shells out to `scripts/docker-build-all.sh --only cuda` and
`scripts/docker-build-all.sh --only cuda-mpi` so the runner host only
re-run from the Actions tab; its `configs` input picks a subset of the
matrix) or (c) pushes to `main` / `master`. The
workflow shells out to `scripts/docker-build-all.sh --only <config>` for
each of `cuda`, `cuda-mpi`, `sycl` and `sycl-mpi`, so the runner host only
needs `docker` + `nvidia-container-toolkit` + an NVIDIA GPU — no
native clang / CUDA / MPI / NCCL / HDF5 install required. Build /
test logs land as workflow artifacts (`gpu-ci-cuda-logs`,
`gpu-ci-cuda-mpi-logs`) for 14 days. The matrix covers the two audit
classes the CPU lane cannot exercise: `cuda` runs the full default
test suite + `format-check`; `cuda-mpi` adds every
`distributed`-labelled test (`ctest -N -L distributed` for the current
list). The workflow
native clang / CUDA / MPI / NCCL / HDF5 / AdaptiveCpp install required.
Build / test logs land as workflow artifacts (`gpu-ci-<config>-logs`) for
14 days. `cuda` runs the full default test suite + `format-check`;
`cuda-mpi` adds every `distributed`-labelled test (`ctest -N -L
distributed` for the current list); `sycl` / `sycl-mpi` are the same two
cells on the AdaptiveCpp backend. The `cuda` and `sycl` cells then re-run
every `gpu` test 20× (`--ctest-args "-L gpu -E format_check --repeat
until-fail:20"`, incremental, no rebuild): the cross-device ordering bugs
fixed so far each passed a single run most of the time. Runner-specific
container environment (e.g. `NCCL_P2P_DISABLE=1`) goes in the
`GPU_CI_DOCKER_ENV` Actions variable (space-separated `KEY=VAL`). The workflow
passes `--werror` (gates the libcarbon host compile on the container
g++) and its preflight prints the visible GPU count. On a runner with
`>= 2` GPUs it exports `CARBON_TEST_STRICT=1` (forwarded into the
container by `scripts/docker-build-all.sh`), so `carbon_multi_gpu_gate`
fails if the devices turn out not to be visible to the test process —
a hidden card, MIG partitioning, or a stale `CUDA_VISIBLE_DEVICES`
no longer downgrades ~28 `needs_multi_device` tests to silent
no longer downgrades ~30 `needs_multi_device` tests to silent
no-op passes. Below 2 GPUs it emits a `::warning::` instead, since
that configuration legitimately covers only the build plus the
single-GPU suite.
Expand Down Expand Up @@ -488,7 +507,31 @@ how a feature behaves at the edges, grep the changelog for the section name
{ None, Standard, Extended, TwoWayExtended }` opts in to the OCC
rewrite — auto-halo insertion + Internal/Boundary split + halo-stream
isolation. Single-stream fast path is preserved bit-for-bit. Catches
"halo missing before stencil" at compile time. Examples:
"halo missing before stencil" at compile time. **Region masks**:
`AccessToken::mask` (256-bit `RegionMask`, default all-ones) narrows a
Map access to user-defined label atoms via `KernelLoader::region(M)` or
`read/write/read_write(f, M)`; disjoint masks drop the edge, stencil /
halo / scalar tokens stay whole-field, masks are declaration-only (the
kernel filters itself), `Options::ignore_region_masks` /
`CARBON_IGNORE_REGION_MASKS=1` restore the whole-field schedule, and MPI
runs check masks are rank-invariant (`docs/skeleton/README.md`,
`examples/region_mask_cube.cu` minimal, `examples/region_mask_bc.cu`). **SubGrid**:
`SubGrid<Dense>` / `SubGrid<Block<>>` (`include/carbon/sub_grid.h`, `detail/sub_grid/`)
built by `Dense::new_sub_grid(labels, mask)` or `new_sub_grid(predicate, mask)` (same on
`Block`) keeps a per-GPU flat lane table of selected parent cells (parent-Internal first,
then parent-Boundary) and launches one thread per lane; `S::Span` / `S::Idx` derive from the parent's so parent
fields are read/written (and stencil-read through their halo) directly, SubGrid fields
are compact and halo-less (`read_stencil` on one is a compile error), kernels declare the
SubGrid mask automatically and OCC-split like Dense kernels, and loading another
SubGrid's field throws. Reductions (`Kernel::reduce` / `host_reduce` /
`reduce_universal`, `S.make_*reduce_kernel`) run one thread per lane through the usual
reduce pipeline via `ReduceLaunchTraits<SubGrid<G>>` (`detail/sub_grid/reduce_traits.h`);
`compute_universal` over a SubGrid is still a static_assert. Per-parent enumeration and
host spans go through `ParentTraits<G>` (`detail/sub_grid/parent_traits.h`); a Block
SubGrid's host kernels get spans from the Block's host tables (owned bricks only, so host
`neighbour` reads stay in the slab) (`docs/skeleton/README.md` "SubGrid",
`examples/sub_grid_cube.cu`, `examples/sub_grid_block_markers.cu`,
`tests/test_sub_grid*.cu`). Examples:
`examples/jacobi_unified.cu` (Dense / DenseDisg / Block from one
source file, runtime grid + transport + overlap selection);
`examples/checkpoint_dense.cu` and `examples/checkpoint_sphere_image.cu`
Expand Down Expand Up @@ -522,22 +565,27 @@ how a feature behaves at the edges, grep the changelog for the section name

Counts drift with every feature, so treat these as a sanity check, not a
contract — `ctest --test-dir <build> -N` is the source of truth. Measured
2026-07-31 on a 2×RTX 6000 Ada box (`sm_89`), every configuration fully green:
2026-11-20 on a 2×RTX A4000 box (`sm_86`, peer access off); every configuration
green apart from `carbon_format_check`, which flags pre-existing violations in
files outside this work:

| Configuration | Tests |
| --- | --- |
| default (CUDA) | 93 |
| `-DCARBON_ENABLE_MPI=ON` (CUDA) | 116 † |
| `-DCARBON_BACKEND=Sycl` | 89 |
| `hip-nvidia` (HIP backend on NVIDIA) | 89 |
| default (CUDA) | 126 |
| `-DCARBON_ENABLE_MPI=ON` (CUDA) | 154 ‡ |
| `-DCARBON_BACKEND=Sycl` | 114 |
| `sycl-mpi` (SYCL + MPI) | 142 ‡ |
| `hip-nvidia` (HIP backend on NVIDIA) | 122 |

† not re-measured on 2026-07-31; carried over from the 2026-07-30 2×A100 run.
‡ 2026-11-18 count plus the SubGrid tests (14 on CUDA, 6 on SYCL); not re-run since.

`hdf5_io` / `nanovdb_io` are registered unconditionally but compile-time
skip when their flags are off. The 26-test MPI delta is the `distributed`
ctest label and registers on both backends. The 4-test CUDA/SYCL delta is
skip when their flags are off. The 28-test MPI delta is the `distributed`
ctest label and registers on both backends. The 12-test CUDA/SYCL delta is
the `carbon_add_cuda_only_unit_test` gate (`block_cuda` + the three
`mgrid_*` tests with hand-rolled `<<<>>>` kernels).
`mgrid_*` tests with hand-rolled `<<<>>>` kernels) plus the eight
`sub_grid_compile_fail_*` entries (CUDA and HIP; regexes match nvcc and clang wording).
HIP registers the compile-fail entries but not the CUDA-only gate, hence 4 fewer than CUDA.
`carbon_format_check` is enforced on every backend.

### Packaging
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CarbonSpdlog)
include(CarbonRapidjson)
include(CarbonSyclMirror)

set(CARBON_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

Expand Down Expand Up @@ -292,6 +293,7 @@ add_library(carbon SHARED
src/logging.cpp
src/memory_side.cpp
src/process_grid.cpp
src/region_mask.cpp
src/report.cpp
src/skeleton.cpp
src/stencil.cpp
Expand Down Expand Up @@ -424,6 +426,7 @@ elseif(CARBON_BACKEND STREQUAL "Sycl")
src/logging.cpp
src/memory_side.cpp
src/process_grid.cpp
src/region_mask.cpp
src/report.cpp
src/skeleton.cpp
src/stencil.cpp
Expand Down
Loading
Loading