Repository navigation
feat(victory-shader): implement s_movrels_b32 and s_movreld_b32 lowering - #608
Amit89-beep wants to merge 2 commits into
Conversation
|
RDNA2 hardware check of the two rules: they match. Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) fills
So Out of range: with M0 = In case a follow-up adds the 64-bit forms: in the same runs AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run. |
catminou4
left a comment
There was a problem hiding this comment.
Conflicts with current main (ffe310e) in lower.rs/bitcode.rs — needs a rebase.
Static review: the M0-relative lowering handles static M0 (constant-folded via the new Module::as_i32) and dynamic M0 (select chain over the reachable SGPR span), with the IR's effects extended so the span is tracked as reads/writes — the relative_sgpr_access_spans_up_to_106 test covers that. Two things I'd want before approving:
- Execution evidence: the tests are
lowers(...)smoke tests — they prove translation, not values. A host test (like the valu suite) writing known SGPRs and checkings_movrels_b32/s_movreld_b32results for a few M0 values (in range, out of range, negative) would make this solid, especially the out-of-range-returns-0 behavior which I can't verify from the ISA docs alone. - The dynamic path builds up to 106 selects per instruction; fine for rare scalar ops, but worth a comment if it ever shows up in a hot loop.
Rebase and I'll re-run.
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 481afd9 on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 71 passed. cargo clippy -p victory-shader --all-targets is clean. victory translate --validate --pipelines on the local title executable still reports 12 of 12 emitted, validated and built into pipelines.
- Semantics match the GFX10 ISA for the SOP1 forms,
SGPR[D] = SGPR[S0.addr + M0]andSGPR[D.addr + M0] = S0, with the full M0 as the offset (unlike the VOP1_2forms in #627). - A constant M0 picks one register directly, and a non-constant M0 becomes a select chain or scatter over the reachable SGPRs.
ir.rslists the same read and write sets, so liveness agrees with the lowering. - An out-of-range index reads 0 and writes nothing here. That's a safe choice, but it doesn't model the hardware, which can reach VCC and the other registers above s105. A
shortcut:comment would make that explicit.
AI-assisted (Claude Code).
…rels_b32 and s_movreld_b32 lowering Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catminou4
left a comment
There was a problem hiding this comment.
The s_movrels_b32 / s_movreld_b32 lowering itself reads correctly (M0 bounds-checked against the SGPR window, static-M0 fast path, dynamic select chain, destination read-modify-write preserved for s_movreld_b32), and Module::as_i32 is a clean helper for it. Two blockers before this can land:
1. Semantic conflict with main — does not compile after merge. Main's test helper is now fn lowers(words: &[u32], rsrc2: u32) (the compute rsrc2/threads field), and this PR's five new calls still use the old one-argument form:
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> crates/victory-shader/src/emit/lower.rs:7443:9 (and 7455, 7466, 7478, 7490)
Verified fix: pass 0 as rsrc2 (these tests don't exercise threads) — lowers(&static_rels, 0).unwrap(); etc. With that one-token change on the merge with current main (ffe310e), cargo test -p victory-shader --locked (macOS arm64, rustc 1.98.1) → 96 passed / 0 failed / 1 ignored.
2. Two existing tests are deleted with no replacement. The diff removes packed_buffer_formats_by_number and small_floats_widen_as_halves (plus the half helper) from lower.rs's test module — coverage of the packed buffer-format table and half-float widening — and they don't reappear in any other file of this PR. Unless that coverage moved somewhere I can't see, please restore them; the s_movrel_lowering addition is no reason to drop unrelated tests.
Windows note: the M0-relative behavior on hardware is valu_tests-gated like the rest, so the Windows lane should confirm once this compiles.
|
Merged onto Checked with CI's steps (both clippy runs with |
|
Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
GPU: name why an indirect execution was dropped, and what its records hold
Summary
Implements IR lowering and DXIL emission support for GFX10 scalar relative-indexing move instructions (
s_movrels_b32ands_movreld_b32) invictory-shader, replacing the previousShaderError::Unsupportedpath.Changes
crates/victory-shader/src/ir.rs):s_movrels_b32(sdst = sgpr[src_base + m0]) for relative scalar source reads indexed byM0.s_movreld_b32(sgpr[dst_base + m0] = ssrc) for relative scalar destination writes indexed byM0.M0offsets cannot produce out-of-bounds SGPR accesses or invalid DXIL IR.M0offsets for boths_movrels_b32ands_movreld_b32, verifying round-trip register updates and DXIL emission/validation.Verification
cargo fmt --checkcargo clippy -p victory-shader --all-targetscargo test -p victory-shader