Skip to content

recomp: enable whole-wave branches and dead-SCC elision in split wave64 - #2203

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/per-lane-split-wave-branches
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/per-lane-split-wave-branches

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What is in it

  • Enables whole-wave branches (wave_branches) in the XCL_PER_LANE=1 split-wave64 compute form when the console wave's partner half is present or spin-synced (Partner::Present | Partner::Spin via Ir::can_wave_branch()).
  • Updates self.tails[self.cur] = self.lw.cur() after split-wave64 ballot and read_lane exchanges in DxilIr so successor PHI incoming blocks track the post-exchange join block under Partner::Spin (same 2-line fix as Tests: add split_wave64_spin_exchange_updates_block_tails regression test #1928, needed here for multi-wave threadgroups to pass DXIL validation).
  • Adds backward SCC liveness (compute_scc_liveness) over Summary::blocks and routes mask-op SCC writes (saveexec, bitwise mask ops, 64-bit mask compares, S_WQM) through mask_nonzero_scc so dead SCC writes skip emitting whole-wave ballots (and split-wave64 exchange barriers).
  • Adds two unit/GPU tests in lower_dxil.rs: split_wave64_wave_branches_on_the_gpu (all 8 wave_branch_cases on both [64, 1, 1] / Partner::Present and [128, 1, 1] / Partner::Spin, validated with dxil.dll and checked for 128-thread GPU parity against dxil::kernel::translate_compute) and split_wave64_dead_scc_skips_exchange_barrier (verifying barrier elimination and GPU output).

Impact on a 2,000-program sample (--direct --lanes --split 1 --sample 2000 --max-bytes 0, 205 compute programs):

  • Per-lane compute coverage in split-wave64 rises from 26 / 205 to 39 / 205 (+50%), matching native wave64 (--split 0: 39 / 205).
  • Refusals for "a branch on whether any lane of a" drop from 35 to 2 (the remaining 2 have partial threadgroup sizes where threads % 64 != 0, matching native wave64).
  • All 39 translated per-lane split-wave64 shaders pass dxil.dll 1.9 validation in debug builds (0 validator errors, 0 panics).
  • On the 3 compute shaders discussed in Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 (50625695d2e6cbe7, 206ed63b96be21a1, a9f2cd53943d5dc4), the whole-wave branch refusal is cleared (remaining refusals are downstream IMAGE_SAMPLE_LZ / IMAGE_LOAD).

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti (driver 621.01), AMD Ryzen 5 7500F, rustc 1.100.0, DXC / dxil.dll 1.9.2602.17, debug & release builds.
  • cargo test --workspace -- --test-threads=4: 1156 passed, 0 failed, 46 ignored (SKIPPED GPU tests: 20 native wave64 tests on 32-lane NVIDIA GPU, 3 pre-existing f16/f32-to-f16 per-lane refusals, 1 driver-cache test without Windows Developer Mode, 1 heap-window test).
  • cargo test -p xcl --lib gpu::recomp::lower: 55 passed, 0 failed (including both new split-wave64 GPU/validator tests).
  • cargo test -p xcl --lib gpu::recomp::lane_masks: 13 passed, 0 failed.
  • xcl shaders <pack> --direct --lanes --split 1 --sample 2000 --max-bytes 16384 (debug build, validating every per-lane output via dxil.dll): 39/39 per-lane split-wave64 compute shaders validated with 0 errors.
  • xcl shaders <pack> --direct --lanes --split 1 --sample 2000 --max-bytes 0 vs --split 0 (release build): 39/205 vs 39/205 compute programs, 0 validator errors, 0 panics.

Regression run
Baseline (main 568e7db):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15495 MB

PR (283068c, run with XCL_PER_LANE=1):

xcl-smoke v1
commit: 283068c8d7bc78aec3d6481c90613701a8d9df1a
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1567 (PresentX 1567)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15664 MB

Not tested

  • Native wave64 GPU execution (AMD RDNA2/RDNA3 hardware; only NVIDIA 32-lane split-wave64 hardware tested locally).
  • Intel Arc / AMD split-wave64 drivers.

AI use

  • Antigravity (Gemini 4 Neon) assisted with implementing Ir::can_wave_branch, compute_scc_liveness, the lower_dxil.rs tail updates and unit/GPU tests, and running the validation

@Kalmarv

Kalmarv commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Heads-up from #1912, which changes the same call. git merge-tree of this head against #1912's c4f00e5 conflicts in lower.rs at wave_branches / analyze_branches. This PR replaces the !ir.whole_needs_exchange() condition with ir.can_wave_branch() and adds compute_scc_liveness. #1912 adds a fifth argument to analyze_branches (!graphics, for its proven-empty loop exits). The resolution keeps both: && ir.can_wave_branch() and analyze_branches(insts, wave64, launch, wave_branches, !graphics). Whichever lands second needs that one-hunk rebase.

AI use: Claude Code (Claude Opus 5.5) ran the merge check and wrote this note.

@iGoldenNinja

iGoldenNinja commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent RTX 5080 16 GB check on Windows 11 Pro 25H2 (26200.9974), driver 617.14, Rust 1.98.1 and DXC/DXIL 1.9.2609.5. Both new tests passed on clean 283068c8d7bc78aec3d6481c90613701a8d9df1a using XCL_ADAPTER=5080 and XCL_REQUIRE_GPU=wave64, with no skips. That covers all eight branch cases at 64 and 128 threads, direct-translator output parity for the 128-thread tests, and correct split-half readback for both SCC cases.

On direct parent 568e7db7729c8fa6c8f0f4b32d798faaf11462bb with only those two test functions copied, the first 64-thread branch and the live mask-SCC fixture both failed during lowering. Last verified stage on the PR was synthetic D3D12 dispatch and readback. Pinned test report

Offline follow-up on the same RTX 5080 and revisions. The uncapped seeded sweep reproduced 26/205 → 39/205 per-lane compute programs and 35 → 2 whole-wave branch refusals. A separate 16 KiB-capped probe validated all 39 PR outputs, retained all 26 parent successes and created a D3D12 compute pipeline for each of the 13 newly emitted Wave64 programs on the RTX 5080.

On seven separately matched compute programs previously investigated in the NVIDIA fork, the PR cleared the branch refusal in six. The per-lane path still emitted 0/7 due to SDWA half conversion, LDS or buffer atomics, and one unchanged IMAGE_STORE refusal. The per-instruction backend validated and created 7/7 compute pipelines on both XCL revisions. The last verified stage for these inputs was offline pipeline creation. Matched-input report

@DarkPanda69

Copy link
Copy Markdown

AMD running the split wave64 form ("AMD split-wave64 drivers" is listed as untested), paired against main.

On the RX 9070 XT, XCL_SPLIT_WAVE64=1 makes xcl use the split form instead of native wave64, so the change runs on an AMD driver. Head 283068c applied on main 568e7db, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010), XCL_SPLIT_WAVE64=1 cargo test -p xcl --lib -- gpu:: --test-threads=4:

