Recompiler: split-wave64 one-wave groups can meet at a group barrier (opt-in, XCL_WAVE64_BARRIER=1) #2377

Open
github-bot wants to merge 1 commit from github-bot/gh-2377 into main AGit
Owner

@⁠grahamster2 on GitHub · 2026-11-25 17:24 UTC · original
grahamster2:wave64-barrier-default → main · +155 −17 · 4 files · 1 commits · open

In the HLSL split-wave64 form, a group of one console wave (64 threads or fewer) is just the two 32-lane halves of that wave. They meet through the bounded counter spin (XCL_X_SPIN 1) by default since #798, which costs about 2.3x the group barrier per exchange on Ampere (see #1244: RTX 3080 and RTX 3070 numbers). This PR adds an opt-in for the cheaper group barrier on one-wave groups, as the direct DXIL translator already does for 33-64-thread groups (Partner::Present, #1426). The default does not change: the counter spin stays, and the barrier needs XCL_WAVE64_BARRIER=1.

An earlier head of this PR made the barrier the default. bmjask's review (P1) pointed out that the barrier is unbounded: a pair that desynchronises (a plain non-GLC s_load that sees two values, hazard 1 in docs/wave64-on-wave32.md) would hang the dispatch until a TDR, where the counters give up after a bounded wait and give wrong output instead. So the barrier is now something you ask for.

Design discussion: #1244 (last comments).

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: x64_spin_for(threads, spin, barrier) picks the meet form, and x64_spin calls it with XCL_WAVE64_SPIN and XCL_WAVE64_BARRIER. The rule:
    • more than 64 threads: always the counters;
    • 64 threads or fewer: XCL_WAVE64_SPIN set to 0 (trimmed) gives the barrier, as on main; set to anything else, including empty (as on main), it forces the counters. With XCL_WAVE64_SPIN unset, XCL_WAVE64_BARRIER set to anything but empty or 0 gives the barrier; otherwise the counters (the default).
    • So XCL_WAVE64_SPIN keeps its current meaning exactly, XCL_WAVE64_BARRIER=1 is a second way to the same barrier, and XCL_WAVE64_SPIN=1 wins over XCL_WAVE64_BARRIER=1.
  • crates/xcl/src/gpu/recomp/pso.rs: XCL_WAVE64_BARRIER joins the variables that bypass the shader cache (cache_allowed, and its test). Without it a cached counter-form shader would be served with the variable set, or the reverse.
  • docs/wave64-on-wave32.md ("Synchronisation"): says the barrier for one console wave is opt-in, why, and how the two variables interact.
  • crates/xcl/src/gpu/recomp/tests.rs:
    • split_wave64_meet_form_by_group_size (unit test): x64_spin_for for 16, 32, 40 and 64 threads with every combination of XCL_WAVE64_SPIN (unset, 0, 0, empty, 1) and XCL_WAVE64_BARRIER (unset, empty, 0, 1, 1) that the rule distinguishes, and for 65 to 1024 threads; the emitted #define XCL_X_SPIN 1 for 64x1x1, 8x8x1, 4x4x4, 40, 32, 16, 256 and 8x8x4 groups (hard-coded, so checked in any environment for several-wave groups and when neither variable is set for the rest); and that a half without a partner leaves xcl_x_meet before either form.
    • gpu_split_wave64_one_wave_groups_end_early (GPU test): 64-, 48- and 40-thread groups make an exchange, then odd groups end early on a scalar branch and even ones exchange again and store. It checks the form it expects (the counters, or the barrier when XCL_WAVE64_BARRIER asks for it) and that no half is left waiting. With the default settings it covers the counter form; the barrier form runs when the variable is set (see Tested).
    • gpu_split_wave64_waves_diverge expects the counters unless a variable asks for the barrier in the 64-thread case. bench_split_wave64 labels its rows with the form x64_spin_for picks.

Why the barrier holds in a one-wave group, and when it does not (checked in the code at main 0829441; this part has not been touched since)

  • Early exit: s_endpgm becomes Flow::End, which lowers to pc = 0xFFFFFFFFu; (recomp/mod.rs, Flow::End arm). That is a jump to the end of the program, not a return, so no hardware wave leaves main early.
  • xcl_budget: LOOP_GUARD is a per-lane counter that both halves start at the same value and decrement once per loop iteration. Branches are on SGPRs, SCC, VCCZ or EXECZ. x64_masks treats any whole read of a mask as needing the exchange; lane reads and GLC/DLC scalar loads are exchanged. So the halves branch the same way and spend their budgets equally, as long as the SGPRs they branch on are the same.
  • The exception is a plain (non-GLC) s_load, which is not exchanged: each half loads on its own. A one-wave group whose halves can see two different values (a group that writes memory and reads it back with a plain s_load, or one that polls memory another group writes, then branches on the result) can split its halves. With the barrier that hangs the dispatch (TDR); with the counters it gives bounded wrong output. That is why the barrier is opt-in. On the console such a load is not coherent either, so a title that relies on it is already racing.
  • Partial groups: in a group of 32 threads or fewer xcl_xn is 0 in the only hardware wave, and xcl_x_meet returns before the #if XCL_X_SPIN, so neither form meets. In a 33-64-thread group both halves have xcl_xn > 0 and both meet.
  • ES+GS (split geometry, 64 threads) follows the same rule: the ES phase has xcl_xn = 32 in both halves, the GS phase xcl_xn = 0 (no meets).
  • Any other desynchronisation of the halves (a translator bug) likewise hangs under the barrier and gives wrong output under the counters.

