Repository navigation
shader: lower v_permlane16_b32 and v_permlanex16_b32 in direct compute - #3022
Conversation
R0Y00
left a comment
There was a problem hiding this comment.
Independent retest at 125f5313 stacked on #3010 (7325dd17). I rebuilt compile_dxil and native_store_replay and ran native_permlane_controls and native_permlane_hardware separately with ctest --preset <dev|release> --no-tests=error -V -R '^native_permlane_(controls|hardware)$'. Both passed in Debug and Release /O2 without skips. The hardware replay matched 128 result words plus all guards in each of six cases with the inbox D3D12 runtime (Windows 11 build 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, replay debug layer off). No WARP test is registered.
The AMD RDNA 2 ISA guide, §12.12 confirms the selector packing, row pairing and FI/BOUND_CTRL bit positions. The desktop readback exercises the proposed inactive-source model. The exact preserve-versus-zero behavior still needs a native RDNA 2 result. All 47 measured requests are flagged wave64, while the current wave64 control only compiles. Please coordinate with #3006 on a split-wave64 bit-exact readback with different lower/upper EXEC masks, so selecting the wrong half fails at a known lane.
|
#3010 is now on |
|
Rebuilt from current
AI-assisted. |
|
Thank you for the rebuild onto
Smaller points, take or leave:
For the record, on a different stack (RTX 4070 Ti SUPER, Linux driver 550.163.01, vkd3d-proton under Proton experimental-11.0, debug layer off), This comment was AI-assisted. |
Lane i of a 16-lane row reads S0 from lane ({S2,S1} >> 4*(i & 15)) & 15
of its row (permlane16) or of the other row of its 32-lane half
(permlanex16). S1 and S2 are uniform: SGPRs, inline constants or one
32-bit literal (the decoder now refuses a literal in S0 or two
literals). op_sel[0] is FI and op_sel[1] is BOUND_CTRL, with the DPP
rule for an inactive source (assumed). Rows stay inside one physical
wave32, also on the wave64 path. Other op_sel bits, modifiers,
non-uniform or special selectors and thread counts that leave a
partial row or pair are refused.
A new check runs six programs on hardware against a CPU reference and
checks the refusals; wave64 is covered by a compile case.
AI-assisted.
Bit 20 of .sa dword 4 is the wave32 flag (R0Y00#2999). Setting it keeps these 32-lane fixtures on the wave32 model once the request reader honours it; without that reader the bit is ignored. AI-assisted.
S1 and S2 of v_permlane16_b32 / v_permlanex16_b32 may both reference the one trailing literal word, as LLVM encodes it; that form now compiles and is read back. A literal in S0 stays refused. A clamp control pins the abs/neg/clamp/omod refusal. The experiment note gives the tested base (main 6057071 plus this branch) and the measurement base (cpp-migration 999e17c plus R0Y00#3010), and says the wave64 branch is compiled only. AI-assisted.
|
Thank you for the review and for the second-stack run. Rebased on
Smaller points:
AI-assisted. |
pigalot
left a comment
There was a problem hiding this comment.
I reviewed b912ad58 merged over main f6206217. The merge is clean (tree 03bd58f5) and git diff --cached --check is clean.
What I traced.
-
Against the RDNA2 definition:
- the selector for row lane
Lis nibbleL & 7of S1 for lanes 0..7 and of S2 for lanes 8..15; v_permlane16_b32reads lanerow_base | selof the current row;v_permlanex16_b32flips row bit 4, so each row reads the other row of its pair.
- the selector for row lane
-
op_sel: bit 0 is FI and bit 1 is BOUND_CTRL. Without FI, an inactive source lane gives 0 under BOUND_CTRL and keeps D otherwise. Guest EXEC still predicates the write.
-
Refusals: S0 must be a VGPR, and a literal S0 is refused in the decoder. Modifiers and the other op_sel bits are refused.
-
Earlier requests: R0Y00's rebuild from
mainand the base change are done. JohnConnorNPC's points are each answered at this head:- the doc bases are corrected;
- a shared S1/S2 literal is accepted, with a read-back case;
- a clamp control is added;
- the
vcc_hiwording is fixed.
The split-wave64 readback is deferred to #3006, as the maintainer asked.
What I ran. I built compile_dxil native_store_replay native_compute_ir_dump offscreen_check in dev and release, then ran
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(native_permlane_(controls|hardware)|native_dpp[a-z0-9_]*_hardware|native_direct_container|native_lane[a-z0-9_]*)$'- Results: 8 of 9 pass in Debug and Release
/O2.native_lane_spill_descriptor_warpreports a 77 skip in both builds; it is an existing WARP test that this PR doesn't touch. - Hardware coverage:
native_permlane_hardwarematched 128 results and all guards in each of its seven cases, includingcross-shared-literal. - Negative control: on
maind6912f58, the PR'snative_permlane_check.pyfails in both modes.controlsgetsrequests=7 compiled=0 refused=7("direct DXIL lowering for v_permlanex16_b32"), and thehardwarereplay compile fails.
Mutants in src/gfx1013_direct_compute.inl. For each, I rebuilt in dev and ran native_permlane_(controls|hardware):
| Mutant | Result |
|---|---|
x16 keeps its own row |
killed (cross-literal-bound word 8: 0x0 vs 0x25) |
| S1/S2 swapped | killed (word 8: 0x2c vs 0x25) |
| BOUND_CTRL ignored | killed (word 24: 0x21 vs 0x0) |
| FI ignored | killed (cross-sgprs-fi word 24: 0x21 vs 0x15) |
| the destination lane's EXEC bit tested instead of the source's | killed (word 24) |
| nibble index from lane bits 0..1 only | killed (word 12) |
| modifier refusal removed | killed (controls) |
| special-SGPR selector refusal reduced to "not a VGPR" | survives |
Restored and rebuilt afterwards; git diff --quiet is clean.
Non-blocking.
- Selector refusal: the selector refusal is pinned only by the VGPR case (
v2/v3/s13). No control usesvcc_lo,m0orexecas a selector. The refusal is a scope limit, not a correctness need, sinceoperand32can read those numerically. One control row would pin it. - Wave64: the wave64 EXEC-half path is still unread, as you noted. #3006 is still open.
- CI: the
prCI preset doesn't selectnative_permlane_*, so this run and yours are the Windows evidence at this head.
Verdict: approve on b912ad58.
Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI: Build and test on Windows passes on b912ad58.
This reply was AI-assisted.
Fixes #3021. Part of #2935. Target branch
main. The measured requests reach these ops only once DPP16 row operations are lowered; that is #3010, now onmain.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl): direct compute now lowersv_permlane16_b32andv_permlanex16_b32.iof a 16-lane row readsS0from lanesel = ({S2, S1} >> (4 * (i & 15))) & 15.permlane16reads from the same row.permlanex16reads from the other row of the same 32-lane half.op_sel[0]is FI andop_sel[1]is BOUND_CTRL.op_selbits, abs, neg, clamp and omod;vcc_lo,vcc_hion the wave64 path, exec, m0, null), and an S0 that is not a VGPR. In wave32,vcc_hiis ordinary scalar data;permlane16) or 32 (permlanex16).Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on
main6057071bplus this branch. The D3D12 debug layer is not installed. Release and Debug (devpreset) builds both pass.native_permlane_hardwarepassed. Seven wave32 programs ran in two 64-thread groups with sparse guest EXEC. All 2,064 output words matched a CPU reference, sentinels included. The programs are:x16with BOUND_CTRL and a literal-plus-SGPR selector;x16with FI and two SGPRs;x16with inline 0 selectors;permlane16with BOUND_CTRL and a literal-plus-SGPR selector;permlane16with two SGPRs;x16with an SGPR in S1 and a literal in S2;x16with the same literal in S1 and S2.The selectors differ per row lane, and S1 differs from S2.
native_permlane_controlspassed. A wave32 request and a split-wave64 container compile. These are refused:op_selbit 2;x16with 16 threads, andpermlane16with 8;Wave64 is covered by that compile case only, not by a readback.
The 9
native_dpp*,native_lane*,native_wave*,native_readlane*andnative_permlane*tests pass.Mutation checks, run by hand; each fails the hardware check:
x16;Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests.cpp-migration999e17cdplus shader: lower DPP16 row_shl, row_shr and row_ror in direct compute #3010, before shader: lower DPP16 row_shl, row_shr and row_ror in direct compute #3010 reachedmain).AI-assisted.