Shaders: a divergent aggregated atomic aggregates per host half in wave64 emulation #3822
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3822"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by omarsaifuddin on 2026-11-29T05:34:31Z.
Stacked on #189 (base
3e39e34). The change is the last two commits; the rest of the diff is #189's branch:a98b70aShaders: a divergent aggregated atomic aggregates per host half in wave64 emulationfe81664Shaders: tests for the divergent aggregated atomicWhat
Under
Wave64Mode::Emulate, a 64-lane ballot in divergent control flow is refused (a 64-lane wave ballot in divergent control flow). That refusal also catches the compiler's append idiom: elect the first active lane (s_ff1_i32_b64), popcount the mask (s_bcnt1_i32_b64), onebuffer_atomic_addfrom the elected lane, then broadcast the base so every lane adds its own rank. Several of the heaviest dropped world programs are this shape.This lets each host half ballot only its own lanes when that cannot change the result:
s_bcnt1_i32_b64), a first lane (s_ff1_i32_b64), or a lane rank (v_mbcnt_*);Each half then aggregates its own lanes into its own distinct slot; only the order the two halves append differs from the console. Anything else — the count read as data, a returned atomic, a reduction used as a value, a different atomic kind — still refuses, so the path is proof-gated rather than an unconditional per-half fallback.
Measured
RTX 3070 Ti, Windows 11, scripted from boot into the prologue (#189 comment); the stack was the one reported in #3330: main
63bcca4+ #3226 + #2323 + #2885 + #3518 + #3016 + #2348 + #3670 + #3496 + #3587 + #3588 + #189 + #3200.victory-shader304 passed / 0 failed / 3 ignored,victory-gpu236 / 0 / 1.One card and one scripted path, so this is a data point, not proof.
Tests
Two unit tests in
emit::wave64_tests:divergent_count_added_by_an_atomic_emits_under_emulate— the idiom emits under Emulate.divergent_count_used_as_data_besides_an_atomic_is_refused— the same count also used as data is still refused.Both pass at
3e39e34+ these commits, andcargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean.Relation to other wave64 work
This is the proof-gated counterpart to #1890's unconditional per-half
shortcut:in divergent code: #1890 lets each half use its own lanes for everything divergent and notes that is right for wave-aggregated atomics; this PR takes only the atomic shapes it can prove and keeps refusing the rest.Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T17:17:01Z.
AMD run on a Radeon 780M (RDNA3, wave32 and wave64), head merged as is onto main
63bcca4,cargo test --profile diag -p <crate> --locked --lib:VICTORY_WAVE64_EMULATE=emulateVICTORY_WAVE64_EMULATE=wave32No regressions on AMD. The three runs are identical, so I'd guess the variable only reaches the runtime shader cache and the tests pick their own mode; if there's a way to force the emulated path in the GPU tests on a wave64-capable card, I can rerun with it. For what it's worth, #3823 (stacked with #3824 and #3830) also passes everything on the same card (356 / 232), and the two conflict.
AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by omarsaifuddin on 2026-11-30T07:37:21Z.
Ran the full stack through the prologue on an RTX 3070 Ti (Windows 11, driver 32.0.16.2140, 1440p). Stack:
main63bcca4+ #189 + #3200 + #2703 + #2118 + #3016 + #2348 + #3670 + #3496 + #3587 + #3588 + #3226 + #2323 + #2885 + #3518 (+ the local capped-heap edits from #3330) + this PR.Caveat: the run also hits
host view heap overflow slots exhausted(noted in #3870) and the world is still about 1 fps, so this shows the patch runs in the title, not that every accepted idiom is right.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.