Tested

  • NVIDIA GeForce RTX 3080 10 GB (driver 610.88, 32-lane waves only, so the split form), AMD Ryzen 5 7600X, Windows 11 Pro 10.0.26200, rustc 1.94.0. Debug build for the tests, release for the bench and smoke.
  • On head 0c44653 (rebased on main b49be183), cargo test -p xcl --lib: 1311 passed, 0 failed, 27 ignored, 24 SKIPPED lines (the no wave64 GPU cases and three direct DXIL refusals of f16 or f32-to-f16 forms).
  • cargo test -p xcl --lib gpu::recomp::tests: 169 passed, 0 failed, 17 ignored with XCL_WAVE64_SPIN and XCL_WAVE64_BARRIER unset, with XCL_WAVE64_BARRIER=1 (the barrier form everywhere it applies, including the early-end test), with XCL_WAVE64_SPIN=1 and with XCL_WAVE64_SPIN=0.
  • The whole lib suite with XCL_WAVE64_BARRIER=1 or XCL_WAVE64_SPIN=1 set: 1310 passed, 1 failed in each, pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk. That is the shader cache being bypassed by the variable on purpose (the same for the existing XCL_WAVE64_SPIN), not a recompiler failure.
  • The earlier "Build and test" failure (run 45664376007) was a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (left: 3, right: 1) on the previous head, which was based on a main from before #2420 changed that test. It passes on this head, rebased on current main, in every run above. I did not rerun the old head to confirm it was that test's staleness and not the barrier default; the head is rebased and the default is gone either way.
  • bench_split_wave64 (cargo test --release -p xcl --lib bench_split_wave64 -- --ignored --nocapture, 2^18 threads x 32768 iterations, GPU timestamps, median of 9). It ran on main 0829441 and on this PR's earlier head 34d2583, which selected the barrier for one-wave groups; the barrier code path is the one XCL_WAVE64_BARRIER=1 selects now, but I did not rerun the bench on this head.
main, 64-thread groups (counters) barrier, 64-thread groups main, 256-thread groups barrier setting, 256-thread groups
no exchange: wave32 / split 12.5 / 13.7 ms (1.10x) 11.5 / 12.7 ms (1.10x) 11.7 / 13.0 ms (1.11x, spin) 11.8 / 13.1 ms (1.11x, spin)
1 exchange / iteration: wave32 / split 13.5 / 53.0 ms (3.93x) 13.6 / 23.0 ms (1.69x) 13.8 / 51.0 ms (3.70x, spin) 13.8 / 51.0 ms (3.70x, spin)

One run each. 256-thread groups always spin, as intended.

Regression run

The smoke run is with the default settings, which give the same recompiler output as main (the counters). A run with XCL_WAVE64_BARRIER=1 on this head showed 1634 frames, no device removal, no crash, peak commit 14849 MB (not a second block, one 60 s run).

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14891 MB

PR:

xcl-smoke v1
commit: 0c446533681f07cf43e91479a7abf869e2aab28e
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1640 (PresentX 1640)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14874 MB

One 60 s run each, so a gap of a few frames is not meaningful.

Not tested

  • The whole workspace suite (cargo test --workspace): only the xcl lib tests ran.
  • AMD, and any GPU with 64-lane waves (they do not use the split form).
  • An NVIDIA soak of the GPU tests (many repeated runs).
  • Gameplay past the first 60 s of the retail title, and whether XCL_WAVE64_BARRIER=1 makes the retail title's one-wave split programs faster in frame time.
  • A program that splits its halves through a plain s_load (the hazard above): no test builds one, so there is no regression test that the default does not hang on it, only the argument that the counters are bounded.
  • No repeated bench_split_wave64 runs, no bench on this head, and no run with the 32 KB LDS block.

AI use

  • Claude Code (Claude Sonnet 5.5) made the change from the review, wrote the tests and this description, and ran the tests and the smoke runs. The first version of the PR was written by Claude Code (Claude Opus 5.5).

AI-assisted (Claude Code).

