perf(cuda): preclusion-layer balance, drop wide-front ripple overhead (Refs #9) - #33
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tobalance_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()vsbalance_ref()The previous wide-front regressions (tower, crack-3D < 1.0×) are removed;
balance() ≥ balance_ref()now holds on every workload.Correctness
==) across all fixtures, including a new wide-frontcrackfixture (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 ==).balance()exposeslast_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 indocs/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.