Repository navigation
Conversation
The console runs whole-wave code in every lane of the wave, inactive ones too; the PC runs only the lanes it launched. The pack's whole-wave code in VS / PS is the compiler's form of a wave reduction (min_u32, max_u32, or_b32): s_or_saveexec -1, v_cndmask of x / the op's identity by a mask within the saved EXEC, three DPP8 steps, row_mirror, v_permlanex16, then v_readlane 32 and 0 (wave64) or 0 (wave32), EXEC restored. In a partial wave (a primitive's edge, the last vertices of a draw) the steps read lanes that were never launched: 0 on NVIDIA, so a min gave 0, on every GPU and at both wave sizes. reductions.rs recognises that sequence as a whole: exactly those instructions (s_waitcnt / s_nop / v_nop between them), the mask the saved EXEC or s_and of it, the constant the op's identity, DPP8 selects that with the row_mirror take in the whole row (followed as the set of lanes each lane has read; the pack's selects are not lane-xor permutations: [2,2,0,0, 6,6,4,4] and [4,4,4,4,0,0,0,0] after the pair step), no branch into it, EXEC restored right after. Anything else is left as it was. The emitter replaces it, from the v_cndmask to the last v_readlane, with xcl_wave_<op>(x, mask): the op over the mask's lanes per 16-lane row of the hardware wave (WaveActiveMin(row == k ? q : identity)), and from the rows every value the steps leave - sH, sT, vA (wave64: the wave's in lanes 0..31, the upper half's in 32..63) and vB (the other row's) - in every lane. Lanes that were not launched are never in the mask; wave operations leave out helper lanes, so in a PS q is first the op over the quad through quad reads (a mask from EXEC after s_wqm holds helper lanes). A 64-lane wave of a wave32 program holds two console waves: rows 0-1 / 2-3 by xcl_half. The form is the same at every wave size, so it also changes the HLSL of GPUs with 64-lane waves, for VS / PS with a reduction only. Reads inside a recognised reduction no longer need upper_lanes' 32-lane form. Compute-like modes keep the steps (a wave64 console wave is two hardware waves there on 32-lane GPUs). XCL_NO_WAVE_REDUCTIONS=1 translates each step on its own, as before. Tests: reductions::tests (the pack's sequences at both wave sizes and variants recognised; other identities, masks not within the saved EXEC, other ops, steps that leave lanes out, other DPP16 controls, permlane16, other lanes, extra whole-wave instructions, branches into it left alone), whole_wave_reductions_translate_to_wave_operations (HLSL of every VS / PS form, DXC), and on the GPU gpu_ps_partial_wave_reductions (wave64 and wave32; min / max / or over the odd pixels and over the quads' lanes; whole target, 3 quads, 55 pixels; sT, sH, vA, vB of every pixel against a console wave of the same lanes) and gpu_vs_partial_wave_reductions (3 vertices). On an RTX 5070 Ti both GPU tests fail with XCL_NO_WAVE_REDUCTIONS=1: every partial-wave min (sT, vA, vB) is 0, the or over the quads' lanes of 3 quads misses two helper pixels, the VS min and vB are 0. Full waves are right either way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
retail_wave_reductions_census (ignored) lists the pack's whole-wave sections by mode and wave size, recognised by op or left by reason: - wave64 VS / PS: all 1 082 sites in 436 programs (min 325, max 322, or 435 sites); every lane >= 32 read as a constant (#133) is inside one, 110 of those programs still get the 32-lane form for spill slots. - wave32 PS: all 2 106 sites in 926 programs (min 588, max 588, or 930). - compute / mesh, where the translation keeps the steps: the same form at 4 371 of 4 607 wave32 CS sites, 94 of 1 148 wave64 CS, 17 of 17 wave64 MS; the rest are sums (add u32 / f32 / f16, prefix sums with row shifts), a float min / max with its identity from a VGPR, v_and_b32. retail_wave64_graphics_lane_forms also compiles the native form of every VS / PS with a recognised reduction, and XCL_FORMS_LIST writes each program's digests. Against XCL_NO_WAVE_REDUCTIONS=1 (digests ac67db269b7452be / 09d45ad13eddc30d, as main) the native HLSL changes for exactly the 1 362 VS / PS with a reduction (436 wave64, 926 wave32; digest 2adc8e0b13d2f20e) and for no other of the 26 698 programs; the other modes' 32-lane digest is unchanged; the 32-lane form differs for 287 programs (spill slots, 613 before). DXC compiles all of them. docs/wave64-on-wave32.md ("Whole-wave reductions") and HANDOFF.md describe the form, the numbers and what is left. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Wave operations leave helper lanes out; on the RTX 5070 Ti WaveActiveMin / Max / BitOr return 0 there. The console leaves the result in every lane, helpers included, and the helpers' copies feed the derivatives of what is computed from it (quad_perm, ds_swizzle, implicit-LOD samples: 429 of the retail PS with a reduction read one after it). The pixel helpers now take each lane's result through the quad (a helper contributes the op's identity), so every lane of a quad holds the wave's result. gpu_ps_reduction_result_in_helper_lanes: sT, vA and vB after a min / max / or, read by the live pixels through quad_perm, wave64 and wave32, three triangle shapes (46 of 54 cases differed before). gpu_ps_reductions_in_branches_and_loops: the retail structure (live pixels saved, s_wqm, a kill, s_and_saveexec / s_cbranch_execz, a min, an or in a loop) in five shapes. Both came from review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
draw_on_multi made a command queue and fence for every draw. Once a test has brought up the D3D12.X backend (gpu_sparse_vram_descriptors_buffers_and_xmem calls hle::d3d12x::real::init) its hooks are on the device the process gets for the adapter, and queues made through them were not given back: with the draw-heavy reduction tests running next to it, CreateCommandQueue failed with E_OUTOFMEMORY (only with several test threads, depending on order). The draws now share one queue and fence per device. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Tested #152
New failure:
Every wrong value is 0, in sT, vA and vB, e.g. Since max and or have identity 0, a stray 0 is invisible to them, so this looks like a lane outside the mask (a helper or an unlaunched lane of a partial quad) contributing 0 instead of the identity – probably in the quad step for helper lanes. On this AMD driver, quad reads of those lanes seem to return 0 rather than what the step expects. Full output available. |
|
Follow-up on the What happens: the reduction call is not in divergent control flow (checked the dumped HLSL: uint4 h = IsHelperLane() ? (uint4)0xFFFFFFFFu : t;
return min(min(QuadReadLaneAt(h, 0u), QuadReadLaneAt(h, 1u)), min(QuadReadLaneAt(h, 2u), QuadReadLaneAt(h, 3u)));returns 0 in live lanes whose quad has a helper lane: a live lane's Change tried (in - let _ = writeln!(s, " return {c};\n}}");
+ let _ = writeln!(s, " uint4 c = {c};\n return IsHelperLane() ? c : t;\n}}");Result on RX 6600 XT: Caveat: a helper lane's own copy still comes from quad reads, so on AMD it may still be off – which matters only for derivatives of the result in partly covered quads, and the test checks live pixels only. Not tested on NVIDIA; the change shouldn't alter live lanes there, since |
|
Tested on an RX 7800 XT (RDNA3, driver 32.0.32029.2010, Windows 11 26300). This driver runs wave64 PS in 32-lane waves.
The 42 are exactly the Edit: - let _ = writeln!(s, " return {c};\n}}");
+ let _ = writeln!(s, " uint4 c = {c};\n return IsHelperLane() ? c : t;\n}}");
|
|
@Foniass, a note on the compute side that this PR's "Not covered" names, and an offer. I measured the same gap (lanes EXEC turns on but the wave never launched) for wave64 compute groups on main
For compute there is a way that needs no matcher: launch the missing lanes. Declare I can send that as a separate PR. It would only touch the compute entry, so it should compose with this one: your reductions keep VS / PS, and a compute reduction would simply run its steps in real lanes. It does nothing for mesh. Would you rather do the compute part yourself, as the follow-up you describe? If so I will leave it and hand over the tests (24 mask programs in partial groups of 40 / 42 / 20 / 10 / 96 threads, plus the case above). Otherwise I will open the PR and link it here. AI-assisted (Claude); tested on an RTX 5070 Ti, NVIDIA 610.74. |
|
Linux / Turing run of
No new failures. The new tests pass here: The 5 failures on every build are this stack's memory-window reads, which return zeros (explained in #175), and are the same on So the helper-lane quad reads in the Not covered: AMD under Linux (RADV); AI-assisted (Claude Code). |
|
#152 on an RTX 3070: the helper-lane change on NVIDIA, and where the reduction coverage ends Setup: NVIDIA GeForce RTX 3070 8 GB (driver 616.92, D3D12 wave range 32..32), Ryzen 5 5600X, Windows 11 build 26200, Rust 1.95.0, debug build, DXC 1.8.2502.11. 1. The helper-lane change works on NVIDIA. This is the one-line change proposed above for the AMD
2. An extra check, written separately from this PR's code and tests. A GPU test against its own CPU model of the console wave64: the 64 lanes stepped through as the ISA defines each instruction, unlaunched lanes holding the identity. The model is checked against a plain fold over the masked lanes. Source below.
Not tested:
The extra test (paste into
|
|
Independent RDNA4 check on Setup: Radeon RX 9060 XT, driver
This confirms the proposed change fixes the reported failure on RDNA4 for these fixtures. I did not run the full workspace suite. AI use: OpenAI Codex (GPT-6.2 Sol) ran both builds and drafted this report. |
|
Closing as a stale, conflicting ~1,500-line pre-template PR (touching |
Follow-up to #133, as asked there: whole-wave reductions in VS / PS are recognised as a whole and emitted as wave operations.
Problem (every GPU)
v_permlanex16andv_readlane32 / 0.Change
Matcher (
recomp/reductions.rs): it recognises the whole sequence, with these checks:The pack's DPP8 selects aren't xor permutations, so it follows the set of lanes each lane has read and requires whole rows after the mirror. Anything else keeps the old steps.
Emitted:
xcl_wave_<op>(x, mask)gives the op over the mask's lanes for each 16-lane row of the hardware wave. From those rows, every register (vA, vB, sH, sT) is written as the console leaves it.WaveActive*returns 0 in helper lanes.xcl_half.Scope: wave64 VS / PS, and also wave32 PS, which has the same reduction and the same partial-wave bug (926 programs). Compute and mesh keep the steps (see below).
Switch:
XCL_NO_WAVE_REDUCTIONS=1gives the old translation for comparison.Test runner: draws share one command queue per device instead of making one per draw.
gpu_sparse_vram_descriptors_buffers_and_xmembrings up the D3D12.X backend (real::init), whose hooks then sit on the adapter's device, and the per-draw queues made through them were not given back. With several test threads, the draw-heavy tests here ended in E_OUTOFMEMORY atCreateCommandQueue, depending on order.Census (
retail_wave_reductions_census, ignored)retail_wave64_graphics_lane_forms: the native HLSL changes for exactly the 1 362 programs with a reduction; the 25 336 others are byte-identical (per-program digests, checked againstXCL_NO_WAVE_REDUCTIONS=1, which reproducesmain's digests). The other modes' 32-lane digest stays09d45ad13eddc30d, and the 32-lane form now differs for 287 programs. DXC compiles all 1 362, with 0 errors.Tests (RTX 5070 Ti, 32-lane waves)
gpu_ps_partial_wave_reductions: wave64 and wave32; min / max / or over the odd pixels and over whole quads; whole target, 3 quads and 55 pixels. sT, sH, vA and vB of every pixel are checked against a CPU model of the console wave. With the old translation every partial-wave min is 0.gpu_vs_partial_wave_reductions: a wave of 3 vertices.gpu_ps_reduction_result_in_helper_lanes: the result in helper lanes, read throughquad_perm; 46 of 54 cases differed before the helper fix.gpu_ps_reductions_in_branches_and_loops: the retail structure (s_wqm, a kill,s_and_saveexec/s_cbranch_execz, a min, an or in a loop) in five shapes.reductions::tests: matcher unit tests, for accepted and rejected variants.cargo test --workspace --releasewithXCL_SAMPLE_RPF: 576 passed, 0 failed (2no wave64skips, as onmain). Lib tests withXCL_SPLIT_WAVE64=1: 543 passed.main, 60 fps.xcl_halfpath.Not covered
v_cmpafters_wqmhas no helper-lane bits on the PC (WaveActiveBallot), so the quad-read step only helps when the mask is the saved EXEC. Only 10 wave32 PS sites in the pack may take the mask that way. Pixel shaders: masks hold the helper lanes (#105 item 1) #134 addresses that in general, and the two shouldn't conflict.🤖 Generated with Claude Code