**@⁠grahamster2** on GitHub · 2026-11-25 17:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377) `grahamster2:wave64-barrier-default` → `main` · +155 −17 · 4 files · 1 commits · open In the HLSL split-wave64 form, a group of one console wave (64 threads or fewer) is just the two 32-lane halves of that wave. They meet through the bounded counter spin (`XCL_X_SPIN 1`) by default since #798, which costs about 2.3x the group barrier per exchange on Ampere (see #1244: RTX 3080 and RTX 3070 numbers). This PR adds an opt-in for the cheaper group barrier on one-wave groups, as the direct DXIL translator already does for 33-64-thread groups (`Partner::Present`, #1426). **The default does not change**: the counter spin stays, and the barrier needs `XCL_WAVE64_BARRIER=1`. An earlier head of this PR made the barrier the default. bmjask's review (P1) pointed out that the barrier is unbounded: a pair that desynchronises (a plain non-GLC `s_load` that sees two values, hazard 1 in `docs/wave64-on-wave32.md`) would hang the dispatch until a TDR, where the counters give up after a bounded wait and give wrong output instead. So the barrier is now something you ask for. Design discussion: #1244 (last comments). **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: `x64_spin_for(threads, spin, barrier)` picks the meet form, and `x64_spin` calls it with `XCL_WAVE64_SPIN` and `XCL_WAVE64_BARRIER`. The rule: - more than 64 threads: always the counters; - 64 threads or fewer: `XCL_WAVE64_SPIN` set to `0` (trimmed) gives the barrier, as on `main`; set to anything else, including empty (as on `main`), it forces the counters. With `XCL_WAVE64_SPIN` unset, `XCL_WAVE64_BARRIER` set to anything but empty or `0` gives the barrier; otherwise the counters (the default). - So `XCL_WAVE64_SPIN` keeps its current meaning exactly, `XCL_WAVE64_BARRIER=1` is a second way to the same barrier, and `XCL_WAVE64_SPIN=1` wins over `XCL_WAVE64_BARRIER=1`. - `crates/xcl/src/gpu/recomp/pso.rs`: `XCL_WAVE64_BARRIER` joins the variables that bypass the shader cache (`cache_allowed`, and its test). Without it a cached counter-form shader would be served with the variable set, or the reverse. - `docs/wave64-on-wave32.md` ("Synchronisation"): says the barrier for one console wave is opt-in, why, and how the two variables interact. - `crates/xcl/src/gpu/recomp/tests.rs`: - `split_wave64_meet_form_by_group_size` (unit test): `x64_spin_for` for 16, 32, 40 and 64 threads with every combination of `XCL_WAVE64_SPIN` (unset, `0`, ` 0 `, empty, `1`) and `XCL_WAVE64_BARRIER` (unset, empty, `0`, `1`, ` 1 `) that the rule distinguishes, and for 65 to 1024 threads; the emitted `#define XCL_X_SPIN 1` for 64x1x1, 8x8x1, 4x4x4, 40, 32, 16, 256 and 8x8x4 groups (hard-coded, so checked in any environment for several-wave groups and when neither variable is set for the rest); and that a half without a partner leaves `xcl_x_meet` before either form. - `gpu_split_wave64_one_wave_groups_end_early` (GPU test): 64-, 48- and 40-thread groups make an exchange, then odd groups end early on a scalar branch and even ones exchange again and store. It checks the form it expects (the counters, or the barrier when `XCL_WAVE64_BARRIER` asks for it) and that no half is left waiting. With the default settings it covers the counter form; the barrier form runs when the variable is set (see Tested). - `gpu_split_wave64_waves_diverge` expects the counters unless a variable asks for the barrier in the 64-thread case. `bench_split_wave64` labels its rows with the form `x64_spin_for` picks. **Why the barrier holds in a one-wave group, and when it does not** (checked in the code at `main` 0829441; this part has not been touched since) - Early exit: `s_endpgm` becomes `Flow::End`, which lowers to `pc = 0xFFFFFFFFu;` (`recomp/mod.rs`, `Flow::End` arm). That is a jump to the end of the program, not a `return`, so no hardware wave leaves `main` early. - `xcl_budget`: `LOOP_GUARD` is a per-lane counter that both halves start at the same value and decrement once per loop iteration. Branches are on SGPRs, SCC, VCCZ or EXECZ. `x64_masks` treats any whole read of a mask as needing the exchange; lane reads and GLC/DLC scalar loads are exchanged. So the halves branch the same way and spend their budgets equally, as long as the SGPRs they branch on are the same. - The exception is a plain (non-GLC) `s_load`, which is not exchanged: each half loads on its own. A one-wave group whose halves can see two different values (a group that writes memory and reads it back with a plain `s_load`, or one that polls memory another group writes, then branches on the result) can split its halves. With the barrier that hangs the dispatch (TDR); with the counters it gives bounded wrong output. That is why the barrier is opt-in. On the console such a load is not coherent either, so a title that relies on it is already racing. - Partial groups: in a group of 32 threads or fewer `xcl_xn` is 0 in the only hardware wave, and `xcl_x_meet` returns before the `#if XCL_X_SPIN`, so neither form meets. In a 33-64-thread group both halves have `xcl_xn > 0` and both meet. - ES+GS (split geometry, 64 threads) follows the same rule: the ES phase has `xcl_xn = 32` in both halves, the GS phase `xcl_xn = 0` (no meets). - Any other desynchronisation of the halves (a translator bug) likewise hangs under the barrier and gives wrong output under the counters. **Tested** - NVIDIA GeForce RTX 3080 10 GB (driver 610.88, 32-lane waves only, so the split form), AMD Ryzen 5 7600X, Windows 11 Pro 10.0.26200, rustc 1.94.0. Debug build for the tests, release for the bench and smoke. - On head `0c44653` (rebased on `main` b49be183), `cargo test -p xcl --lib`: 1311 passed, 0 failed, 27 ignored, 24 SKIPPED lines (the `no wave64` GPU cases and three direct DXIL refusals of f16 or f32-to-f16 forms). - `cargo test -p xcl --lib gpu::recomp::tests`: 169 passed, 0 failed, 17 ignored with `XCL_WAVE64_SPIN` and `XCL_WAVE64_BARRIER` unset, with `XCL_WAVE64_BARRIER=1` (the barrier form everywhere it applies, including the early-end test), with `XCL_WAVE64_SPIN=1` and with `XCL_WAVE64_SPIN=0`. - The whole lib suite with `XCL_WAVE64_BARRIER=1` or `XCL_WAVE64_SPIN=1` set: 1310 passed, 1 failed in each, `pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk`. That is the shader cache being bypassed by the variable on purpose (the same for the existing `XCL_WAVE64_SPIN`), not a recompiler failure. - The earlier "Build and test" failure (run 45664376007) was `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` (`left: 3, right: 1`) on the previous head, which was based on a `main` from before #2420 changed that test. It passes on this head, rebased on current `main`, in every run above. I did not rerun the old head to confirm it was that test's staleness and not the barrier default; the head is rebased and the default is gone either way. - `bench_split_wave64` (`cargo test --release -p xcl --lib bench_split_wave64 -- --ignored --nocapture`, 2^18 threads x 32768 iterations, GPU timestamps, median of 9). It ran on `main` 0829441 and on this PR's earlier head 34d2583, which selected the barrier for one-wave groups; the barrier code path is the one `XCL_WAVE64_BARRIER=1` selects now, but I did not rerun the bench on this head. | | `main`, 64-thread groups (counters) | barrier, 64-thread groups | `main`, 256-thread groups | barrier setting, 256-thread groups | |---|---|---|---|---| | no exchange: wave32 / split | 12.5 / 13.7 ms (1.10x) | 11.5 / 12.7 ms (1.10x) | 11.7 / 13.0 ms (1.11x, spin) | 11.8 / 13.1 ms (1.11x, spin) | | 1 exchange / iteration: wave32 / split | 13.5 / 53.0 ms (3.93x) | 13.6 / 23.0 ms (1.69x) | 13.8 / 51.0 ms (3.70x, spin) | 13.8 / 51.0 ms (3.70x, spin) | One run each. 256-thread groups always spin, as intended. **Regression run** The smoke run is with the default settings, which give the same recompiler output as `main` (the counters). A run with `XCL_WAVE64_BARRIER=1` on this head showed 1634 frames, no device removal, no crash, peak commit 14849 MB (not a second block, one 60 s run). main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3080 title: 5d6132ca seconds: 60 exit: 0x0 frames shown: 1642 (PresentX 1642) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14891 MB ``` PR: ``` xcl-smoke v1 commit: 0c446533681f07cf43e91479a7abf869e2aab28e gpu: NVIDIA GeForce RTX 3080 title: 5d6132ca seconds: 60 exit: 0x0 frames shown: 1640 (PresentX 1640) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14874 MB ``` One 60 s run each, so a gap of a few frames is not meaningful. **Not tested** - The whole workspace suite (`cargo test --workspace`): only the `xcl` lib tests ran. - AMD, and any GPU with 64-lane waves (they do not use the split form). - An NVIDIA soak of the GPU tests (many repeated runs). - Gameplay past the first 60 s of the retail title, and whether `XCL_WAVE64_BARRIER=1` makes the retail title's one-wave split programs faster in frame time. - A program that splits its halves through a plain `s_load` (the hazard above): no test builds one, so there is no regression test that the default does not hang on it, only the argument that the counters are bounded. - No repeated `bench_split_wave64` runs, no bench on this head, and no run with the 32 KB LDS block. **AI use** - Claude Code (Claude Sonnet 5.5) made the change from the review, wrote the tests and this description, and ran the tests and the smoke runs. The first version of the PR was written by Claude Code (Claude Opus 5.5). _AI-assisted (Claude Code)._
In the HLSL split-wave64 form a group of one console wave (64 threads or
fewer) is just the two 32-lane halves, and they take the same branches
(on exchanged, wave-uniform state), so both reach every exchange. Since
#798 they met through the bounded counter spin there too, which costs
about 2.3x the group barrier per exchange on Ampere (#1244: 13.2 ms vs
5.7 ms on an RTX 3080 in bench_split_wave64, 64-thread groups, one
exchange per iteration; 3.6x vs 1.55x wave32 on an RTX 3070).

