Skip to content

Compute groups that are not whole waves: padded where the program can tell - #245

Open
Kalmarv wants to merge 1 commit into
ivall:mainfrom
Kalmarv:fix/cs-pad-partial-waves
Open

Kalmarv wants to merge 1 commit into
ivall:mainfrom
Kalmarv:fix/cs-pad-partial-waves

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

This is the compute side of the gap #152 names under "Not covered": lanes the PC never launched. It was offered in #152 (comment).

A console wave always has all its lanes; a PC group of 40 threads has only 40. The lanes the PC never launches are still visible to a program: v_writelane writes them, and code that turns on EXEC runs in them. This PR launches those lanes for compute programs that can tell, inactive as on the console.

One commit, 3aaef99, on main 9ab7d76: about 310 lines of translator code and about 450 of tests. The earlier heads were 887ae29 and ba63366 (the same patch, rebased). 3aaef99 adds the fix for 64-bit writes to NULL that @JGonzalezRodriguez found (below).

What is in it

What was wrong:

  • A compute group of 40 threads is one console wave64 with lanes 0..39 launched and lanes 40..63 inactive in EXEC, but there.
  • v_writelane writes the inactive lanes whatever EXEC is.
  • Code that turns them on runs in them: s_or_saveexec_b64 s, -1 around whole-wave code, s_mov_b64 exec, -1, s_not_b64 exec, exec, s_wqm_b64 exec, exec.
  • A PC group of 40 threads has no such lanes.

Measured on main 956a476 (RTX 5070 Ti, split form; the same with XCL_X64_ALL_MASKS=1 and XCL_WAVE64_SPIN=1). Expected values are the ISA's definition, not a console measurement:

group s_not_b64 exec, exec, then bits of v_cmp_eq_u32 vcc, v0, v0 s_or_saveexec_b64 s, -1, then the same v_mov under EXEC = -1, v_readlane of lane 63
40 24 expected, 0 measured 64, 40 7, 7 (an undefined read that happened to be right)
42 22, 0 64, 42 7, 7 (same)
20 44, 0 64, 20 7, 0
10 54, 0 64, 10 7, 0
96, second wave 32, 0 64, 32 7, 0

Wave32 programs have the same gap in groups that are not a multiple of 32. It is not the split form's doing: it happens on every GPU and at both wave sizes.

The change: for compute, the missing lanes can simply be launched.

  • The group is declared as whole console waves: [numthreads(64, 1, 1)] for 40 threads, 1-D whatever the console's shape.
  • EXEC starts as the ballot of thread index < 40.
  • The padding lanes are real lanes, inactive as on the console. Nothing else in the translation changes.

Which programs are padded:

  • Only a program that can tell is padded (crates/xcl/src/gpu/recomp/partial_waves.rs). Every other program keeps its group and its HLSL byte for byte (compute_groups_are_padded_only_where_the_program_can_tell).
  • A program can tell when it has a v_writelane to a lane the last wave may not launch, or when EXEC may get a bit outside the launched lanes.
  • The second case is a forward pass over the SGPRs. It tracks words known to lie inside the launched lanes: EXEC at the start, VALU masks, constants by their bits, AND with such a word, OR / XOR of two such words, the saveexec forms, moves and selects.
    • Anything else may have any bit.
    • An indirect jump pads.
    • A 64-bit write to NULL (s125) writes nothing. Before 3aaef99, the pass wrote its high word to s126 (EXEC_LO), and upper_lanes::sgpr_outputs listed a null SDST / VDST as two registers. With EXEC_HI 0, s_or_saveexec_b64 null, 0xFFFFFFFF was then not seen as turning lanes on, and s_and_saveexec_b64 null, s_and_b64 null and a VOP3 v_cmp to null padded for nothing. @JGonzalezRodriguez found this.
    • The compiler's if / else / loop code keeps EXEC inside the launched lanes, so ordinary programs are not padded.
  • The pass errs towards padding. A padded program is exact; it only runs up to 63 more inactive threads per group.
  • TG_SIZE, group ids, LDS and the dispatch counts are the title's, as before.
  • XCL_CS_PAD_ALL=1 pads every group that is not whole waves, and XCL_NO_CS_PAD=1 pads none. Both are for comparison and bypass the shader caches.
  • A group whose padded size would pass D3D12's 1 024 threads keeps its size.

This is narrower than what I offered in the #152 comment (pad every partial group). I gated it so that programs that cannot tell keep their HLSL and pay nothing; XCL_CS_PAD_ALL=1 is the ungated form.

