Skip to content

Recompiler: fold split-wave64 reduction tail v_readlane exchanges - #981

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/x64-reduction-tails
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/x64-reduction-tails

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

In split-wave64 mode (two hardware wave32 halves per console wave64), wave64 reductions end with a cross-half tail such as v_readlane_b32 s_tmp, v, 32 → v_<op> v, s_tmp, v → v_readlane_b32 s_out, v, 0 (or four v_readlane_b32 reads around v_add_f64 for 64-bit reductions). Previously, every v_readlane_b32 emitted its own xcl_x_rla_uniform call — running 2 (or 4 for f64) full cross-half xcl_x_meet() barrier/spin-wait exchanges even though the first exchange already hands both halves both v[L] and v[L^32].

This folds split-wave64 cross-half reduction tails (and direct (v, L) / (v, L^32) pairs) inside each basic block into a single xcl_x_meet() exchange: both halves keep both lane values from the first exchange, run the middle VALU instruction normally so all 64 lanes of v remain exact, and compute the updated target lane locally under its EXEC bit for the trailing v_readlane_b32 without a second exchange. Native wave64, wave32, and PRELUDE_X64 are unchanged; this is orthogonal to #917 (v_writelane_b32 spill shadows) and #944 (consecutive uniform readlane batching).

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: add Em::emit_insts and try_emit_x64_reduction_tail for split-wave64 mode covering:
    • 32-bit reduction tails (v_add_nc_u32, v_add_f32, v_min/max_f32/u32/i32, v_and/or/xor_b32, and v_add_f16 preserving the upper 16 bits) with modifier-free plain VALU ops, exact operand ordering, and EXEC-bit gating on the target lane;
    • 64-bit v_add_f64 reduction tails (4 v_readlane_b32 exchanges collapsed into 1 two-word xcl_x_meet());
    • direct (v, L) + (v, L^32) pairs.
  • crates/xcl/src/gpu/recomp/mod.rs: route the three basic-block emission loops (emit_block, emit_range, and straight-line branches == 0) through em.emit_insts(...).
  • crates/xcl/src/gpu/recomp/tests.rs: add split_wave64_reduction_tail_rules (unit test covering 32-bit, 64-bit v_add_f64, direct pair, CLAMP/mismatched-lane/jump-target negative guards, and native wave64 invariance) and gpu_split_wave64_reduction_tails (GPU test verifying v_min_u32, v_add_f32 swapped order, v_add_f16 high-16 preservation, 64-bit v_add_f64, direct pair, and inactive lane 0 under EXEC).

Across 10,447 wave64 CS/MS programs in a retail shader pack, this removes 869 xcl_x_meet() exchanges (773 × 32-bit tails, 32 × 3 from 64-bit v_add_f64 tails, and 3 direct pairs) and cuts wave64 reduction cross-half barrier syncs by 2x (32-bit) and 4x (64-bit f64) at runtime.

Measured on three reduction-heavy retail wave64 compute shaders on origin/main (077ce40) → this commit (9e2c7a5) (RTX 3060 Ti, DXC 1.9.2609.5):

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.2101), Ryzen 5 7500F, 64 GB RAM, Windows 11 Build 26300, DXC 1.9.2609.5, Rust 1.100.0 (x86_64-pc-windows-msvc), debug + release.
  • cargo test --workspace -- --test-threads=1: 718 passed, 0 failed, 41 ignored (2 SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)). Both new tests (split_wave64_reduction_tail_rules, gpu_split_wave64_reduction_tails) ran and passed.

Regression run
(local folder name redacted to retail-title in both blocks; main baseline 09940bb has an identical Rust tree to 077ce40, which only updated README.md; all metrics are exact output of the 60 s runs with XCL_NETWORK=0)

main:

xcl-smoke v1
commit: 09940bb87fa11bc394fd9e5de570c2b7cfd16323
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14658 MB

PR:

xcl-smoke v1
commit: 9e2c7a566574700755c2da4971bb2e882f56f506
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1574 (PresentX 1574)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15015 MB

Not tested

  • Native wave64 GPU (AMD RDNA): hardware not available here (split_wave64 is false there so emitted HLSL is unchanged).
  • Retail gameplay past menus (smoke run covers boot through menus; heavy compute shaders were benchmarked offline via DXC + CreateComputePipelineState).

AI use

  • Antigravity (Gemini 4 Neon): scanned the retail shader corpus, wrote the implementation, unit/GPU tests, and PR description; all tests, benchmarks, and smoke runs were executed locally on the hardware above and the diff was reviewed line by line.

@eizispark

Copy link
Copy Markdown

