Repository navigation
shader: support defined numeric M0 in direct compute - #3205
Conversation
pigalot
left a comment
There was a problem hiding this comment.
I tried to review 6307e672 over current main 6cc46a3c. The trial merge conflicts in both source files, and the conflicts are semantic, not just textual. Three PRs landed after this PR's base 673a9f2c and changed the same three spots:
Emit::require_numeric(src/gfx1013_compute_native.cpp): #3180 (63fd6ea8) gave it alimitparameter (reg < limit, default 106), andoperand32now passessgpr_limit. This PR'sreg <= 105 || reg == 124has to be folded into that form, for example(reg < limit || reg == 124). If the conflict is resolved by keepingmain's side, reads of M0 would skip the numeric check entirely, since 124 is above every limit. Yourundefinedandpartial_joincontrols should catch that, so please make sure they still run after the rebase.operand32(src/gfx1013_direct_compute.inl): the samerequire_numeric(i, n, sgpr_limit)call. Thenumeric_m0condition itself merges unchanged.- The
s_mov_b32/s_mov_b64destination guard: #3192 (2b7ebf18) replaced!(wave64 && i.dst == 127)with anexec_hiflag that also covers wave32s_mov_b32 exec_hi. Both clauses need to stay:!exec_hi && !(compute && i.dst == 124 && n == "s_mov_b32").
Reading of the change itself, from the diff only, not run:
- M0 entry state: it starts
unbound, so a read before any write refuses. - Raw loads: M0 is still refused as a raw-load
soffsetafter #3172, whose decoder admits SGPRs 0 to 105 only. - Other memory operands:
operand32excludes MUBUF/MTBUF/GLOBAL (allEncoding::Mubuf) and SMEM, so M0 cannot become a memory offset through that path either.
I found nothing else to change there. I stopped at the conflict, so I have not built or run this head.
Requested: rebase onto current main with the three resolutions above, then re-run native_m0_controls / native_m0_hardware. I'll retest the new head.
Environment: Windows 11 25H2 build 26200.9974; Git trial merge only.
CI: Build and test on Windows passes on 6307e672 against its own base.
This reply was AI-assisted.
6307e67 to
906d027
Compare
|
Thanks for the precise conflict analysis. Rebased #3205 onto a5c02db as 906d027, preserving all three semantics: numeric M0 with the caller's SGPR limit, the sgpr_limit call, and the upstream EXEC_HI exception alongside the M0 s_mov_b32 exception. Both Debug and Release native_m0_controls passed, including undefined and partial_join. The stock native_m0_hardware fixture skips on this host; relinking the freshly built replay objects with the existing app-local Agility 1.620.2 export and using the upstream --direct-warp mode gave exact 2064-DWORD readbacks on RX 7900 XT and WARP in both builds (4/4, 8256 DWORDs). No changes to the test oracle or M0 scope. The prior commit is retained locally. Debug layer unavailable. Buhe; AI-assisted. |
There was a problem hiding this comment.
I reapplied exact head 906d0271 over main 886a5a28 (trial tree 382502fb) without a conflict. I checked the three areas called out on the prior head: the caller's SGPR bound is preserved, the numeric M0 read still receives that bound, and the wave32 EXEC_HI and M0 s_mov_b32 destination exceptions coexist. MUBUF/SMEM still exclude M0. Debug and Release /O2 each passed native_direct_container, native_m0_controls, and native_salu_shift64_controls from a source build, with no skips. These are compiler/validation results; the GPU-vendor results above are the author's. @pigalot, the rebase addresses the conflicts you identified on 6307e672; could you update your review for the new head?
Follow-up on the same trial tree: the stock native_m0_hardware fixture passed in both Debug and Release /O2 on RTX 4060 Laptop (32.0.16.1656, Windows 11 26200.9974), with an exact 2,064-DWORD comparison per run and no capability skip. The standalone compute replay does not enable the D3D12 debug layer.
pigalot
left a comment
There was a problem hiding this comment.
I retested 906d0271 merged over main c1de64a5. The merge is clean (tree 6af2f070) and git diff --cached --check is clean. This supersedes the changes-requested review on 6307e672.
Earlier findings. All three are addressed at this head:
Emit::require_numeric: the check is now(reg < limit || reg == 124). A caller's lowerlimitis kept, and M0 is always checked.operand32: it still passessgpr_limittorequire_numericfor the numeric M0 read.s_mov_b32/s_mov_b64destination guard: #3192'sexec_hiexception and the newcompute && i.dst == 124 && s_mov_b32exception are separate clauses. A wave64s_mov_b64into M0 stays refused.
What I traced.
- Analysis: M0 starts
unbound, so a read before a defining write is refused, and a join of defined and undefined stays refused. - Exclusions: MUBUF and SMEM still exclude M0 as an operand, so this change doesn't touch M0 memory addressing (#3172's scope).
What I ran. I built compile_dxil native_store_replay native_compute_ir_dump 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_m0_(controls|hardware)|native_salu[a-z0-9_]*|native_direct_container|native_permlane_(controls|hardware)|native_scalar_lds_hardware|native_readlane[a-z0-9_]*|native_lane[a-z0-9_]*)$'- Results: 22 pass and 1 skips, in both Debug and Release
/O2. The skip (77) isnative_lane_spill_descriptor_warp, an existing WARP test this PR doesn't touch. - Hardware coverage:
native_m0_hardwareran here, with no skip, and matched the 20 value words and all 2,044 guard and untouched words for both groups.native_m0_controlsgives the expected refusal forundefined,partial_join,descriptor,pair_source,pair_destinationandmemory_offset. - Negative control: on
maind6912f58, the PR'snative_m0_check.pyfails in both modes.controlsis refused atnumericwith+0x1c: direct scalar move destination, and thehardwarereplay compile fails.
Mutants. For each, I rebuilt in dev and ran native_m0_(controls|hardware):
| Mutant | Result |
|---|---|
require_numeric without reg == 124 |
killed (undefined compiles) |
M0 not initialised unbound |
killed (undefined compiles) |
| numeric M0 also accepted in MUBUF | killed (memory_offset) |
| scalar move destination refusal disabled | killed (pair_destination) |
M0 destination exception widened to s_mov_b64 |
killed (pair_destination) |
Restored and rebuilt afterwards; git diff --quiet is clean.
Verdict: approve on 906d0271.
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 906d0271.
This reply was AI-assisted.
Fixes #3202. Refs #2935, #3143 and #3172.
Change
Support defined numeric M0 (RDNA2 scalar encoding 124) in the direct compute frontend. Reuse the existing per-wave register storage, numeric state analysis and CFG joins. Allow the 32-bit scalar move destination and explicit numeric operand reads; keep M0 unbound on entry. This adds eight production lines and removes four. No new state structure or memory-addressing support.
The raw-buffer-load decoder is unchanged: #3172 owns the off/offen and nonzero SGPR-offset work, and still explicitly excludes M0. M0 buffer offsets remain refused. This is a separate register-support prerequisite, not a claim to implement implicit LDS, relative VGPR indexing, interpolation, or all M0 instruction forms. The existing 64-bit pair restrictions remain.
Actual verification
Base 673a9f2, candidate 6307e67.
Public source-generated fixtures only. AI-assisted; locally tested by Buhe (@xiaoqi72665).