Recompiler: wave-local remap and null guard cut cold compute PSO compiles #2544

Closed
brandostrong wants to merge 1 commit from upstream-pr/2554 into main
brandostrong commented 2026-11-25 22:45:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brandostrong on 2026-11-25T22:45:55Z.


Cold CreateComputePipelineState for a large split-wave64 compute program (a 1.5 MB cascade-shadow
resolve) was 38.3 s on an RTX 4090. Driver time tracks control-flow complexity, not bytes. Two
XCL-generated constructs dominate it: the wave64 exchange's spin loop (~16 s, its mere presence)
and the per-accessor out-of-window guard branch (~6 s, duplicated at every heap access). This PR
removes both, losslessly, for the programs where they are not needed.

What is in it

  • Memory: null descriptors for out-of-window heap accesses — console_heap.rs adds two null
    raw UAVs just past the window slots (MEM_NULL_LOAD reads 0, MEM_NULL_STORE discards writes);
    general allocation starts after them. No behaviour change until the emit path uses them.
  • Recompiler: branchless window guard via null descriptors — emit.rs mem_accessors redirects
    out-of-window load/store to the null descriptors with a select (no divergent branch);
    interlocked accessors keep the guard (they must return 0 and not modify). Differential test:
    out-of-window load/store/interlocked semantics unchanged.
  • Recompiler: wave-local compute runs one console wave per group — a split-wave64 compute program
    that shares nothing across its console waves (no LDS, no s_barrier) gets one console wave per
    hardware group, so the exchange's two halves are the whole group and meet with a group barrier
    instead of the spin loop. The console view is preserved (group id = hw id / ratio, thread id
    adds the wave offset); dispatch_ratio / dispatch_dim tell the runtime to launch ratio
    hardware groups per console group along dim, applied at dispatch_chain::dispatch. Indirect
    dispatch (ExecuteIndirect) reads group counts from the title's buffer on the GPU, so the CPU ratio
    cannot scale them: a lazily-built non-remapped fallback PSO (remap_fallback in real.rs, swapped
    in at bind.rs) is bound instead for a remapped pipeline, driven by Options.no_remap. forget_pso
    now clears the per-PSO dispatch ratio, so a reused PSO address no longer inherits a stale one.
    Differential test: a wave-local compute program gives identical output remapped; a non-wave-local one
    is unchanged.