Hardware check of 9e2c7a566574700755c2da4971bb2e882f56f506 (verified clean merge with main 9aec53d): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 715 passed, 3 failed, 41 ignored (GPU tests skipped on this adapter: none; the 3 failures are the pre-D3D12.X: a sparse pool retired a moment ago is taken back (#913) #923 placed_title_textures_share_vram_and_preserve_pixels concurrent global-table race on base 077ce40 plus its 2 downstream PoisonError tests — cargo test -p xcl --lib hle::d3d12x -- --test-threads=1: 115 passed, 0 failed, 1 ignored)
  • Split-wave64 reduction-tail & native wave64 GPU checks: split_wave64_reduction_tail_rules, gpu_split_wave64_reduction_tails (both native wave64 and forced XCL_SPLIT_WAVE64=1: 1 passed, 0 failed), gpu_wave32_program_in_wave64_hardware, and gpu_geometry_wave32_prefix_count_over_a_mask all passed

Regression run
main (6bac4b4):

xcl-smoke v1
commit: 6bac4b4419886acc940d479dcf8815d0b1804435
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1669 (PresentX 1669)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

PR (9e2c7a5):

xcl-smoke v1
commit: 9e2c7a566574700755c2da4971bb2e882f56f506
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1661 (PresentX 1661)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14722 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X Radeon iGPU (gfx1036 RDNA2) + RTX 3060 Ti; Rust stable MSVC, debug.

  • XCL_ADAPTER=radeon XCL_SPLIT_WAVE64=1 cargo test -p xcl --lib split_wave64_reduction: 2 passed — split_wave64_reduction_tail_rules and gpu_split_wave64_reduction_tails on the Radeon.
  • Default adapter (RTX 3060 Ti, wave32 — split-wave64 is its native path): 2 passed.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@LANgmas

LANgmas commented Nov 24, 2026

Copy link
Copy Markdown

Independent validation — NVIDIA RTX 3050 Laptop (wave32-only)

Tested PR head: 9e2c7a566574700755c2da4971bb2e882f56f506
PR target base at validation: 9aec53d
Actual merge-base: 077ce40
Current upstream/main at validation: 384f7f7f8c79fa4d4dee59336d650a4021af4c7e (approximately 30 commits ahead of the PR's merge-base).
Tested the exact PR head in an isolated detached worktree.

Hardware / environment

  • NVIDIA RTX 3050 Laptop GPU, 3962 MiB VRAM
  • NVIDIA driver 617.14
  • D3D12 Feature Level 12_2
  • WaveLaneCountMin / WaveLaneCountMax: 32 / 32 (wave32-only)
  • DXC 1.9.2602.17
  • Windows SDK 10.0.26100.0
  • d3d12SDKLayers.dll unavailable
  • All XCL_* variables unset

Focused tests — PASS

split_wave64_reduction_tail_rules

  • Passed (0.01s).
  • Verified emission rules, operand ordering, f16 upper-bit preservation, f64 handling and negative guards.

gpu_split_wave64_reduction_tails

  • Passed (1.63s) on the real NVIDIA RTX 3050 adapter.
  • DXC loaded successfully; no early return or skip.
  • The split-wave64 path was genuinely exercised on this wave32-only adapter.
  • All six GPU cases executed and passed:
    • v_min_u32
    • Swapped-operand v_add_f32
    • v_add_f16 upper-16-bit preservation
    • Two-word v_add_f64
    • Direct lane pair 5/37
    • Inactive lane 0 under EXEC
  • The fold assertion verified zero xcl_x_rla_uniform exchanges for the tested reduction tail.

Full official test wrapper — PASS
Command: .\scripts\test.ps1
Result: 718 passed, 0 failed, 41 ignored, across 17 test binaries. Exit code 0.
The wrapper reported two GPU tests skipped due to lack of native wave64.

Additional skip reconciliation:

  • One full native-wave64 early skip.
  • One geometry test whose wave32 portion ran but native-wave64 reference was skipped.
  • Three additional hidden capability/debug-layer skips.
  • Approximately 28 sample-gated tests returned early because all XCL_SAMPLE_* variables were unset. This is an estimate from source gates and observed runtimes, not an exhaustive per-test audit.
  • The 41 ignored tests are separate.

Not tested

  • Native wave64 hardware.
  • Retail game smoke on this RTX 3050.
  • Retail shader-corpus performance benchmarks on this machine.
  • Release configuration.
  • The PR integrated with current upstream main.
    The PR's actual merge-base was approximately 30 commits behind current upstream main at validation time. This report describes the exact PR head tested, not merge-time validation against current main.

Interpretation
The focused GPU test confirms that the split-wave64 reduction-tail fold is exercised and produces the expected results on a real NVIDIA wave32-only adapter.
This provides independent NVIDIA validation complementary to the author's RTX 3060 Ti results and the AMD RX 9070 XT report.
No independent FPS or retail-game performance improvement is claimed from this test.

AI use
Devin (SWE-2 Max) assisted with test execution and result reconciliation. The contributor reviewed the results and authorized this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.

  • cargo test -p xcl --lib reduction_tail: 2 passed, 0 failed — split_wave64_reduction_tail_rules (emission rules) and gpu_split_wave64_reduction_tails (GPU, real hardware).
  • cargo test -p xcl --lib wave64: 17 passed, 0 failed, 3 ignored — no regressions in the surrounding wave64 lowering.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

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.

5 participants