Repository navigation
Conversation
887ae29 to
ba63366
Compare
|
Tested
Not run: the new tests without the AI-assisted (Claude Code). |
|
Tested on RTX 5060 Ti 8 GB, driver 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native), Rust 1.100.0 msvc, debug. Run and written with Claude Code (Claude Opus 5.5). |
|
Tested commit Tested
* On AMD RADV, the 3 failures ( The native wave64 reorder prologue, Findings1. 64-bit writes with
This causes both a false negative (missed padding) and false positives (spurious padding) on partial waves with
Guarding (Minor: in Not tested
AI useAntigravity (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. |
|
@JGonzalezRodriguez thank you, and for the RADV wave64 run. Finding 1 holds as you describe: 🤖 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>
ba63366 to
3aaef99
Compare
|
Tested the new head Tested
The switches, the 13 tests above only (
With Regression run
Not tested
AI use: Claude Code with Claude Opus 5.5 ran the builds and tests and wrote this report; the numbers come from those runs. |
RDNA3: Radeon RX 7800 XT (native 64-lane waves) on
|
| 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.
main, first run on an emptycache/(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
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
- 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
- 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
mainagain, 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.
|
@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 🤖 Claude Opus 5.5 |
|
Re-tested the new head Pass: 683 passed, 0 failed, 41 ignored. SKIPPED: only the 2 Run and written with Claude Code (Claude Opus 5.5). |
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_writelanewrites 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, onmain9ab7d76: about 310 lines of translator code and about 450 of tests. The earlier heads were887ae29andba63366(the same patch, rebased).3aaef99adds the fix for 64-bit writes to NULL that @JGonzalezRodriguez found (below).What is in it
What was wrong:
v_writelanewrites the inactive lanes whatever EXEC is.s_or_saveexec_b64 s, -1around whole-wave code,s_mov_b64 exec, -1,s_not_b64 exec, exec,s_wqm_b64 exec, exec.Measured on
main956a476(RTX 5070 Ti, split form; the same withXCL_X64_ALL_MASKS=1andXCL_WAVE64_SPIN=1). Expected values are the ISA's definition, not a console measurement:s_not_b64 exec, exec, then bits ofv_cmp_eq_u32 vcc, v0, v0s_or_saveexec_b64 s, -1, then the samev_movunder EXEC = -1,v_readlaneof lane 63Wave32 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.
[numthreads(64, 1, 1)]for 40 threads, 1-D whatever the console's shape.thread index < 40.Which programs are 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).v_writelaneto a lane the last wave may not launch, or when EXEC may get a bit outside the launched lanes.3aaef99, the pass wrote its high word to s126 (EXEC_LO), andupper_lanes::sgpr_outputslisted a null SDST / VDST as two registers. With EXEC_HI 0,s_or_saveexec_b64 null, 0xFFFFFFFFwas then not seen as turning lanes on, ands_and_saveexec_b64 null,s_and_b64 nulland a VOP3v_cmpto null padded for nothing. @JGonzalezRodriguez found this.XCL_CS_PAD_ALL=1pads every group that is not whole waves, andXCL_NO_CS_PAD=1pads none. Both are for comparison and bypass the shader caches.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=1is 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 ofballot(true)(xcl_x_ballotin the split form). It is the same function in the same place.Split form (32-lane hardware):
XCL_X_THREADSis the padded count.xcl_x_threadand 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;InterlockedAddon the groupshared counter,WaveReadLaneFirst;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_launchedandgpu_wave32_valu_code_in_lanes_not_launched: one program, run in 1-D, 2-D and 3-D groups. It:s_not exec, execand afters_or_saveexec s, -1;v_writelanewrote.Both fail without the change. Each also runs with
PadWaves::Never(the translationmainmakes) 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: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, 0xFFFFFFFFwith 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) andcompute_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_seenandmasks_discarded_into_null_leave_exec_alone; both fail without the fix in3aaef99.Tested
cargo test --workspace -- --test-threads=4on3aaef99: 664 passed, 0 failed, 40 ignored (SKIPPED GPU tests:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_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.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_launchedpasses with the fix. Without it, every thread counts 20 lanes instead of 32.ba63366, on our machine: 661 passed, 0 failed, 40 ignored, with the same two SKIPPED tests.3aaef99, merged ontomain4017f8f(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;main4017f8fgave 652 / 0 / 40 on both.gpu_wave64_saveexec_to_null_turns_on_lanes_not_launchedincluded, ran in native 64-lane waves there.XCL_CS_PAD_ALL=1: 13 passed on both. WithXCL_NO_CS_PAD=1: 10 passed and 3 failed on both, the three GPU tests in their padded half, as expected.ba63366(main9ab7d76+ 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, withXCL_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;main9ab7d76gave 651 / 0 / 40.gpu::recomp::: 192 / 0 / 18 natively, and the same withXCL_SPLIT_WAVE64=1,XCL_CS_PAD_ALL=1,XCL_WAVE64_SPIN=1andXCL_X64_ALL_MASKS=1.XCL_NO_CS_PAD=1, both…_valu_code_in_lanes_not_launchedtests fail in every partial wave, natively on 64-lane hardware too.3aaef99merged ontomain2b4bb43, 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)).ba63366and887ae29, which carry the same patch.3aaef99differs from them only by the null-write fix and its tests (git diff ba63366 3aaef99:partial_waves.rs,upper_lanes.rs,tests.rs).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)).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)).887ae29(the same patch asba63366), 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::tests6/6 and the four new tests 4/4 on both GPUs.XCL_NO_CS_PAD=1, and with the two GPU tests on base60565c4), both…_valu_code_in_lanes_not_launchedtests 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 withXCL_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 base60565c4.887ae29(main60565c4+ the same patch):<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.XCL_NO_CS_PAD=1, which makes the translationmain's), both…_valu_code_in_lanes_not_launchedtests fail in every partial wave. For example:[24, 64, 7, 33], got[0, 40, 7, 0];[12, 32, 7, 33], got[0, 20, 7, 0].gpu::recomp::test (<lib test exe> gpu::recomp:: --test-threads=2):XCL_CS_PAD_ALL=1(every partial compute group padded)XCL_WAVE64_SPIN=1XCL_X64_ALL_MASKS=1XCL_X64_ALL_MASKS=1aregpu_split_wave64_lane_local_masksandgpu_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 withmain's translator when I ran it onaf20b4b.cargo test --workspace --no-fail-fast -- --test-threads=2: 661 passed, 0 failed, 40 ignored (lib: 621 / 0 / 20).Overlaps:
docs/wave64-on-wave32.mdsays that "the console group keeps itsnumthreads". 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:
PR: previous head
ba63366; it differs from3aaef99only by the null-destination fix. A block at3aaef99has been asked for.Not tested
3aaef99: so far it ran only atba63366(above). How many of a title's compute programs get padded is not counted.ba63366, before the null-write fix;3aaef99;887ae29.AI use