Repository navigation
Conversation
… an add of 0 (xcl-dev#847) The halves' meet (`xcl_x_meet`) and the early-exit-safe barrier poll their counters with `InterlockedAdd(x, 0u, c)`. Mesa's NIR lowers an atomic add of 0 to a load of shared memory and hoists it out of the loop (found and shown in the RADV ISA by SzczepanGrela on xcl-dev#847), so on RADV a half reads the other half's counter once and spins to the bound whenever the other half arrives a little late: under async compute load the split tests fail (66 of 80). A compare-exchange of 0 with 0 never changes the word and returns it like the add did; NIR keeps it inside the loop (checked on xcl-dev#847 with DXC 1.9 and Mesa 26.2.5). The three polls use it now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on One more passing test than the baseline; the split wave64 spin-loop polling change ships its case and runs green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. |
|
Verified on Linux / Mesa RADV + Machine and build. AMD Radeon RX 9070 (RDNA4 /
RDNA4 ISA check ( BB22:
s_cmp_lt_u32 0xfffff, s10
s_cbranch_scc1 BB30
BB24:
v_mov_b32_e32 v0, 0
ds_cmpstore_rtn_b32 v0, v5, v0, v0 offset:32756
s_mov_b32 s11, exec_lo
s_wait_dscnt 0x0
v_add_nc_u32_e32 v0, 0xffffffe0, v0
v_cmpx_lt_i32_e32 -1, v0Not tested: full workspace suite on this branch, native Windows AMD, RX 7900 XT (RDNA3), or AI use: Antigravity (Gemini 4 Neon) cross-compiled |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Retail run on an RTX 5080 (32-lane waves): Tested
So on this title the split-wave64 programs with the compare-exchange polls run into world loading as before. The stalls of #505 are not changed by it beyond run-to-run noise: one
this PR merged onto it (run 2): Not tested
AI use
|
|
Two regression pairs for Tested
Pair 1, Pair 1, this PR, Pair 2, Pair 2, this PR,
Presents per 2 s over the whole run (from the
All four runs slow down to a few frames per 2 s at about 44-48 s; three of them pick up again before 60 s. When that phase starts and how long it lasts is what decides each total: in pair 1 it lasted to the end of the PR's run (65 frames in the last 16 s, against 178 on For #505. The program at 100 % before the device removal on this machine is the BVH builder's refit, Not tested
AI use: Claude Code (Claude Opus 5.5) |
|
Tested exact head Tested
PR (Run 1 on Notes
Not tested
AI use
|
|
RDNA3 confirmation, as requested on #847: PR head
12/12 runs green. My #847 floor comments' failing set is exactly this PR's fixed set: all four single-test failures and the cross-test leak are gone on RDNA3 too. Consistent with SzczepanGrela's NIR-hoisting root cause: the Mesa-side spin-loop poll elimination explains my mask-semantics symptoms on RDNA3 as well, Windows-native-AMD staying clean included. Machine. RX 7900 XT (RADV NAVI31), Mesa 26.2.5, Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, DXC 1.9.2609.5, release profile, target Counts only, no game data. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting. |
|
A measurement for the split-wave64 meet in one-wave groups (64-thread groups: the two 32-lane halves are the whole group). Main cbc296a, RTX 3080 10 GB (driver 610.88), the
With the 32 KB LDS block (any program that touches LDS), the same loop with an LDS store + load per iteration takes 41.9 ms spin vs 13.9 ms barrier. 256-thread groups always spin: 12.6 ms vs 3.4 ms native. That makes a meet about 2.3x to 3x more expensive with the counter spin than with the barrier in one-wave groups. 257 of the 374 split compute programs in the title I looked at use 64-thread groups, and their exchanges are mostly v_cmp masks, 25.4k static exchanges in total. This is only a number for whoever touches the meet form. I'm not proposing to drop #798's guard. In a one-wave group both halves reach every meet together unless they desync, and the barrier form has no bound for that case. A cheaper poll (#1244) or a barrier fast path with a bounded fallback would be the places to win it back. AI-assisted (Claude Code, Claude Opus 5.5); numbers from runs on my machine. |
|
Thanks grahamster2. The same
Without an exchange, all four are within 1.0-1.15x of wave32. On Ampere too, then, the counter spin in one-wave groups costs about 2.3x the barrier, matching your 3080 numbers. This PR doesn't change that: the compare-exchange poll runs at the same speed as the add of 0. Its point is the correctness of the poll (#847), not speed. Using the barrier for one-wave groups would be a separate change. AI-assisted (Claude Code). Synthetic benchmark only. |
|
A design question before I write anything: could the HLSL split-wave64 form go back to a group barrier for the meet in one-wave groups (≤ 64 threads), as the direct DXIL translator does? Why ask. In a group of one console wave, the two 32-lane halves are the whole group. #798 made the bounded counter spin the default there too, as a guard against a half that exits early, runs out of
257 of the 374 split compute programs in the title I checked use 64-thread groups. Most of their 25k static exchanges are Why I think the barrier is safe there (please correct me):
What the spin still buys is a bound if the translator ever desyncs the halves (a bug). That shows up as wrong output instead of a TDR. As upipibi noted on #798, the wrong output is silent. Question: would you take a change that emits the barrier meet ( AI-assisted (Claude Code, Claude Opus 5.5); measurements from runs on my machine. |
|
@grahamster2 From #1244's side, a separate PR for that fits; whether the barrier becomes the default there is the maintainers' call. It doesn't conflict with this PR: #1244 only changes what the spin polls with ( Your RTX 3080 numbers match the 3070 run I posted above: in 64-thread groups, spin is 3.6x wave32 and the barrier 1.55x. On safety, I checked only the early-exit point. I can run the NVIDIA GPU-test soak on the 3070 (Ampere) at your head once it's up. |
The split wave64 form's spin loops poll the other half's arrival counter with
InterlockedAdd(x, 0u, c). On RADV, Mesa's NIR lowers that to a plain load of shared memory and hoists it out of the loop. SzczepanGrela showed this in the RDNA4 ISA on #847: oneds_load_b32before the loop, none inside it. So a half that arrives a few polls late is never seen, and the waiting half always runs out its 2^20 polls and gives up. Under async compute load the split tests fail 66 of 80 times there, and pass 80 of 80 withXCL_WAVE64_SPIN=0. This PR makes the three polls compare-exchanges that never change the word. NIR keeps those inside the loop (checked on #847 with DXC 1.9 and Mesa 26.2.5).Part of #847 (the RADV failures). Related to #772 (the same
gpu_split_wave64_*failures under RADV).What is in it
gpu/recomp/emit.rs:xcl_x_meet()polls withInterlockedCompareExchange(XCL_XC(...), 0u, 0u, c), andxcl_s_barrier()pollsXCL_BAR_STATEandXCL_BAR_ALIVEthe same way. A compare-exchange of 0 with 0 returns the word like the add of 0 did, and leaves it as it was (when the word is 0 it writes 0). Nothing else changes: the bound, the dead-pair path and the counters.gpu/recomp/tests.rs:split_wave64_spin_polls_are_not_adds_of_zerotranslates a 128-thread split program withs_barrierand av_readfirstlane. It checks that the three polls are compare-exchanges and that noInterlockedAdd(…, 0u, …)is left, and compiles the HLSL with DXC. It fails onmainand passes here. It needs no GPU.Tested
cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4:71d3a38): 742 passed, 0 failed, 41 ignored;main47efa2e: 741 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware. Allgpu_split_wave64_*andgpu_safe_s_barrier_*tests pass.bench_split_wave64's loop (one exchange per iteration) with its shape changed locally (64 threads,Dispatch(4,1,1), as on Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505). GPU timestamps, median of 9:mainThe poll costs the same when the halves meet. A timed-out meet is about 20 % longer (about 42 ns per poll instead of 36), and that path is taken at most once per wave.
Regression run
From Kalmarv's run (#1244 (comment)), thanks:
main:
PR:
That is Kalmarv's first pair (the PR at 87 % of
main's frames). Their second pair, about 10 minutes later on the same machine, has the PR at 103 % (1360 / 1317 frames). In every run the title slows to a few frames per 2 s at 44–48 s, and how long that phase lasts decides the total.Not tested
gpu_split_wave64_*andgpu_geometry_wave32_prefix_count_over_a_mask, defaultXCL_WAVE64_SPIN) on this head?AI use
🤖 Generated with Claude Code