The HLSL a padded program gets: no wave intrinsic that the translator does not already emit, and none in a new position.

  • [numthreads(N, 1, 1)], with N the next multiple of the console wave size.

  • The entry ballot's argument is ballot(gi < 40u) instead of ballot(true) (xcl_x_ballot in the split form). It is the same function in the same place.

  • Split form (32-lane hardware): XCL_X_THREADS is the padded count. xcl_x_thread and the exchange are unchanged.

  • Native form (64-lane hardware): a padded group takes its threads through the prologue that every 2-D / 3-D compute group already has:

    • WaveActiveCountBits(true), WaveIsFirstLane;
    • InterlockedAdd on the groupshared counter, WaveReadLaneFirst;
    • two group barriers.

    The only new thing is that a 1-D group can get it.

A padded group's thread count is a multiple of the hardware wave size, so the driver has no partial last wave to form for it. A padded program's wave operations therefore run in fewer partial waves than before, not more. The body of the program is translated as before.

Tests:

  • gpu_wave64_valu_code_in_lanes_not_launched and gpu_wave32_valu_code_in_lanes_not_launched: one program, run in 1-D, 2-D and 3-D groups. It:

    • counts the compare's bits after s_not exec, exec and after s_or_saveexec s, -1;
    • reads the wave's last lane of a VGPR written under EXEC = -1;
    • reads back a lane v_writelane wrote.

    Both fail without the change. Each also runs with PadWaves::Never (the translation main makes) and requires every partial wave to differ: 11 and 5 of them.

  • gpu_padded_compute_groups_look_the_same_to_the_program: these are the same padded or not:

    • thread ids (1-D, 2-D, 3-D), the group id, TG_SIZE and lane numbers;
    • the launched-lane count;
    • LDS across s_barrier, and one atomic per thread.

    No padding lane stores.

  • gpu_wave64_saveexec_to_null_turns_on_lanes_not_launched: @JGonzalezRodriguez's case on the GPU. In a group of 20 threads, s_or_saveexec_b64 null, 0xFFFFFFFF with EXEC_HI 0 turns on lanes 20..31, so a compare counts 32 lanes. Unpadded (PadWaves::Never), it counts 20.

  • CPU: partial_waves::tests (8) and compute_groups_are_padded_only_where_the_program_can_tell. Two of the eight are for the null writes, a_saveexec_to_null_that_widens_exec_is_seen and masks_discarded_into_null_leave_exec_alone; both fail without the fix in 3aaef99.

