Repository navigation
Shaders: multi-wave group_any widen, guarded resources, and s_setpc early-out strip - #1124
nameermohammedkhan-art wants to merge 1 commit into
Conversation
…setpc early-out strip
|
Runnable two-store regression and experimental fix: fixture, patch and reproduction commands. On 887d053, the RTX 3050 Laptop produced 4,096 unexpected writes inside the branch and 4,096 after the join. Guarding only the in-branch store left all 4,096 post-join errors. Selecting the incoming EXEC mask of each skipped guest wave at the join also removed those errors (33,280 output words checked). This is a single-block synthetic case; visual impact and complex control flow remain unverified. Correctness counterexample on PR head 887d053 (RTX 3050 Laptop, native wave32). With the public translator and VICTORY_WAVE_WIDE=1, a guest wave with empty EXEC loses a live scalar value when the other guest wave takes the body. This matters if enabling multi-wave widening for additional shaders. Reproducer using the 128-thread per-lane variant below: preserve the per-thread byte offset in v9. Before s_and_saveexec_b64 initialize s7=5 (0xBE870385). Immediately after SAVEEXEC branch with s_cbranch_scc0 +20 (0xBF840014) over exactly WAVE_OR_V7_TO_S7. At the join restore EXEC from s[12:13], then copy s7 to v0 and store to each thread's own word. Keep the existing predicate t > threshold. With threshold 63, guest wave 0 skips all writes to s7 and must store 5 into words 0..63. It instead stores zero into all 64. Guest wave 1 produces the expected 0xffffffff. The retry diagnostic confirms wave-wide branches, wave Some(32). Across thresholds 0..128 inclusive plus 200, precisely 63..126 fail, each by those first 64 words (4,096 of 16,640 comparisons). Both-active and both-empty controls pass. The earlier masked-store fixture below passed because it did not observe the scalar from an empty wave after reconvergence. Please retain the original rejection for this case until the per-wave scalar at the join is preserved. Synthetic fixture only, AI-assisted. One additional hardware test case for I checked those expectations with a synthetic CPU reference and a deliberately group-wide OR. The latter differs on 31 words here, versus zero at the current thresholds of 96 and 200. Distinct output words also avoid the two active guest waves racing on the same address. This is a coverage suggestion; I have not observed incorrect output on the PR. AI-assisted. Hardware follow-up at the same head: tested the per-lane variant on an RTX 3050 Laptop (native wave32), with a zero-initialized 128-word UAV, for every threshold from 0 through 128 and also 200. All 16,640 output words across 130 dispatches matched the per-guest-wave CPU expectation. Pipeline creation and dispatch were required for the test to pass. This covers correctness of the synthetic fixture only. Public translation path, parent versus head on the same RTX: in the per-lane fixture above, replace s_cbranch_execz +23 (0xBF880017) immediately following s_and_saveexec_b64 with s_cbranch_scc0 +23 (0xBF840017). SAVEEXEC sets SCC according to whether the resulting EXEC is nonempty, so the expected lane outputs are unchanged. With VICTORY_WAVE_WIDE=1, parent 085ee7c refuses multi-wave widening and falls through to approximate local waves (threshold 0, lane 1: 0x0000ffff instead of 0xffffffff). Head 887d053 takes the wave-wide retry and passes all 16,640 word checks. With the switch unset both commits take the approximation and fail at that same lane. Under VICTORY_WAVE_LOCAL=idiom with widening enabled, the parent refuses translation and the head passes. This isolates a correctness improvement through translate() on native wave32. No frame-time or title-shader claim. |
|
Dathinel's two-store regression on a second vendor: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2,
So the counterexample is not NVIDIA-specific. The PR's own 5 new tests pass here too (221 passed, 0 failed without the patches, on main AI-assisted (Claude Code): tests run on my machine, text drafted with Claude. |
Summary
widento support multi-wave compute threadgroups (all_group_blocksconvergence +wave_widecross-wave LDS reduction forgroup_any/group_all).EXECguards inresource::Tracer::activeso resource provenance prunes unreachable lanes afterwithout_early_outsstripss_cbranch_execz/s_setpcearly-out paths (VICTORY_WAVE_DEEP_SKIPS=0disables).v_readfirstlane_b32narrowed byv_cmpx_eq_{i,u}32againstv_mbcnt(single_lane_readfirstlane).lower.rsunder the 512 KiBxtask policylimit by placing the group-convergence / singleton helpers incrates/victory-shader/src/emit/group_wide.rs.wave64_tests.rsandresource.rs.Validation
cargo xtask policy:asset policy: 184 files okcargo clippy -p victory-shader --all-targets -- -D warnings: passed (0 warnings)cargo test -p victory-shader --lib:220 passed; 0 failed; 3 ignored(includes hardware execution testmulti_wave_widen_runs_group_any_on_hardware)