Repository navigation
Conversation
…omics in Wave32 regions
…r the threads that run it Two more proofs for trustno1-coder#1435, on top of trustno1-coder#2358 (commutative atomics) and trustno1-coder#1773 (own-mask values, one constant per dword, strided loop counters), whose commits come first here. - Refinement D: at most one thread of the group runs the region's LDS instructions (`if (tid == 0) { ... }`). One thread is in one host wave and makes its accesses in program order, so whatever it reads or writes, the halves cannot see each other's order. - Refinement E: over the threads that may run each access, no two threads touch one byte where one writes. `if (tid < 16) { lds[28 + 12 t]; lds[220 + 12 t]; }` overlaps over the whole group (thread 16's first slot is thread 0's second) but not over threads 0..15. Which threads may run an LDS instruction: for each thread, the lane compares in its block's reach and its guard whose operands are known per thread (constants and thread ids) take that thread's outcome, constant masks its bit, other atoms stay free (a walk of the decision diagram, with a node budget that answers "may run"). Free atoms only add threads, so both proofs err towards refusing. Groups of more than 1024 threads are not looked at. Not taken, on purpose: a lane-branch region where several lanes of one host half read what other lanes of it wrote with no barrier (a wave reduction under `tid < 32`). The console wave saw those writes in lockstep; the host has no order between its lanes there. That needs a lowering with a wave-level sync, not a proof. Tests: one thread at tid 0, 40 and 63, under a branch and under v_cmpx; two threads refused; an 8 x 8 group column refused; footprints accepted for 16 threads and refused for 17; a read of the next thread's slot refused (across the halves and within one); one or two atomic families in a lane loop (trustno1-coder#2358's proof). The trustno1-coder#1773 commit was cherry-picked onto main with its Access fields merged next to trustno1-coder#2358's (`atomic_alg` beside `data_const`, `strided`, `ds_off`) and both proofs in the read-write check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hardware check of this PR's pattern on a gfx1036 oracle (native wave64), against the 32-lane result on an RTX 5080 and a Radeon 680M. Hand-written wave64 cases matched in every case. On main those cases only translated through the folded form; with this PR they go to the plain split. Rebased onto current main together with the other LDS proof PR, the #3441 is built on this PR and #2358/#1773 (the two conflict with each other; the resolution is in #3441). It adds two more proofs and takes the refused/folded count from 181 (main) via 162 (this pair) to 139. AI use: Claude Code (Claude Opus 5.5). |
|
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch |
What it changes
Adds Refinement C to the static LDS hazard analysis in
crates/victory-shader/src/emit/lds.rs(region_commutative_atomics):!all(lane-branch) LDS regions where every LDS access is a non-returning, commutative and associative 32-bit integer atomic (ds_add_u32,ds_sub_u32,ds_and_b32,ds_or_b32,ds_xor_b32,ds_min_i32,ds_max_i32,ds_min_u32,ds_max_u32), with zero plain reads, zero plain writes, and zero returning (_rtn) or order-sensitive atomics (ds_inc_u32,ds_cmpst_*,ds_add_f32, etc.).ds_add_u32andds_or_b32), requires provably disjoint constant byte offsets on a shared group-uniform base; same-offset mixes are refused.lds::analyzeinserts host-wavemeetbarriers around!allregion entries and exits and 32-bit LDS atomics operate on single aligned dwords (addr >> 2), any Wave32 interleaving produces the exact same final LDS bits as Wave64 — complementingLdsOrder::loopedfor acyclic!allbranches and for loops preceded byall-block writes without an explicits_barrier.How it was tested
commutative_atomic_reduction_runs_on_wave32_gpu)!allregions with non-returning commutative integer atomics (e.g.,if (tid.x < N) { ds_add_u32(LDS[0], ...); }) failedlds::analyzewithRefusal::AtomicWithoutPlainReadand fell back to Wave64 (or requiredVICTORY_LDS_WRITE_ONLY_OK=1)emit::lds::tests::verifies both Wave32 acceptance/GPU execution and Wave64 refusal cases)cargo testpassed for the crates it touches: yes (cargo test -p victory-shader --lib --locked emit::lds::tests::— 23 passed, 0 failed)Checked for overlap
lds.rs; this PR only adds commutative non-returning 32-bit integer atomic analysis and does not overlap Water and Light Probe Shader Fix (Wave32 LDS Safety Proofs) #1773)