Tested

  • RTX 5070 Ti, NVIDIA 610.74, Ryzen 9 9950X, Windows 11 Pro 25H2 (build 26200.9711), Rust 1.99.0, debug build. The GPU has 32-lane waves only: wave64 programs run split, wave32 programs natively.
  • cargo test --workspace -- --test-threads=4 on 3aaef99: 664 passed, 0 failed, 40 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware, both "no wave64"). That is the previous head's 661 and the three new tests. gpu::recomp::: 195 passed, 0 failed, 18 ignored.
  • The fix in 3aaef99, built with and without it (the same tests in both):
    • partial_waves::: 8 of 8 pass with the fix, and both new CPU tests fail without it.
    • gpu_wave64_saveexec_to_null_turns_on_lanes_not_launched passes with the fix. Without it, every thread counts 20 lanes instead of 32.
    • The four GPU tests of this PR pass with the fix.
  • The previous head ba63366, on our machine: 661 passed, 0 failed, 40 ignored, with the same two SKIPPED tests.
  • Also run by @regiumlepidi on 3aaef99, merged onto main 4017f8f (a clean merge), on an RTX 5070 Ti (NVIDIA 617.42) and on the AMD RDNA2 iGPU of a Ryzen 7 9800X3D (driver 32.0.21030.2001, native 64-lane waves, native Windows D3D12). Windows 11 Pro 25H2, rustc 1.100.0, debug (Compute groups that are not whole waves: padded where the program can tell #245 (comment)):
    • scripts/test.ps1: 665 passed, 0 failed, 40 ignored on both adapters; main 4017f8f gave 652 / 0 / 40 on both.
    • SKIPPED tests: 2 on the RTX 5070 Ti (no wave64), none on the iGPU. So the wave64 tests, gpu_wave64_saveexec_to_null_turns_on_lanes_not_launched included, ran in native 64-lane waves there.
    • The 13 tests of this PR, with XCL_CS_PAD_ALL=1: 13 passed on both. With XCL_NO_CS_PAD=1: 10 passed and 3 failed on both, the three GPU tests in their padded half, as expected.
  • Also run by @Rednaxeh on ba63366 (main 9ab7d76 + this commit), on an RX 7800 XT (RDNA3, native 64-lane waves, driver 32.0.32029.2010), Ryzen 7 7800X3D, Windows 11 Pro 26300, rustc 1.100.0, with XCL_REQUIRE_GPU=wave64,mesh (Compute groups that are not whole waves: padded where the program can tell #245 (comment)):
    • scripts/test.ps1, debug and release: 661 passed, 0 failed, 40 ignored, 0 SKIPPED; main 9ab7d76 gave 651 / 0 / 40.
    • gpu::recomp::: 192 / 0 / 18 natively, and the same with XCL_SPLIT_WAVE64=1, XCL_CS_PAD_ALL=1, XCL_WAVE64_SPIN=1 and XCL_X64_ALL_MASKS=1.
    • With XCL_NO_CS_PAD=1, both …_valu_code_in_lanes_not_launched tests fail in every partial wave, natively on 64-lane hardware too.
    • The regression run below.
  • Also run by @PHeitor1 on 3aaef99 merged onto main 2b4bb43, on an RTX 5060 Ti, debug, with the debug-layer tests enabled: cargo test --workspace, 683 passed, 0 failed, 41 ignored; the only SKIPPED tests are the two "no wave64" ones (Compute groups that are not whole waves: padded where the program can tell #245 (comment)).
  • The tester runs below are of ba63366 and 887ae29, which carry the same patch. 3aaef99 differs from them only by the null-write fix and its tests (git diff ba63366 3aaef99: partial_waves.rs, upper_lanes.rs, tests.rs).
  • Also run by @denio4321 on an RTX 3060 (NVIDIA 610.88), previous head ba63366: cargo test --workspace, 661 passed, 0 failed, 40 ignored (main: 651 passed), and the 10 new tests pass (Compute groups that are not whole waves: padded where the program can tell #245 (comment)).
  • Also run by @PHeitor1 on an RTX 5060 Ti (NVIDIA 621.24), Windows 11, debug, previous head ba63366: cargo test --workspace, 661 passed, 0 failed, 40 ignored (Compute groups that are not whole waves: padded where the program can tell #245 (comment)).
  • Also run by @JGonzalezRodriguez on 887ae29 (the same patch as ba63366), on an RTX 4090 (wave32 hardware, wave64 split) and on an AMD Raphael RDNA2 iGPU (RADV 26.2.4, native wave64), both under Proton with vkd3d-proton on Linux, debug (Compute groups that are not whole waves: padded where the program can tell #245 (comment)):
    • partial_waves::tests 6/6 and the four new tests 4/4 on both GPUs.
    • Without the change (XCL_NO_CS_PAD=1, and with the two GPU tests on base 60565c4), both …_valu_code_in_lanes_not_launched tests fail on both GPUs.
    • gpu::recomp::: 192 passed, 0 failed, 18 ignored on the RTX 4090. On RADV: 189 passed, 3 failed, 18 ignored, also with XCL_CS_PAD_ALL=1. The three (gpu_f64_roots, gpu_f64_math_random, gpu_nonfused_mad_and_mac_prevent_fma_contraction) fail the same way on base 60565c4.
  • The runs below are of the earlier head 887ae29 (main 60565c4 + the same patch):
    • The four new tests by exact name (<lib test exe> --exact … --test-threads=1), in three forms of the split (default, XCL_X64_ALL_MASKS=1, XCL_WAVE64_SPIN=1): 4 passed, 0 failed in each.
    • Without the change (XCL_NO_CS_PAD=1, which makes the translation main's), both …_valu_code_in_lanes_not_launched tests fail in every partial wave. For example:
      • group 40, wave64: want [24, 64, 7, 33], got [0, 40, 7, 0];
      • group 20, wave32: want [12, 32, 7, 33], got [0, 20, 7, 0].
    • Every gpu::recomp:: test (<lib test exe> gpu::recomp:: --test-threads=2):
switch passed failed ignored
none 192 0 18
XCL_CS_PAD_ALL=1 (every partial compute group padded) 192 0 18
XCL_WAVE64_SPIN=1 192 0 18
XCL_X64_ALL_MASKS=1 190 2 18
  • The two failures under XCL_X64_ALL_MASKS=1 are gpu_split_wave64_lane_local_masks and gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves. They assert that masks stay in their half, which that switch turns off. They failed the same way with main's translator when I ran it on af20b4b.
  • cargo test --workspace --no-fail-fast -- --test-threads=2: 661 passed, 0 failed, 40 ignored (lib: 621 / 0 / 20).

Overlaps:

  • 1058c0b (Compute TG_SIZE: a partial last wave counts #136, TG_SIZE) changed one constant: the wave count in the TG_SIZE SGPR is now the ceiling, so a program is told that a last, partial wave exists. That wave still has only the lanes the PC launched. This PR does not touch TG_SIZE (the line is unchanged, and a test checks that the value is the same padded or not); it gives the partial wave its missing lanes.
  • VS / PS whole-wave reductions as wave operations (partial waves, every GPU) #152 recognises whole-wave reductions in VS / PS and names compute and mesh as not covered. Nothing here touches VS / PS; this only changes the compute entry, so the two should compose.
  • docs/wave64-on-wave32.md says that "the console group keeps its numthreads". With this PR, a compute program that can tell gets a padded group instead. The doc is not edited here.

Regression run

By @Rednaxeh, RX 7800 XT (RDNA3, driver 32.0.32029.2010), Ryzen 7 7800X3D, Windows 11 Pro 26300, release builds, no uncommitted changes (#245 (comment)). These are their runs 5 (main) and 4 (PR), made one after the other; the blocks are as they posted them. The gpu: line names the wrong adapter: that is the script's known issue (#281 / #282 / #285), and the GPU was the RX 7800 XT.

main:

xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1262 (PresentX 1262)
presents per 2 s (last 3): 1 0 1
device removals: 0
crashes: 0
peak commit: 16302 MB

PR: previous head ba63366; it differs from 3aaef99 only by the null-destination fix. A block at 3aaef99 has been asked for.

xcl-smoke v1
commit: ba633669be03d9a41a314a3204d58fe4cc88237d
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1261 (PresentX 1261)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 16236 MB

Not tested

  • The regression run at the head 3aaef99: so far it ran only at ba63366 (above). How many of a title's compute programs get padded is not counted.
  • AMD: no RDNA4. The AMD runs:
  • Expected values come from the ISA's definition; nothing was compared with a console.
  • Not covered by the change:

AI use

  • Claude Code (Claude Fable 5.2), code, tests and the first description; Claude Code (Claude Opus 5.5), the rebase and this description

@denio4321

Copy link
Copy Markdown

Tested ba63366 merged onto main 9ab7d76 on RTX 3060 12 GB (Ampere, 32-lane waves), NVIDIA 610.88, Windows 11 Pro 23H2 (22631), rustc 1.100.0 MSVC, DXC 1.9.2602.17: pass.

.\scripts\test.ps1 (debug, --test-threads=4), no XCL_SAMPLE_* set. Baseline main 9ab7d76 alone on the same machine: 651 passed, 0 failed, 40 ignored.

  • This PR: 661 passed, 0 failed, 40 ignored (the 10 new tests, all ok).
  • gpu_wave64_valu_code_in_lanes_not_launched and gpu_wave32_valu_code_in_lanes_not_launched pass here; the wave64 one runs in the split form (two hardware wave32s per console wave).
  • gpu_padded_compute_groups_look_the_same_to_the_program and compute_groups_are_padded_only_where_the_program_can_tell pass, and so do the six partial_waves::tests.
  • GPU skips are the same 2 as on main (no wave64).

Not run: the new tests without the emit.rs change (the negative control), or any game.

AI-assisted (Claude Code).

@PHeitor1

Copy link
Copy Markdown

Tested on RTX 5060 Ti 8 GB, driver 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native), Rust 1.100.0 msvc, debug. cargo test --workspace --no-fail-fast -- --test-threads=4 on the head ba63366: 661 passed, 0 failed, 40 ignored (main 9ab7d76: 651 / 0 / 40, so +10 new tests, all green on a 32-lane NVIDIA). SKIPPED: only the usual two no wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware).

Run and written with Claude Code (Claude Opus 5.5).

@JGonzalezRodriguez

Copy link
Copy Markdown

Tested commit 887ae29 (on base 60565c4; also verified the current rebased head ba63366 has zero diff in partial_waves.rs, upper_lanes.rs, and emit.rs) on both wave32-only hardware (NVIDIA RTX 4090) and native wave64 hardware (AMD Raphael RDNA2 / RADV).

Tested

  • Host / stack: CachyOS Linux, Proton Experimental wine + relaxed vkd3d-proton (30b0eb9), DXC 1.9.2609.5, cross-built x86_64-pc-windows-msvc debug (rustc 1.98.1, clang-cl 23.1.1 + lld-link, 0 errors, 0 warnings).
Suite / switch RTX 4090 (610.57.4, wave32 / split wave64) AMD Raphael RDNA2 (radv 26.2.4, native wave64 + wave32)
partial_waves::tests 6/6 pass 6/6 pass
4 new PR #245 tests (default) 4/4 pass 4/4 pass
4 new PR #245 tests (XCL_WAVE64_SPIN=1) 4/4 pass —
4 new PR #245 tests (XCL_X64_ALL_MASKS=1) 4/4 pass —
4 new PR #245 tests (XCL_SPLIT_WAVE64=1) — 4/4 pass
4 new PR #245 tests (XCL_NO_CS_PAD=1) 2 pass, 2 fail (11 w64 + 5 w32 partial waves) 2 pass, 2 fail (11 w64 + 5 w32 partial waves)
Full gpu::recomp:: (default) 192 pass, 0 fail, 18 ignored 189 pass, 3 fail*, 18 ignored
Full gpu::recomp:: (XCL_CS_PAD_ALL=1) 192 pass, 0 fail, 18 ignored 189 pass, 3 fail*, 18 ignored
Base 60565c4 negative control (2 new GPU tests carried onto base) 0/2 pass (11 w64 + 5 w32 partial waves fail) 0/2 pass (11 w64 + 5 w32 partial waves fail)

* On AMD RADV, the 3 failures (gpu_f64_roots, gpu_f64_math_random, gpu_nonfused_mad_and_mac_prevent_fma_contraction) also fail identically 3/3 on base 60565c4 (pre-existing RADV f64 rsq / f32 FMA quirks; zero regressions from this PR, including under XCL_CS_PAD_ALL=1). Native wave64 execution on RADV was verified via gpu_wave32_program_in_wave64_hardware running without skipping.

The native wave64 reorder prologue, XCL_WT/xcl_lds[8191u] barrier handoff, TG_SIZE, barriers, and split-wave64 paths all behave cleanly on both GPUs.

Findings

1. 64-bit writes with SDST/VDST = null (125) clobber st.s[126] (EXEC_LO)

State::set ignores r == 125, so the low-word write to null is skipped, but 64-bit writes still call st.set(dst + 1, ...) = st.set(126, ...), overwriting EXEC_LO in three places:

  • partial_waves.rs:137-141 (SAVEEXEC/WREXEC: st.set(dst + 1, ...))
  • partial_waves.rs:160-163 (ENC_SOP1/ENC_SOP2: st.set(dst + 1, hi))
  • partial_waves.rs:173-180 via upper_lanes::sgpr_outputs (upper_lanes.rs:497, 509), which returns (125, 2) when SDST/VDST == 125 (including SDWA SD=1).

This causes both a false negative (missed padding) and false positives (spurious padding) on partial waves with launched < 32 (reproduced on both RTX 4090 and AMD RADV with a [20, 1, 1] wave64 group):

  1. False negative: s_mov_b32 exec_hi, 0; s_or_saveexec_b64 null, 0xFFFF_FFFF widens EXEC_LO to 0xFFFF_FFFF (activating lanes 20..31), setting st.s[126] = 0, which is immediately overwritten by st.set(126, eh) (LO | HI) before line 205 checks st.s[126] & LO == 0. sees_lanes_not_launched returns None, the shader stays unpadded, and v_cmp_eq_u32 vcc, v0, v0; s_bcnt1_i32_b64 returns 20 instead of 32 (PadWaves::Always returns 32).
  2. False positives: Normal narrowing/test idioms that discard into null — s_and_saveexec_b64 null, vcc, s_and_b64 null, exec, vcc, and v_cmp_gt_u32 null, v0, v1 (ENC_VOP3) — overwrite st.s[126] with eh (HI, lacking LO) and spuriously pad the group.

Guarding dst != 125 before writing 64-bit pairs in partial_waves.rs (e.g. a set64 helper) and skipping v == 125 in upper_lanes::sgpr_outputs fixes all three paths cleanly.

(Minor: in partial_waves.rs:138, if b64 could also be if b64 && wave64 to match emit.rs:1118.)

Not tested

  • Native Windows, Windows SDK DXC 1.7, full workspace test run on rebased ba63366 (verified zero diff vs tested 887ae29 in partial_waves.rs/upper_lanes.rs/emit.rs), retail titles.

AI use

Antigravity (Gemini frontier model) assisted with code review, dual-GPU test execution, and drafting this report; every line cited and repro result was directly verified on this host.

@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@JGonzalezRodriguez thank you, and for the RADV wave64 run. Finding 1 holds as you describe: State::set skips 125, but the second word of a 64-bit write to null lands on 126, and sgpr_outputs returns (125, 2) for a null destination. A fix with your cases as tests (the missed pad and the three spurious ones) is coming as a push to this PR, with you credited in the description; I'll also check the b64 && wave64 point against emit.rs. I'll ask for smoke runs once the new head is up.

🤖 Claude Opus 5.5

A console wave always has all its lanes: a 40-thread group is one wave64
with lanes 0..39 launched and 40..63 inactive, but there. v_writelane
writes them, and code that turns them on in EXEC (s_or_saveexec_b64 s, -1,
s_mov_b64 exec, -1, s_not_b64 exec, s_wqm_b64 exec) runs in them. A PC
group of 40 threads has no such lanes: on an RTX 5070 Ti s_or_saveexec -1
followed by a compare gave 40 mask bits instead of 64, s_not exec followed
by one 0 instead of 24.

A compute program that can tell (partial_waves.rs: a v_writelane to a lane
the last wave may not launch, or EXEC that may leave the launched lanes) now
gets its group declared as whole console waves, with EXEC starting as the
ballot of thread index < the console's thread count. Thread ids come from
the index (xcl_x_thread in the split form, the 2-D / 3-D groups' thread
counter natively). Every other program keeps its group and its HLSL.
TG_SIZE, group ids and LDS are unchanged. XCL_CS_PAD_ALL=1 pads every
partial group, XCL_NO_CS_PAD=1 none; both bypass the shader caches.

A 64-bit write to NULL (s125) writes nothing: the pass wrote its high word
to s126 (EXEC_LO), and upper_lanes::sgpr_outputs listed a null SDST / VDST
as (125, 2). So `s_or_saveexec_b64 null, 0xFFFFFFFF` with EXEC_HI 0 was not
seen as turning on lanes (a group of 20 then counted 20 lanes, not 32), and
s_and_saveexec_b64 null / s_and_b64 null / a VOP3 v_cmp to null padded
for nothing. Found by JGonzalezRodriguez.

Tests: gpu_wave64_valu_code_in_lanes_not_launched,
gpu_wave32_valu_code_in_lanes_not_launched (both fail without the padding),
gpu_padded_compute_groups_look_the_same_to_the_program,
gpu_wave64_saveexec_to_null_turns_on_lanes_not_launched,
compute_groups_are_padded_only_where_the_program_can_tell,
partial_waves::tests.

Not covered: mesh and geometry programs, VS / PS. Not run on AMD.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Kalmarv
Kalmarv force-pushed the fix/cs-pad-partial-waves branch from ba63366 to 3aaef99 Compare November 23, 2026 22:45
@regiumlepidi

Copy link
Copy Markdown

Tested the new head 3aaef99 merged onto current main 4017f8f (clean merge) on native 64-lane hardware under Windows – an AMD RDNA2 iGPU – and on an NVIDIA RTX 5070 Ti, with main 4017f8f as the baseline on both: pass on both.

Tested

  • AMD Radeon(TM) Graphics, the Ryzen 7 9800X3D's iGPU (RDNA2, native 64-lane waves), driver 32.0.21030.2001, native Windows D3D12 (not vkd3d), selected with XCL_ADAPTER=radeon
  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves), driver 617.42 (32.0.16.1742)
  • AMD Ryzen 7 9800X3D, 48 GB DDR5-6000, Windows 11 Pro 25H2, rustc 1.100.0 MSVC, DXC from Windows SDK 10.0.26100, debug
  • .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4), no XCL_SAMPLE_* set
Build Adapter Passed Failed Ignored GPU tests skipped
main 4017f8f RTX 5070 Ti 652 0 40 2 (no wave64)
main 4017f8f RDNA2 iGPU 652 0 40 none
3aaef99 on 4017f8f RTX 5070 Ti 665 0 40 2 (no wave64)
3aaef99 on 4017f8f RDNA2 iGPU 665 0 40 none
  • On the iGPU nothing is skipped, so the wave64 programs ran in native 64-lane waves there: gpu_wave64_valu_code_in_lanes_not_launched, gpu_wave64_saveexec_to_null_turns_on_lanes_not_launched (the null-saveexec case from the RADV review), gpu_wave32_valu_code_in_lanes_not_launched and gpu_padded_compute_groups_look_the_same_to_the_program all pass, as do the 8 partial_waves::tests and compute_groups_are_padded_only_where_the_program_can_tell. The PadWaves::Never halves of those tests (11 and 5 differing waves, the unpadded count of 20) hold on both adapters too.

The switches, the 13 tests above only (cargo test -p xcl --lib -- lanes_not_launched padded_compute compute_groups_are_padded partial_waves):

Switch RTX 5070 Ti RDNA2 iGPU
XCL_CS_PAD_ALL=1 13 passed 13 passed
XCL_NO_CS_PAD=1 10 passed, 3 failed 10 passed, 3 failed

With XCL_NO_CS_PAD=1 the three GPU tests fail in their WhereSeen half, as expected, since the switch turns it into Never: e.g. on the iGPU group [40, 1, 1] wave 0 (40 lanes) | want [24, 64, 7, 33] | got [[0, 40, 0, 0]], and the null-saveexec case counts 20 instead of 32. So on 64-lane hardware too the padding is what makes them pass.

Regression run

  • None: I have no unpacked Xbox Series title.

Not tested

  • scripts/smoke.ps1 on a real title, main or this head; how many of a title's compute programs get padded.
  • RDNA3 / RDNA4 and discrete AMD cards; Intel.

AI use: Claude Code with Claude Opus 5.5 ran the builds and tests and wrote this report; the numbers come from those runs.

@Rednaxeh

Copy link
Copy Markdown

RDNA3: Radeon RX 7800 XT (native 64-lane waves) on ba63366: 661 passed, 0 failed; the new tests fail without the change here too; retail title runs the same as main

First AMD run of this PR, as asked under Not tested, plus a regression run on a retail title. Tested ba63366, which is main 9ab7d76 plus this PR's commit (fast-forward, so head = merge result), with no uncommitted changes. No XCL_SAMPLE_* variables set for the test suite.

GPU / driver AMD Radeon RX 7800 XT (16 GB, RDNA3), driver 32.0.32029.2010; 32–64-lane waves, mesh shaders, SM 6.6
CPU / RAM AMD Ryzen 7 7800X3D, 32 GB DDR5-6000
OS Windows 11 Pro 26300 (native)
Toolchain rustc 1.100.0 x86_64-pc-windows-msvc, debug (release where said); DXC 1.9.2602.17 (Windows SDK 10.0.26100); system XGameRuntime 10.0.26100.9656

Whole suite – .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4) with XCL_REQUIRE_GPU=wave64,mesh, so a skipped GPU test would have failed: 661 passed, 0 failed, 40 ignored, 0 SKIPPED (lib 621 / 0 / 20). main 9ab7d76 alone on this machine, same command and switch, earlier today: 651 / 0 / 40, 0 SKIPPED. The 10 extra passes are this PR's tests: the 6 unit tests in partial_waves.rs, compute_groups_are_padded_only_where_the_program_can_tell, and the 3 GPU tests.

gpu::recomp:: (cargo test -p xcl --lib -- gpu::recomp:: --test-threads=2, XCL_REQUIRE_GPU=wave64,mesh throughout):

switch passed failed ignored
none (native wave64) 192 0 18
XCL_SPLIT_WAVE64=1 (the 32-lane split form on AMD) 192 0 18
XCL_CS_PAD_ALL=1 192 0 18
XCL_WAVE64_SPIN=1 192 0 18
XCL_X64_ALL_MASKS=1 192 0 18

Under XCL_X64_ALL_MASKS=1 the two gpu_split_wave64_*_masks* tests that fail on the RTX 5070 Ti pass here: on native 64-lane waves there is no split for that switch to act on.

The four new tests by exact name (--exact --test-threads=1): 4 passed in each of the five forms (native, XCL_SPLIT_WAVE64=1, XCL_CS_PAD_ALL=1, XCL_WAVE64_SPIN=1, XCL_X64_ALL_MASKS=1).

Release: cargo build --release --workspace + cargo test --release --workspace -- --test-threads=4, XCL_REQUIRE_GPU=wave64,mesh: 661 passed, 0 failed, 40 ignored, 0 SKIPPED, the same as debug.

Without the change (XCL_NO_CS_PAD=1, same four tests): gpu_wave64_valu_code_in_lanes_not_launched and gpu_wave32_valu_code_in_lanes_not_launched fail in every partial wave, as on NVIDIA; the other two pass. So the native thread-counter prologue on 64-lane hardware, which the description lists as untested, takes the padded form here and the test catches main's translation on it. Examples, verbatim (want / got as the test prints them):

wave64: group [40, 1, 1] wave 0 (40 lanes) | want [24, 64, 7, 33] | got [[0, 40, 0, 0]]
wave64: group [96, 1, 1] wave 1 (32 lanes) | want [32, 64, 7, 33] | got [[0, 32, 0, 0]]
wave64: group [1, 1, 1]  wave 0 (1 lanes)  | want [63, 64, 7, 33] | got [[0, 1, 0, 0]]
wave32: group [20, 1, 1] wave 0 (20 lanes) | want [12, 32, 7, 33] | got [[0, 20, 0, 0]]
wave32: group [52, 1, 1] wave 1 (20 lanes) | want [12, 32, 7, 33] | got [[0, 20, 0, 0]]

One difference from the NVIDIA failure quoted in the description (got [0, 40, 7, 0]): natively on this GPU the third word is 0, not 7, in every case. I have not looked into why; it is the unfixed path either way.

Regression run – scripts/smoke.ps1 -Game <folder> on a retail title, release builds, no uncommitted changes, same machine, the five runs one after the other in this order. All five: exit 0x0, 0 device removals, 0 crashes. The gpu: line names the wrong adapter (the script's known issue, #281 / #282 / #285); the GPU was the RX 7800 XT. Blocks unedited.

  1. main, first run on an empty cache/ (the First run of a title: the coherent window is 512 MB until uma_coherent.txt has been learned (menus at ~12 fps, then 30) #284 first-run window; a warm-up, not for comparison):
xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 966 (PresentX 966)
presents per 2 s (last 3): 38 39 39
device removals: 0
crashes: 0
peak commit: 15681 MB
  1. main, second run:
xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1470 (PresentX 1470)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15549 MB
  1. this PR, first run with its exe (its padded compute programs translate differently, so they compile anew):
xcl-smoke v1
commit: ba633669be03d9a41a314a3204d58fe4cc88237d
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1393 (PresentX 1393)
presents per 2 s (last 3): 60 58 14
device removals: 0
crashes: 0
peak commit: 15773 MB
  1. this PR, second run:
xcl-smoke v1
commit: ba633669be03d9a41a314a3204d58fe4cc88237d
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1261 (PresentX 1261)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 16236 MB
  1. main again, right after:
xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: Meta Virtual Monitor
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1262 (PresentX 1262)
presents per 2 s (last 3): 1 0 1
device removals: 0
crashes: 0
peak commit: 16302 MB

Reading: the consecutive pair 4 / 5 is 1261 vs 1262 frames and 16236 vs 16302 MB peak, so no difference between this PR and main on this title. The spread between runs of the same build (main 1470 → 1262) is far larger than any main / PR difference, and the near-zero presents at the end of runs 4 and 5 appear on both builds alike, so they come from where the title is by then (it stops presenting in its last seconds), not from this PR. Run 3's lower count and its 14 are what a first run with new shader translations looks like; run 4 does not repeat it.

Not tested: how many of the title's compute programs get padded (not counted); which screen the title reaches, and why it stops presenting near the end of runs 4 and 5, was not looked at; no RDNA4 / RDNA2 (this machine has one GPU).

Report written with Claude Code (Claude Fable 5.1) from the runs above; the commands and counts are from this machine.

@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@Rednaxeh thank you, the first AMD run and the first regression runs this PR has. One catch: after @JGonzalezRodriguez's finding above, the head moved to 3aaef99. The only change from ba63366 is the null-destination fix in partial_waves.rs / upper_lanes.rs and its tests (git diff ba63366 3aaef99). The PR check wants the PR's block made on the head commit. If you can, a single scripts/smoke.ps1 run built from 3aaef99, same title and length, is all it needs; your main blocks still count. Your results go into the description either way, with your name and hardware.

🤖 Claude Opus 5.5

@PHeitor1

Copy link
Copy Markdown

Re-tested the new head 3aaef99 merged onto main 2b4bb43 (clean merge) on RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed, so the debug-layer tests run), rustc 1.100.0 MSVC, debug, cargo test --workspace --no-fail-fast -- --test-threads=4, no XCL_SAMPLE_*.

Pass: 683 passed, 0 failed, 41 ignored. SKIPPED: only the 2 no wave64 tests.

Run and written with Claude Code (Claude Opus 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