x64_spin_for picks the form: groups of more than one console wave keep
the counters (a barrier would wait for other console waves); one-wave
groups now get the barrier, as the direct DXIL translator does
(Partner::Present, #1426). XCL_WAVE64_SPIN=1 forces the counters
everywhere, for debugging a desynchronised pair (wrong output instead
of a hang); =0 keeps the barrier, as before.

Assisted-by: Claude Code (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:29:31 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 17:32 UTC · original · edited 2026-11-26 06:55 UTC

Update for head 0c44653 (now opt-in): rerun on main b49be18, in both modes.

  • Default (XCL_WAVE64_BARRIER unset): paired gpu:: runs, RTX 3060 710 → 712 passed, 0 failed; RX 9070 XT with XCL_SPLIT_WAVE64=1 708 → 710 passed, 2 failed (#2115, the same on main). The only result changes are gpu_split_wave64_one_wave_groups_end_early and split_wave64_meet_form_by_group_size, both ok, with no new skips. Soak on the RTX 3060: split_wave64 ×10 = 120 test runs, 0 failed.
  • XCL_WAVE64_BARRIER=1: split_wave64 ×5 on the RTX 3060 = 60 test runs, 0 failed. ×2 on the RX 9070 XT with XCL_SPLIT_WAVE64=1 = 24 test runs, 0 failed. gpu_split_wave64_one_wave_groups_end_early ok there, with no SKIPPED.

An NVIDIA soak of the split-wave64 GPU tests (listed as untested), on an Ampere RTX 3060, plus the change on an AMD driver with the split form forced. No failures.

Head 6ee3743 applied on main 68a284a, debug, Windows 11 Pro 26200.

Soak, RTX 3060 (driver 32.0.16.1088, 32-lane waves, so the split form by default): cargo test -p xcl --lib -- split_wave64 --test-threads=4, 10 runs back to back = 120 test runs, 0 failed (12 tests per run, gpu_split_wave64_one_wave_groups_end_early among them).

Paired against main, whole gpu:: filter (cargo test -p xcl --lib -- gpu:: --test-threads=4):

main this PR
RTX 3060 649 passed, 1 failed, 24 SKIPPED 651 passed, 1 failed, 24 SKIPPED
RX 9070 XT (RDNA4, 32.0.32029.2010) with XCL_SPLIT_WAVE64=1 647 passed, 3 failed, 6 SKIPPED 649 passed, 3 failed, 6 SKIPPED

On both cards the only differences are the 2 new tests (gpu_split_wave64_one_wave_groups_end_early, split_wave64_meet_form_by_group_size, both ok); no existing test changes result or skip state. The failures are all on main without this PR: a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier on both (since #2074's merge, see there) and, on the RX 9070 XT, the #2115 fuzz seeds. So the group-barrier meet also holds on an AMD driver when it runs the split form.

Not tested: the whole workspace suite, frame time in a title, a soak longer than 10 runs.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 17:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377#issuecomment-7169650772) · edited 2026-11-26 06:55 UTC **Update for head `0c44653`** (now opt-in): rerun on `main` `b49be18`, in both modes. - **Default (`XCL_WAVE64_BARRIER` unset):** paired `gpu::` runs, RTX 3060 710 → 712 passed, 0 failed; RX 9070 XT with `XCL_SPLIT_WAVE64=1` 708 → 710 passed, 2 failed (#2115, the same on `main`). The only result changes are `gpu_split_wave64_one_wave_groups_end_early` and `split_wave64_meet_form_by_group_size`, both ok, with no new skips. Soak on the RTX 3060: `split_wave64` ×10 = 120 test runs, 0 failed. - **`XCL_WAVE64_BARRIER=1`:** `split_wave64` ×5 on the RTX 3060 = 60 test runs, 0 failed. ×2 on the RX 9070 XT with `XCL_SPLIT_WAVE64=1` = 24 test runs, 0 failed. `gpu_split_wave64_one_wave_groups_end_early` ok there, with no SKIPPED. An NVIDIA soak of the split-wave64 GPU tests (listed as untested), on an Ampere RTX 3060, plus the change on an AMD driver with the split form forced. No failures. Head `6ee3743` applied on `main` `68a284a`, debug, Windows 11 Pro 26200. **Soak, RTX 3060** (driver 32.0.16.1088, 32-lane waves, so the split form by default): `cargo test -p xcl --lib -- split_wave64 --test-threads=4`, 10 runs back to back = **120 test runs, 0 failed** (12 tests per run, `gpu_split_wave64_one_wave_groups_end_early` among them). **Paired against `main`, whole `gpu::` filter** (`cargo test -p xcl --lib -- gpu:: --test-threads=4`): | | `main` | this PR | |---|---|---| | RTX 3060 | 649 passed, 1 failed, 24 SKIPPED | 651 passed, 1 failed, 24 SKIPPED | | RX 9070 XT (RDNA4, 32.0.32029.2010) with `XCL_SPLIT_WAVE64=1` | 647 passed, 3 failed, 6 SKIPPED | 649 passed, 3 failed, 6 SKIPPED | On both cards the only differences are the 2 new tests (`gpu_split_wave64_one_wave_groups_end_early`, `split_wave64_meet_form_by_group_size`, both ok); no existing test changes result or skip state. The failures are all on `main` without this PR: `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` on both (since #2074's merge, see there) and, on the RX 9070 XT, the #2115 fuzz seeds. So the group-barrier meet also holds on an AMD driver when it runs the split form. Not tested: the whole workspace suite, frame time in a title, a soak longer than 10 runs. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 17:44 UTC · original

Independent AMD RDNA4 (native wave64) full workspace + retail-title smoke report on exact head 6ee3743c788bb7485f1a372adf95bd98ea3eabe9 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1272 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record).
    • Both PR tests passed (no skips): gpu::recomp::tests::split_wave64_meet_form_by_group_size and gpu::recomp::tests::gpu_split_wave64_one_wave_groups_end_early.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release; note this GPU runs native wave64 in the title rather than split wave64)

xcl-smoke v1
commit: 6ee3743c788bb7485f1a372adf95bd98ea3eabe9
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1596 (PresentX 1596)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15888 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • Wave32-only GPUs (NVIDIA/Intel) in the retail title; repeated GPU soak.

AI use

  • Antigravity with Gemini 4 Neon ran the build, full workspace test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 17:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377#issuecomment-7169938361) Independent AMD RDNA4 (native wave64) full workspace + retail-title smoke report on exact head `6ee3743c788bb7485f1a372adf95bd98ea3eabe9` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1272 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). - Both PR tests passed (no skips): `gpu::recomp::tests::split_wave64_meet_form_by_group_size` and `gpu::recomp::tests::gpu_split_wave64_one_wave_groups_end_early`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release; note this GPU runs native wave64 in the title rather than split wave64) ``` xcl-smoke v1 commit: 6ee3743c788bb7485f1a372adf95bd98ea3eabe9 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1596 (PresentX 1596) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15888 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - Wave32-only GPUs (NVIDIA/Intel) in the retail title; repeated GPU soak. **AI use** - Antigravity with Gemini 4 Neon ran the build, full workspace test suite, and smoke run and drafted this report.
Author
Owner

@⁠jordi-vancuijlenborg-vinci on GitHub · 2026-11-25 17:50 UTC · original

On an RTX 3080 10 GB with NVIDIA driver 621.01, I reproduced the single-wave speedup on the current PR head 6ee3743c788bb7485f1a372adf95bd98ea3eabe9.

Tested

Windows 11, i7-9700F, Rust 1.100.0 MSVC, release, DXC 1.9.2609.5. I used the same executable for both modes. A used the default group barrier for 64-thread groups. B forced the counters with XCL_WAVE64_SPIN=1. Run order was A, B, B, A. Each value is the median of nine GPU timestamp measurements from bench_split_wave64.

Split wave64 workload Default, two runs Forced counters, two runs
64 threads, one exchange per iteration 23.0 / 23.1 ms 57.2 / 60.9 ms
64 threads, no exchange in the loop 12.8 / 12.7 ms 12.7 / 12.7 ms
256 threads, one exchange per iteration 55.0 / 55.2 ms 55.2 / 54.7 ms

The 256-thread case used counters in both configurations. Nine focused correctness tests also passed with XCL_WAVE64_SPIN unset, set to 1, and set to 0. This includes the 40-, 48-, and 64-thread early-exit case. Per setting, 9 passed, 0 failed, 0 ignored, 0 skipped. The benchmark passed in each of the four runs.

Commands

Built with cargo test --locked --offline --release -p xcl --lib --no-run -j 3, then invoked the resulting test executable with XCL_ADAPTER=3080 and these arguments:

--test-threads=1 --nocapture --exact gpu::recomp::tests::split_wave64_meet_form_by_group_size gpu::recomp::tests::split_wave64_reduction_tail_rules gpu::recomp::tests::gpu_split_wave64_cross_half_operations gpu::recomp::tests::gpu_split_wave64_lane_local_masks gpu::recomp::tests::gpu_split_wave64_reduction_tails gpu::recomp::tests::gpu_split_wave64_masks_read_whole_after_partial_writes gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves gpu::recomp::tests::gpu_split_wave64_waves_diverge gpu::recomp::tests::gpu_split_wave64_one_wave_groups_end_early
--test-threads=1 --nocapture --exact --ignored gpu::recomp::tests::bench_split_wave64

Not tested

Game frame rate, other adapters and the full workspace suite.

OpenAI Codex (GPT-6.2 Astra Extra High) ran the tests and drafted this report.

**@⁠jordi-vancuijlenborg-vinci** on GitHub · 2026-11-25 17:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377#issuecomment-7170072171) On an RTX 3080 10 GB with NVIDIA driver 621.01, I reproduced the single-wave speedup on the current PR head `6ee3743c788bb7485f1a372adf95bd98ea3eabe9`. **Tested** Windows 11, i7-9700F, Rust 1.100.0 MSVC, release, DXC 1.9.2609.5. I used the same executable for both modes. A used the default group barrier for 64-thread groups. B forced the counters with `XCL_WAVE64_SPIN=1`. Run order was A, B, B, A. Each value is the median of nine GPU timestamp measurements from `bench_split_wave64`. | Split wave64 workload | Default, two runs | Forced counters, two runs | |---|---:|---:| | 64 threads, one exchange per iteration | 23.0 / 23.1 ms | 57.2 / 60.9 ms | | 64 threads, no exchange in the loop | 12.8 / 12.7 ms | 12.7 / 12.7 ms | | 256 threads, one exchange per iteration | 55.0 / 55.2 ms | 55.2 / 54.7 ms | The 256-thread case used counters in both configurations. Nine focused correctness tests also passed with `XCL_WAVE64_SPIN` unset, set to `1`, and set to `0`. This includes the 40-, 48-, and 64-thread early-exit case. Per setting, 9 passed, 0 failed, 0 ignored, 0 skipped. The benchmark passed in each of the four runs. <details><summary>Commands</summary> Built with `cargo test --locked --offline --release -p xcl --lib --no-run -j 3`, then invoked the resulting test executable with `XCL_ADAPTER=3080` and these arguments: ```text --test-threads=1 --nocapture --exact gpu::recomp::tests::split_wave64_meet_form_by_group_size gpu::recomp::tests::split_wave64_reduction_tail_rules gpu::recomp::tests::gpu_split_wave64_cross_half_operations gpu::recomp::tests::gpu_split_wave64_lane_local_masks gpu::recomp::tests::gpu_split_wave64_reduction_tails gpu::recomp::tests::gpu_split_wave64_masks_read_whole_after_partial_writes gpu::recomp::tests::gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves gpu::recomp::tests::gpu_split_wave64_waves_diverge gpu::recomp::tests::gpu_split_wave64_one_wave_groups_end_early --test-threads=1 --nocapture --exact --ignored gpu::recomp::tests::bench_split_wave64 ``` </details> **Not tested** Game frame rate, other adapters and the full workspace suite. OpenAI Codex (GPT-6.2 Astra Extra High) ran the tests and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 19:01 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 19:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377#issuecomment-7171708055) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-bot changed title from Recompiler: split-wave64 one-wave groups meet at a group barrier by default to Recompiler: split-wave64 one-wave groups can meet at a group barrier (opt-in, XCL_WAVE64_BARRIER=1) 2026-11-26 06:47:16 +00:00
github-bot force-pushed github-bot/gh-2377 from 6ee3743c78 to 0c44653368 2026-11-26 06:47:17 +00:00 Compare
Author
Owner

@⁠grahamster2 on GitHub · 2026-11-26 06:46 UTC · original

@⁠bmjask thanks, you were right and I took the first option: the barrier is no longer the default. Head is now 0c44653, rebased on current main.

  • The counter spin stays the default for every group size, so the hang you describe (a pair that desynchronises on a plain s_load) gives the old bounded wrong output again.
  • XCL_WAVE64_BARRIER=1 turns the barrier on for groups of 64 threads or fewer. XCL_WAVE64_SPIN keeps its current meaning: 0 still selects the barrier, any other value still forces the counters, and XCL_WAVE64_SPIN=1 wins over XCL_WAVE64_BARRIER=1. Groups of several console waves always use the counters.
  • XCL_WAVE64_BARRIER also bypasses the shader cache, like XCL_WAVE64_SPIN (pso.rs, with its test), so a cached shader of the other form is never served. docs/wave64-on-wave32.md now says the barrier is opt-in and why.
  • Tests: the unit test covers every combination of the two variables, and the GPU early-end test checks the counters by default and the barrier with XCL_WAVE64_BARRIER=1. The gpu::recomp::tests filter passes unset, with XCL_WAVE64_BARRIER=1, XCL_WAVE64_SPIN=1 and XCL_WAVE64_SPIN=0.

What I did not add: a test for the hang itself. No test builds a program whose halves split through a plain s_load, so "the default does not hang on it" rests on the counters being bounded, not on a regression test. The description says so.

The failing "Build and test" run was a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (left: 3, right: 1) on the old head, based on a main from before #2420 changed that test. It passes on this head in every run I did, but I did not rerun the old head, so I cannot say whether the barrier default also played a part.

Smoke pair on the new head (default settings, 60 s): 1640 frames against 1642 on main, no device removal, no crash. The title and description are updated.

AI use: Claude Code (Claude Sonnet 5.5) wrote this reply.

**@⁠grahamster2** on GitHub · 2026-11-26 06:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377#issuecomment-7184770194) @⁠bmjask thanks, you were right and I took the first option: the barrier is no longer the default. Head is now 0c44653, rebased on current `main`. - The counter spin stays the default for every group size, so the hang you describe (a pair that desynchronises on a plain `s_load`) gives the old bounded wrong output again. - `XCL_WAVE64_BARRIER=1` turns the barrier on for groups of 64 threads or fewer. `XCL_WAVE64_SPIN` keeps its current meaning: `0` still selects the barrier, any other value still forces the counters, and `XCL_WAVE64_SPIN=1` wins over `XCL_WAVE64_BARRIER=1`. Groups of several console waves always use the counters. - `XCL_WAVE64_BARRIER` also bypasses the shader cache, like `XCL_WAVE64_SPIN` (`pso.rs`, with its test), so a cached shader of the other form is never served. `docs/wave64-on-wave32.md` now says the barrier is opt-in and why. - Tests: the unit test covers every combination of the two variables, and the GPU early-end test checks the counters by default and the barrier with `XCL_WAVE64_BARRIER=1`. The `gpu::recomp::tests` filter passes unset, with `XCL_WAVE64_BARRIER=1`, `XCL_WAVE64_SPIN=1` and `XCL_WAVE64_SPIN=0`. What I did not add: a test for the hang itself. No test builds a program whose halves split through a plain `s_load`, so "the default does not hang on it" rests on the counters being bounded, not on a regression test. The description says so. The failing "Build and test" run was `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` (`left: 3, right: 1`) on the old head, based on a `main` from before #2420 changed that test. It passes on this head in every run I did, but I did not rerun the old head, so I cannot say whether the barrier default also played a part. Smoke pair on the new head (default settings, 60 s): 1640 frames against 1642 on `main`, no device removal, no crash. The title and description are updated. AI use: Claude Code (Claude Sonnet 5.5) wrote this reply.
Author
Owner

@⁠bmjask on GitHub · 2026-11-25 20:23 UTC · original · reviewed

P1: this makes a known split-wave64 divergence hazard a default GPU hang. For <=64-thread groups, emit.rs:5975-5985 selects unbounded GroupMemoryBarrierWithGroupSync in xcl_x_meet. A plain non-GLC s_load is not exchanged and can produce different scalar values in the two emulated halves; the PR description acknowledges this. The prior counter form eventually abandoned the exchange, but the new default can deadlock the dispatch/TDR. XCL_WAVE64_SPIN=1 is an opt-in escape hatch, not a safe default, and tests cover only synchronized early scalar end. Keep the bounded form by default or gate the barrier on proof/feature support, with a non-hanging regression or rejection test. The current Windows build/test check also fails and needs repair/re-run.

**@⁠bmjask** on GitHub · 2026-11-25 20:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/2377#pullrequestreview-6064422611) · **reviewed** P1: this makes a known split-wave64 divergence hazard a default GPU hang. For <=64-thread groups, emit.rs:5975-5985 selects unbounded GroupMemoryBarrierWithGroupSync in xcl_x_meet. A plain non-GLC s_load is not exchanged and can produce different scalar values in the two emulated halves; the PR description acknowledges this. The prior counter form eventually abandoned the exchange, but the new default can deadlock the dispatch/TDR. XCL_WAVE64_SPIN=1 is an opt-in escape hatch, not a safe default, and tests cover only synchronized early scalar end. Keep the bounded form by default or gate the barrier on proof/feature support, with a non-hanging regression or rejection test. The current Windows build/test check also fails and needs repair/re-run.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2377/head:github-bot/gh-2377'
git switch 'github-bot/gh-2377'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2377'
git switch 'github-bot/gh-2377'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2377'
git switch 'github-bot/gh-2377'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2377'
git switch 'main'
git merge --squash 'github-bot/gh-2377'
git switch 'main'
git merge --ff-only 'github-bot/gh-2377'
git switch 'main'
git merge 'github-bot/gh-2377'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.