Tested

  • hardware: RTX 4090 (NVIDIA), driver 32.0.16.1664, CPU i9-13900K, Windows 11 Pro build 26200,
    rustc 1.100.0, release
  • cargo test --workspace --release -- --test-threads=4: 1220 passed, 1 failed, 26 ignored (the 26
    are wave64 GPU tests that skip on this 32-lane NVIDIA adapter; the 1 failure is the same
    pre-existing lower_dxil test below)
  • cargo test -p xcl --lib --release recomp: 373 passed, 1 failed, 19 ignored — the 1 failure is
    lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, pre-existing
    on this NVIDIA adapter (present on clean main 68a284a; CI has no GPU), not from this change
  • goal measure xcl shaders shaders.rpf --measure-pso 062468c09af883b9 --windows 4 with
    XCL_HEAP_WINDOWS=1: median 12.33 s / 13.79 s over two runs (was 38.3 s), DXIL 1.50 MB → 1.08 MB
  • head-vs-main cold --measure-pso (repeat 1, same run window, uncontended), the 4 largest compute
    records: cascade-shadow 73fb752d7f62c3a5 17.9 s vs 53.1 s (−66 %), 062468c09af883b9 19.4 s vs
    42.5 s (−54 %); irradiance 517e7bab67ece93f 21.9 s vs 23.4 s (−6 %), 193d9a08bf6784bd 20.2 s vs
    21.1 s (−4 %). The win is concentrated on the wave64-spin cascade class; the irradiance records are
    not spin-dominated. Single cold samples are load-sensitive (the target's repeat-3 median above is 12.33 s)

Regression run

  • not run here: scripts/smoke.ps1 on a retail title was not executed for this PR (see Not tested).
    Help wanted: a scripts/smoke.ps1 -Game <title> run on main and on this head from anyone with a
    retail title (wave64 or wave32 adapter) would close the regression gap — post the two xcl-smoke
    blocks to #42.

Not tested

  • AMD / other drivers (measured on NVIDIA 4090 only; the levers change emitted DXIL, so they are
    driver-general by construction, but not measured on AMD)
  • indirect dispatch of a remapped program is handled by the fallback PSO but is not exercised by a GPU
    test (no title in the suite indirect-dispatches a wave-local remapped program); the fallback's
    translation is covered by the no_remap unit test
  • multi-dimensional and LDS/barrier compute groups (remap scoped to wave-local, clean multiple of 64)
  • the direct-DXIL path (XCL_DIRECT_DXIL=1) — remap is in the HLSL path only
  • no regression run on a retail title (scripts/smoke.ps1 not run); the change is validated by the
    recomp GPU suite and the head-vs-main compile benchmark above

AI use

  • Claude Code; wrote the code, the tests, and this description
<!-- greyfinch-sync:ivall/xcl:issue:5500475931 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554). Originally posted by [brandostrong](https://github.com/brandostrong) on 2026-11-25T22:45:55Z. --- Cold `CreateComputePipelineState` for a large split-wave64 compute program (a 1.5 MB cascade-shadow resolve) was 38.3 s on an RTX 4090. Driver time tracks control-flow complexity, not bytes. Two XCL-generated constructs dominate it: the wave64 exchange's spin loop (~16 s, its mere presence) and the per-accessor out-of-window guard branch (~6 s, duplicated at every heap access). This PR removes both, losslessly, for the programs where they are not needed. **What is in it** - `Memory: null descriptors for out-of-window heap accesses` — `console_heap.rs` adds two null raw UAVs just past the window slots (`MEM_NULL_LOAD` reads 0, `MEM_NULL_STORE` discards writes); general allocation starts after them. No behaviour change until the emit path uses them. - `Recompiler: branchless window guard via null descriptors` — `emit.rs` `mem_accessors` redirects out-of-window load/store to the null descriptors with a `select` (no divergent branch); interlocked accessors keep the guard (they must return 0 *and* not modify). Differential test: out-of-window load/store/interlocked semantics unchanged. - `Recompiler: wave-local compute runs one console wave per group` — a split-wave64 compute program that shares nothing across its console waves (no LDS, no `s_barrier`) gets one console wave per hardware group, so the exchange's two halves are the whole group and meet with a group barrier instead of the spin loop. The console view is preserved (group id = hw id / ratio, thread id adds the wave offset); `dispatch_ratio` / `dispatch_dim` tell the runtime to launch `ratio` hardware groups per console group along `dim`, applied at `dispatch_chain::dispatch`. Indirect dispatch (`ExecuteIndirect`) reads group counts from the title's buffer on the GPU, so the CPU ratio cannot scale them: a lazily-built non-remapped fallback PSO (`remap_fallback` in `real.rs`, swapped in at `bind.rs`) is bound instead for a remapped pipeline, driven by `Options.no_remap`. `forget_pso` now clears the per-PSO dispatch ratio, so a reused PSO address no longer inherits a stale one. Differential test: a wave-local compute program gives identical output remapped; a non-wave-local one is unchanged. **Tested** - hardware: RTX 4090 (NVIDIA), driver 32.0.16.1664, CPU i9-13900K, Windows 11 Pro build 26200, rustc 1.100.0, release - `cargo test --workspace --release -- --test-threads=4`: 1220 passed, 1 failed, 26 ignored (the 26 are wave64 GPU tests that skip on this 32-lane NVIDIA adapter; the 1 failure is the same pre-existing `lower_dxil` test below) - `cargo test -p xcl --lib --release recomp`: 373 passed, 1 failed, 19 ignored — the 1 failure is `lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, pre-existing on this NVIDIA adapter (present on clean `main` 68a284a; CI has no GPU), not from this change - goal measure `xcl shaders shaders.rpf --measure-pso 062468c09af883b9 --windows 4` with `XCL_HEAP_WINDOWS=1`: median 12.33 s / 13.79 s over two runs (was 38.3 s), DXIL 1.50 MB → 1.08 MB - head-vs-main cold `--measure-pso` (repeat 1, same run window, uncontended), the 4 largest compute records: cascade-shadow `73fb752d7f62c3a5` 17.9 s vs 53.1 s (−66 %), `062468c09af883b9` 19.4 s vs 42.5 s (−54 %); irradiance `517e7bab67ece93f` 21.9 s vs 23.4 s (−6 %), `193d9a08bf6784bd` 20.2 s vs 21.1 s (−4 %). The win is concentrated on the wave64-spin cascade class; the irradiance records are not spin-dominated. Single cold samples are load-sensitive (the target's repeat-3 median above is 12.33 s) **Regression run** - not run here: `scripts/smoke.ps1` on a retail title was not executed for this PR (see Not tested). **Help wanted:** a `scripts/smoke.ps1 -Game <title>` run on `main` and on this head from anyone with a retail title (wave64 or wave32 adapter) would close the regression gap — post the two `xcl-smoke` blocks to [#42](https://github.com/ivall/xcl/issues/42). **Not tested** - AMD / other drivers (measured on NVIDIA 4090 only; the levers change emitted DXIL, so they are driver-general by construction, but not measured on AMD) - indirect dispatch of a remapped program is handled by the fallback PSO but is not exercised by a GPU test (no title in the suite indirect-dispatches a wave-local remapped program); the fallback's translation is covered by the `no_remap` unit test - multi-dimensional and LDS/barrier compute groups (remap scoped to wave-local, clean multiple of 64) - the direct-DXIL path (`XCL_DIRECT_DXIL=1`) — remap is in the HLSL path only - no regression run on a retail title (`scripts/smoke.ps1` not run); the change is validated by the recomp GPU suite and the head-vs-main compile benchmark above **AI use** - Claude Code; wrote the code, the tests, and this description
DavidM1911 commented 2026-11-25 23:09:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T23:06:59Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (crates/xcl/src/gpu/recomp/pso.rs) — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7177164359 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7177164359). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T23:06:59Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`crates/xcl/src/gpu/recomp/pso.rs`) — needs a rebase before it can be tested.
DarkPanda69 commented 2026-11-26 00:05:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T23:15:38Z.


AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: no failure from this PR in the GPU suite. I did not measure cold PSO compile times, which is what the "not measured on AMD" line is about.

Head ca6f17b tested as is (on its base 68a284a), because it no longer applies on current main 08db802: emit.rs and pso.rs conflict. Debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4, card chosen with XCL_ADAPTER:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010): 648 passed, 3 failed, 22 ignored, 6 SKIPPED. Two of the failures are the AMD fuzz seeds tracked in #2115.
  • RTX 3060 (driver 32.0.16.1088): 650 passed, 1 failed, 22 ignored, 24 SKIPPED.

The remaining failure on both cards is gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (group barriers in the program: left 3, right 1). It fails the same way on the base 68a284a without this PR, on both cards, and it passes on current main. So it comes from the old base, and a rebase should clear it.

Not tested: cold --measure-pso timings on AMD (no retail pack used here), Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7177326676 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7177326676). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-25T23:15:38Z. --- AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: no failure from this PR in the GPU suite. I did not measure cold PSO compile times, which is what the "not measured on AMD" line is about. Head `ca6f17b` tested as is (on its base `68a284a`), because it no longer applies on current `main` `08db802`: `emit.rs` and `pso.rs` conflict. Debug, Windows 11 Pro 26200, `cargo test -p xcl --lib -- gpu:: --test-threads=4`, card chosen with `XCL_ADAPTER`: - **RX 9070 XT** (RDNA4, driver 32.0.32029.2010): 648 passed, 3 failed, 22 ignored, 6 SKIPPED. Two of the failures are the AMD fuzz seeds tracked in #2115. - **RTX 3060** (driver 32.0.16.1088): 650 passed, 1 failed, 22 ignored, 24 SKIPPED. The remaining failure on both cards is `gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` (group barriers in the program: left 3, right 1). It fails the same way on the base `68a284a` without this PR, on both cards, and it passes on current `main`. So it comes from the old base, and a rebase should clear it. Not tested: cold `--measure-pso` timings on AMD (no retail pack used here), Intel, a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
bielfreedom commented 2026-11-26 02:08:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bielfreedom on 2026-11-26T01:55:15Z.


AMD Windows, for the "not measured on AMD" line: on an RX 9070 XT (native wave64) this PR does not change the DXIL of any of the 2,689 retail compute programs, with switch or heap windows. So there is no AMD driver time to measure; the gain is on the split-wave64 path, which GPUs with 64-lane waves do not take.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010. Ryzen 7 7700, 32 GB RAM, Windows 11, release.
  • Builds: this PR at ca6f17b and its base 68a284a, each with a local patch in xcl shaders that writes every program's DXIL size and hash to a file.
  • Offline: xcl shaders <retail shaders.rpf> --precompile --only cs with XCL_DIRECT_DXIL=1, a fresh translation cache per run.
windows base 68a284a this PR programs changed
switch (default) 876,842,304 B 876,842,304 B 0 of 2,689
heap (XCL_HEAP_WINDOWS=1) 731,495,396 B 731,495,396 B 0 of 2,689

I did not run the GPU suite (DarkPanda69 did, above) or a title.

AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.

<!-- greyfinch-sync:ivall/xcl:comment:7180281283 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7180281283). Originally posted by [bielfreedom](https://github.com/bielfreedom) on 2026-11-26T01:55:15Z. --- **AMD Windows, for the "not measured on AMD" line: on an RX 9070 XT (native wave64) this PR does not change the DXIL of any of the 2,689 retail compute programs, with switch or heap windows. So there is no AMD driver time to measure; the gain is on the split-wave64 path, which GPUs with 64-lane waves do not take.** **Setup** - GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010. Ryzen 7 7700, 32 GB RAM, Windows 11, release. - Builds: this PR at `ca6f17b` and its base `68a284a`, each with a local patch in `xcl shaders` that writes every program's DXIL size and hash to a file. - Offline: `xcl shaders <retail shaders.rpf> --precompile --only cs` with `XCL_DIRECT_DXIL=1`, a fresh translation cache per run. | windows | base `68a284a` | this PR | programs changed | |---|---:|---:|---:| | switch (default) | 876,842,304 B | 876,842,304 B | 0 of 2,689 | | heap (`XCL_HEAP_WINDOWS=1`) | 731,495,396 B | 731,495,396 B | 0 of 2,689 | I did not run the GPU suite (DarkPanda69 did, above) or a title. **AI use:** Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.
github-actions[bot] commented 2026-11-30 08:40:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:40:58Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273211477 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7273211477). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:40:58Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 08:22:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:22:36Z.


Triage (#1607) – head ca6f17b

Both parts of this PR are already on main. The null raw-UAV descriptors and branchless out-of-window load/store guard in mem_accessors landed as 409cf07 (its message says it was adapted from this PR), and the wave-local split-wave64 remap (Em::remap, Options.no_remap, remap_fallback for indirect dispatch, the dispatch scaling in dispatch_chain) landed as 4ec5d49 with the same eligibility rules (no LDS, no s_barrier, x or y split).
Recommendation: close (superseded by main commits 409cf07 and 4ec5d49).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305235050 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7305235050). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:22:36Z. --- **Triage (#1607)** – head ca6f17b Both parts of this PR are already on main. The null raw-UAV descriptors and branchless out-of-window load/store guard in `mem_accessors` landed as 409cf07 (its message says it was adapted from this PR), and the wave-local split-wave64 remap (`Em::remap`, `Options.no_remap`, `remap_fallback` for indirect dispatch, the dispatch scaling in `dispatch_chain`) landed as 4ec5d49 with the same eligibility rules (no LDS, no `s_barrier`, x or y split). Recommendation: close (superseded by main commits 409cf07 and 4ec5d49). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:53:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:53:42Z.


Closing as superseded: this change is already on main (409cf071). both halves on main: branchless null-descriptor window guard (409cf071, MEM_NULL_LOAD/STORE) and wave-local remap (4ec5d490, Em::remap with no_remap)

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311803307 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2554#issuecomment-7311803307). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:53:42Z. --- Closing as superseded: this change is already on `main` (409cf071). both halves on main: branchless null-descriptor window guard (409cf071, MEM_NULL_LOAD/STORE) and wave-local remap (4ec5d490, Em::remap with no_remap) Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2544
No description provided.