main this PR
RX 9070 XT, split wave64 forced 584 passed, 2 failed, 22 ignored, 6 SKIPPED 586 passed, 2 failed, 22 ignored, 6 SKIPPED

Not tested: native wave64 with this PR (I only ran the forced split form here), Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@raylitebull
raylitebull merged commit fef1d5d into xcl-dev:main Nov 25, 2026
2 checks passed
Decodere added a commit to Decodere/xcl that referenced this pull request Nov 25, 2026
…test

Both `self.tails[self.cur] = self.lw.cur()` sync lines in `DxilIr::ballot`
and `DxilIr::read_lane` landed on `main` via xcl-dev#2203. Rebase xcl-dev#1928 onto `main`
to keep only the standalone `[128, 1, 1]` split-wave64 (`Partner::Spin`)
regression test covering:
- whole-wave ballot (`s_bcnt1_i32_b64`) in a uniform branch arm feeding a join PHI,
- cross-half `v_readlane_b32` (lane 37) in a uniform branch arm feeding a join PHI,
- `v_readfirstlane_b32` (ballot + read_lane) in a uniform loop feeding back-edge PHIs.

Each case compiles and validates through `lower_dxil::compute_split` and, when
a GPU is available, checks dispatch parity against `run_compute_waves`.

Part of xcl-dev#1889
Assisted-by: Google Antigravity (Gemini 4 Neon)
@tiagonleal

Copy link
Copy Markdown
Contributor

Test report on XCL_PER_LANE=1 after #2203: process memory jumps from ~8 GB to ~19 GB working set, one giant compute program is the likely cause.

Setup: unmodified main at 5478c4a7c1ae5adba127c8d27018d7fdbf3a8725 (release build), Windows 11 Pro 10.0.26300, RTX 5070 Ti 16 GB (driver 32.0.16.1742), Ryzen 7 9800X3D, 32 GB RAM, 64 GB page file. Env: XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=0 XCL_COHERENT_MB=512 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_GPU_PROFILE=1, A pressed at 30 s, 300 s planned; compute blobs precompiled for the used set (the per-lane runs were made with that same cache, built without XCL_PER_LANE).

Fact (n = 2 with XCL_PER_LANE=1, n = 2 without as control): in the title's menus, with XCL_PER_LANE=1, the working set sat at 8.2-8.7 GB and then rose by about 2 GB every 2 s: 8.3 -> 19.6 GB in 8 s (second run, at ~129 s of the run), 8.7 -> 18.9 GB in 10 s (first run, at ~164 s). Process commit went from 38 to 53-55 GB system-wide; my guard killed both at free RAM < 1 GB (0.77 GB and 0.06 GB). The two runs without XCL_PER_LANE stayed flat (working set 7.3-7.7 GB, commit 17.5 GB) for the full 300 s.

What the logs show: the growth is process-private memory in many 8-32 MB regions (about 50 per second); image, mapped files, the heaps and the sparse windows do not change, and video memory stays at 6.5 GB local. In the 30 s before the jump only graphics pipelines compile (1.8-3.3 s each), as in the control runs. The one difference in compile activity is the compute program 56c0cd3b82a00c6e: with per-lane it is 4 273 472 B of DXIL with no blob, and its driver compile started (at 4.8 s and at 41.5 s) and never finished in either run; without per-lane it is 455 056 B and comes from the blob at once. On the CPU (shaders <pack> --direct --hash 56c0cd3b82a00c6e --lanes --windows 260), 5478c4a accepts it in per-lane form (9.4x the split form's DXIL), while a build before #2203 refuses it ("a branch on whether any lane of a mask is set"). So #2203 seems to be what lets it in. I have not proven the program is the cause: the ramp starts 125-165 s after its compile starts, and I have no run with it excluded. The delay does match what I measured this morning for the same program's 4.32 MB switch form compiled alone outside the title on an older main (flat for 170 s, then +18 GiB in 18 s, never finished; in my comment on #2088).

Not identified: which allocation exactly (driver or process); the other four programs I checked (50625695d2e6cbe7, 206ed63b96be21a1, a9f2cd53943d5dc4, 4097cf4856634349) are still refused for IMAGE_SAMPLE_LZ / IMAGE_LOAD.

Not tested: the commit before #2203 with per-lane in the game, runs in the world, AMD, a per-lane precompiled cache. One thing that could be tried is a size cap on the per-lane form (fall back to the split form above some DXIL size); I have not tried it.

Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).

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.

6 participants