Skip to content

perf(cuda): preclusion-layer balance, drop wide-front ripple overhead (Refs #9) - #33

Merged
nikbott merged 1 commit into
devfrom
perf/cuda-preclusion-balance
Aug 14, 2026
Merged

nikbott merged 1 commit into
devfrom
perf/cuda-preclusion-balance

Conversation

@nikbott

@nikbott nikbott commented Aug 14, 2026

Copy link
Copy Markdown
Owner

What

Rewrites the CUDA balance() to re-check only the insulation/preclusion layer each pass ([IBG2012] §II-B), with a sticky whole-mesh fallback (== balance_ref()) when the front spans the mesh. balance_ref() is untouched as the oracle. Byte-identical to balance_ref() by construction — a full check is a strict superset of the layer check, so it produces identical flags.

Performance (A2000, sm_86, CUDA 12.0), balance() vs balance_ref()

case before after
sphere 3D (89 M leaves) 1.04× 2.21×
crack 2D 1.70× 1.75×
tower 2D / 3D 0.90× / 0.92× 1.01× / 1.01×
crack 3D (49 M) 0.92× 0.95×

The previous wide-front regressions (tower, crack-3D < 1.0×) are removed; balance() ≥ balance_ref() now holds on every workload.

Correctness

  • Byte-identical parity (codes + levels + pass-count ==) across all fixtures, including a new wide-front crack fixture (crack-2D 4600 leaves/8 passes, crack-3D 47776 leaves/5 passes) added specifically to exercise the fallback. Independently re-run on the A2000; adversarially verified (no byte-identity defect — kernels untouched, 18-dir stencil, active ⊆ full, seeding ⊇, hence ==).
  • Test now proves the fallback runs: balance() exposes last_front_collapsed, and the crack fixtures assert it — so a future threshold change that stopped tripping the wide-front path fails the test instead of silently skipping it (closes a test-adequacy gap flagged in review).

Scope note

This lands the byte-identical preclusion-layer win. The literal single-round [IBG2012] Fig. 7 (from-scratch GPU Complete()) is not attempted — byte-identical minimal 2:1 balance is intrinsically level-by-level, and a true Fig. 7 port risks byte-identity for little gain here. Tracked as future work in docs/design/gpu-balance-notes.md; hence Refs #9, not Closes.

Note: CI only compiles CUDA (the GPU test job is self-hosted/skipped); the byte-identical validation above was run locally on the A2000.

Re-check only the insulation/preclusion layer each balance() pass
([IBG2012] Sec. II-B): the just-refined children plus the pre-existing
finer cells that can still flag them. When that layer grows to span the
mesh (a crack plane fans one coarse cell across the whole domain), a
cheap pre-filter plus one O(n) reduce detect it and the balance falls
through -- stickily -- to the plain whole-mesh check that balance_ref()
uses, dropping all front-tracking overhead. This removes the previous
wide-front regression (balance() < balance_ref()) while keeping the
thin-front win.

Byte-identical to balance_ref(): a full check is a strict superset of
the preclusion-layer check, so it produces the same flags. Parity
fixtures extended with a wide-front `crack` case that reaches the
whole-mesh fallback.

A2000 sm_86: sphere 3D (89M leaves) 1.04x -> 2.21x; crack 2D 1.70x ->
1.75x; tower 2D/3D 0.90x -> 1.01x; crack 3D 0.92x -> 0.95x.

Full single-round preclusion (generate coarse-neighbourhood + Complete,
[IBG2012] Fig. 7) is left as future work; see docs/design/gpu-balance-notes.md.

Refs #9

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nikbott
nikbott merged commit 8c2584b into dev Aug 14, 2026
9 checks passed
@nikbott
nikbott deleted the perf/cuda-preclusion-balance branch August 22, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant