Skip to content

Recompiler: split wave64 spin loops poll with a compare-exchange, not an add of 0 (#847) - #1244

Open
upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:fix/spin-poll-cas
Open

upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:fix/spin-poll-cas

Conversation

@upipibi

@upipibi upipibi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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: one ds_load_b32 before 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 with XCL_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 with InterlockedCompareExchange(XCL_XC(...), 0u, 0u, c), and xcl_s_barrier() polls XCL_BAR_STATE and XCL_BAR_ALIVE the 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_zero translates a 128-thread split program with s_barrier and a v_readfirstlane. It checks that the three polls are compare-exchanges and that no InterlockedAdd(…, 0u, …) is left, and compiles the HLSL with DXC. It fails on main and passes here. It needs no GPU.

Tested

  • NVIDIA GeForce RTX 3070 (32-lane waves, so the split form runs), driver 616.56; Windows 11 Pro 26100; Rust 1.100.0 MSVC; debug.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4:
    • this PR (71d3a38): 742 passed, 0 failed, 41 ignored;
    • main 47efa2e: 741 passed, 0 failed, 41 ignored.
    • Both skip the same two tests (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. All gpu_split_wave64_* and gpu_safe_s_barrier_* tests pass.
  • Cost on NVIDIA, release: 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:
main this PR
halves in step, loop to the 65 536 budget 15.2 ms 14.2 ms
halves in step, 16 384 iterations 3.7 ms 3.4 ms
one half never arrives (timed-out meet, forced locally) 37.3 ms 44.2 ms

The 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:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1323 (PresentX 1324)
presents per 2 s (last 3): 19 45 48
device removals: 0
crashes: 0
peak commit: 26877 MB

PR:

xcl-smoke v1
commit: 71d3a384d9b35ed845f066ea5c62d7030e8be68a
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1147 (PresentX 1148)
presents per 2 s (last 3): 0 1 13
device removals: 0
crashes: 0
peak commit: 25610 MB

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

AI use

🤖 Generated with Claude Code

… 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>
@dcastell1

Copy link
Copy Markdown

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 main@930e8b4 (baseline 751 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
752 passed; 0 failed; 41 ignored   (exit 0)

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.

@SzczepanGrela

Copy link
Copy Markdown

Verified on Linux / Mesa RADV + vkd3d-proton at PR head 71d3a38: every failure from #847 and #772 is gone (0 / 146 failed under async compute load; 0 / 185 total including idle runs and the new unit test, vs 86 / 105 failed on main 1ec4c98 under the same async loads), and RADV_DEBUG=shaders confirms ds_cmpstore_rtn_b32 stays inside the spin loop.

Machine and build. AMD Radeon RX 9070 (RDNA4 / GFX1201, native wave64, 15.81 GiB VRAM), Ryzen 7 7700, 31.4 GiB RAM. CachyOS, kernel 7.3.0-5-cachyos, Mesa 26.2.5-arch3.1 (radv, Vulkan 1.4.354), GE-Proton11-12 (Wine Staging 11.0 + ntsync), vkd3d-proton v3.1-1-g8293130eb, DXC/DXIL 1.9.2602.17. Built with rustc 1.97.1 cross x86_64-pc-windows-gnu, release (cargo test -p xcl --lib --target x86_64-pc-windows-gnu --release --no-run). Default XCL_WAVE64_SPIN (unset), XCL_NETWORK=0, solo --exact --test-threads=1 --nocapture, no skips.

gpu_geometry_wave32_prefix_count_over_a_mask (XCL_REQUIRE_GPU=wave64):

Workload main 1ec4c98 PR #1244 71d3a38 GPU telemetry (PR run)
Idle 20 / 20 20 / 20 busy 1-17%, VRAM 2.10 GiB
Single async compute (6.5 ms dispatches, 32 KiB LDS, 1 GiB VRAM) 1 / 30 30 / 30 busy med 99%, VRAM 3.15 GiB
Dual queue (async + gfx ~83 ms dispatches, 32 KiB LDS, 12 GiB VRAM) 13 / 50 50 / 50 busy med 100%, VRAM 14.12 GiB

gpu_split_wave64_* and gpu_safe_s_barrier (XCL_SPLIT_WAVE64=1):

Test Threads main 1ec4c98 (idle / async) PR #1244 71d3a38 (idle / async)
gpu_split_wave64_waves_diverge 256 0/3 / 0/5 3/3 / 10/10
gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves 256 0/3 / 0/5 3/3 / 10/10
gpu_split_wave64_masks_read_whole_after_partial_writes 64 1/3 / 0/5 3/3 / 10/10
gpu_split_wave64_cross_half_operations 64 0/3 / 0/5 3/3 / 10/10
gpu_split_wave64_lane_local_masks 64 3/3 / 5/5 3/3 / 10/10
gpu_safe_s_barrier_multi_warp_and_early_endpgm 128 n/a 3/3 / 10/10
  • RADV_DEBUG=llvm under the same 6.5 ms async load: cross_half_operations 3/3, waves_diverge 3/3 (cross_half_operations was 0/3 idle on main).
  • split_wave64_spin_polls_are_not_adds_of_zero: 1/1 passed (0.03s).

RDNA4 ISA check (RADV_DEBUG=shaders on gpu_geometry_wave32_prefix_count_over_a_mask): ds_cmpstore_rtn_b32 stays inside the 0xfffff loop body:

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, v0

Not tested: full workspace suite on this branch, native Windows AMD, RX 7900 XT (RDNA3), or xcl-smoke (no local retail title).

AI use: Antigravity (Gemini 4 Neon) cross-compiled 71d3a38, ran the Linux/RADV test matrix and RADV_DEBUG=shaders check on my machine, and drafted this comment; I reviewed the results before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib lib recomp: 190 passed, 0 failed.

Thanks!

@IvyNotFound

Copy link
Copy Markdown

Retail run on an RTX 5080 (32-lane waves): 71d3a38 merged onto main 930e8b4 – no regression into world loading; the #505 GPU-wait stalls are still there, about as on main

Tested

main 930e8b4 PR, run 1 PR, run 2
exit / device removals / crashes 0x0 / 0 / 0 0x0 / 0 / 0 0x0 / 0 / 0
frames shown 1434 1390 1402
peak commit 33 004 MB 33 883 MB 35 355 MB
GPU queue.Wait … did not complete within 5000 ms 19, first at 118.6 s 10, first at 124.5 s 14, first at 117.2 s
Write64 cycle breaks 13 9 14
draws (skipped) / dispatches (skipped), last report 15 134 (12 629) / 32 768 (2 828) at 108 s 12 072 (19 811) / 47 358 (8 193) at 118 s 16 384 (12 422) / 35 150 (2 798) at 134 s

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 main run is not enough to read the 19 / 10 / 14 as a trend, and the frames after loading stay black, as on main.

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 140
exit: 0x0
frames shown: 1434 (PresentX 1435)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 33004 MB

this PR merged onto it (run 2):

xcl-smoke v1
commit: 458ba4d28593b93bb547e7cd27a92814c2ee4ecb
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 140
exit: 0x0
frames shown: 1402 (PresentX 1406)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 35355 MB

Not tested

  • the test suite at this merge (only the runs above)
  • the PR head on its own base

AI use

  • Claude Code, Claude Opus 5.5: merged and built the PR, ran the runs, read the logs and wrote this report.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Two regression pairs for 71d3a38 against main 47efa2e (this PR's base), for the Regression run section. Both pairs pass: no device removal, no crash. The first PR run was low (87 % of main's frames); the second pair, run right after to check it, has the PR at 103 %, so the drop did not repeat.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200.
  • scripts/smoke.ps1, the same retail title for 60 s each: main at 47efa2e (this PR's base) first, then this PR's head, one after the other on the same machine; then the same pair again about 10 minutes later.

Pair 1, main 47efa2e:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1323 (PresentX 1324)
presents per 2 s (last 3): 19 45 48
device removals: 0
crashes: 0
peak commit: 26877 MB

Pair 1, this PR, 71d3a38:

xcl-smoke v1
commit: 71d3a384d9b35ed845f066ea5c62d7030e8be68a
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1147 (PresentX 1148)
presents per 2 s (last 3): 0 1 13
device removals: 0
crashes: 0
peak commit: 25610 MB

Pair 2, main 47efa2e:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1317 (PresentX 1317)
presents per 2 s (last 3): 35 53 23
device removals: 0
crashes: 0
peak commit: 28261 MB

Pair 2, this PR, 71d3a38:

xcl-smoke v1
commit: 71d3a384d9b35ed845f066ea5c62d7030e8be68a
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1360 (PresentX 1360)
presents per 2 s (last 3): 5 15 45
device removals: 0
crashes: 0
peak commit: 26265 MB
frames peak commit
pair 1 1147 / 1323 (87 %) 25610 / 26877 MB (95 %)
pair 2 1360 / 1317 (103 %) 26265 / 28261 MB (93 %)

Presents per 2 s over the whole run (from the activity (2 s) lines):

  • pair 1 main: 0 30 59 50 27 60 60 60 60 60 60 60 60 60 59 46 54 60 60 60 45 56 23 6 2 25 10 19 45 48
  • pair 1 PR: 0 28 59 11 27 60 60 41 60 60 60 60 60 60 60 54 41 60 60 60 58 44 38 2 0 5 6 0 1 13
  • pair 2 main: 0 31 60 51 31 60 60 60 60 60 60 60 60 60 59 46 51 60 60 60 46 49 15 1 8 5 33 35 53 23
  • pair 2 PR: 0 32 57 56 31 60 60 60 60 60 60 60 60 60 59 43 52 60 60 60 60 60 40 59 21 3 2 5 15 45

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 main), and in pair 2 it started later in the PR's run.

For #505. The program at 100 % before the device removal on this machine is the BVH builder's refit, cs b6043104de672057. It is a wave32 program (xcl shaders --recomp: "wave32: 1"), so it doesn't run in the split form, and this PR's poll loop doesn't touch it.

Not tested

AI use: Claude Code (Claude Opus 5.5)

@ExoCalibra

Copy link
Copy Markdown

Tested exact head 71d3a38 (clean merge onto main b7aa9f3).

Tested

  • NVIDIA GeForce RTX 3080 Ti (12,084 MiB VRAM, Wave32, mesh shaders), driver 610.88 (32.0.16.1088), Ryzen 7 7800X3D, 63.1 GB RAM, Windows 11 Pro 10.0.26200, rustc 1.100.0, DXC 1.8.2502.11.
  • .\scripts\test.ps1 (debug): 742 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware. Passed: split_wave64_spin_polls_are_not_adds_of_zero, gpu_safe_s_barrier_multi_warp_and_early_endpgm, and all 5 gpu_split_wave64_* tests.
  • cargo build --release -p xcl + 60 s scripts/smoke.ps1 (XCL_NETWORK=0, compared against base main 47efa2e; identical 6529 MB local VRAM, 3577 MB target pages, 0 skipped draws/dispatches once past startup):

main (47efa2e, warm cache):

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 3080 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1190 (PresentX 1190)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15984 MB

PR #1244 (71d3a38, run 2 — cold re-hashed split-wave64 PSO compiles of 24.0 s / 40.3 s + 12.3 s startup delay, then steady 60 presents/2 s):

xcl-smoke v1
commit: 71d3a384d9b35ed845f066ea5c62d7030e8be68a
gpu: NVIDIA GeForce RTX 3080 Ti
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 729 (PresentX 729)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15964 MB

(Run 1 on 71d3a38: 710 frames, 58 59 60 presents/2 s, 15705 MB peak commit, 0 device removals, 0 crashes; 11.6 s cold compute PSO compile.)

Notes

  • Checked crates/xcl/src/gpu/recomp/emit.rs: no InterlockedAdd(..., 0u, ...) spin polls remain.

Not tested

  • AMD / Linux RADV / native wave64, gameplay past menus (60 s startup only).

AI use

  • Antigravity (Gemini 4 Neon) ran the tests/smoke and drafted this report; checked by me.

@SlopTart

Copy link
Copy Markdown

RDNA3 confirmation, as requested on #847: PR head 71d3a38 on RX 7900 XT (RADV NAVI31) - the whole gpu_split_wave64_* family goes green in forced split mode (XCL_SPLIT_WAVE64=1), every test solo, 2 runs each:

  • gpu_split_wave64_cross_half_operations: ok, ok (was FAILED solo 2/2 on main, and was the polluter that flipped waves_diverge red in family runs)
  • gpu_split_wave64_masks_read_whole_after_partial_writes: ok, ok (was deterministic FAILED 3/3 solo)
  • gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves: ok, ok (was self-flaky 2/3 FAILED, 157 vs 164 delta)
  • gpu_split_wave64_waves_diverge: ok, ok
  • gpu_split_wave64_lane_local_masks: ok, ok
  • gpu_geometry_wave32_prefix_count_over_a_mask: ok, ok (the Recompiler: ds_bpermute_b32 in wave64 may stay within each 32-lane half on RDNA2 (needs a hardware run) #772 side of the root cause)

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 x86_64-pc-windows-gnu, XCL_NETWORK=0, --exact --test-threads=1.

Counts only, no game data.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@grahamster2

Copy link
Copy Markdown
Collaborator

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 bench_split_wave64 loop: 2^18 threads, one v_readfirstlane exchange per iteration, GPU timestamps, median of 7 to 9 dispatches.

64-thread groups no exchange 1 exchange / iteration
native wave32 (reference) 3.1 ms 3.7 ms
split, counter spin (XCL_X_SPIN 1, default since #798) 3.4 ms 13.2 ms
split, group barrier (XCL_WAVE64_SPIN=0) 3.4 ms 5.7 ms

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.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks grahamster2. The same bench_split_wave64 on an RTX 3070 (Ampere, driver 616.56), release build, 2^18 threads x 32768 iterations, main 6ea813a and this PR's 71d3a38, with one exchange per iteration (v_cmp + v_cndmask + v_readfirstlane):

64-thread groups 256-thread groups
main, counter spin (default) 75.1 ms (3.59x wave32) 74.2 ms (3.83x)
main, XCL_WAVE64_SPIN=0 32.6 ms (1.55x) 74.8 ms (still counter-paired)
this PR, compare-exchange poll 77.1 ms (3.62x) 73.7 ms (3.75x)
this PR, XCL_WAVE64_SPIN=0 32.9 ms (1.58x) 78.6 ms

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.

@grahamster2

Copy link
Copy Markdown
Collaborator

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 xcl_budget, or desyncs. On an RTX 3080, a meet costs:

bench_split_wave64 loop, 64-thread groups, 1 exchange / iteration time
native wave32 3.7 ms
split, spin (default) 13.2 ms
split, group barrier (XCL_WAVE64_SPIN=0) 5.7 ms
split, spin, with the 32 KB LDS block (before #2146) 41.9 ms
split, barrier, with the 32 KB LDS block 13.9 ms

257 of the 374 split compute programs in the title I checked use 64-thread groups. Most of their 25k static exchanges are v_cmp masks (#1597).

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 (XCL_X_SPIN 0) for groups of at most one console wave, with XCL_WAVE64_SPIN=1 forcing the spin back? Multi-wave groups keep the counter spin. Or do you want the spin kept as the default there for the desync case, and the cost won back on the poll side instead (#1244)? I can do either, with bench_split_wave64 numbers and an NVIDIA soak of the GPU tests.

AI-assisted (Claude Code, Claude Opus 5.5); measurements from runs on my machine.

@upipibi

upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@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 (InterlockedCompareExchange instead of an add of 0), and the barrier meet has no poll. #1244 still matters for multi-wave groups and for XCL_WAVE64_SPIN=1.

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. s_endpgm becomes Flow::End (recomp/emit.rs:1263 on main), which lowers to pc = 0xFFFFFFFFu; (recomp/mod.rs:1174): a jump to the program's end, not a return, so no hardware wave leaves main early. I did not check the xcl_budget point or the partial-group case. The cost you named still applies: if a translator bug desyncs the halves, a half misses the barrier and the dispatch hangs (TDR) instead of giving wrong output. Keeping XCL_WAVE64_SPIN=1 as the way back covers debugging that.

I can run the NVIDIA GPU-test soak on the 3070 (Ampere) at your head once it's up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants