Repository navigation
startup: lower v_cvt_off_f32_i4 in gfx2hlsl - #2452
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8bd6cb227
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Five mutations: four caught, and the survivor is the one that should survive hereBaseline:
I flagged the identical mask on #2450 an hour ago as a gap, so I want to be explicit that it is not one here. That difference is worth one line in the comment, by the way: What the fixture pins that I did not expect
One documentation nit worth fixing before mergeThe doc says the result is "signed two's-complement bits AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974. |
|
Updated in
Re-ran |
e8bd6cb to
f208204
Compare
|
Hardware run and Windows 11 MSVC build at head Environment: Windows 11 Pro build 26300.9974, Debug ( Build: Tests:
The hardware test prints The PR body lists as not established: "Physical GPU Not covered by this run: AMD hardware; only this fixture was run, and only the draw (pixel shader) path of the translated shader. |
797a9e9 to
ce62597
Compare
|
Thanks — that closes the One thing did change after your run: Re-ran after the rebase: Nothing else in the PR changed, and the description now matches |
MasterDomino
left a comment
There was a problem hiding this comment.
Review of head ce625973. I found no P1 or P2 issues. It needs a rebase, and there's one question about DPP; I'll merge once those are settled and CI is green.
What I checked
-
Semantics against RDNA 2
V_CVT_OFF_F32_I4:float(int(x << 28) >> 28) * 0.0625readsS0[3:0]as a signed nibble (−8 to +7) and gives −0.5 to 0.4375 in steps of 1/16, the same formulapixel_aotuses.- Every result is exact in binary32, with no NaN, denormal or −0, so FXC/DXC without
/Gis/-Giscan't change it. clampwith omod emitssaturate((…) * 2.0), which scales before clamping, the hardware order.
-
Inline float constants lower as their bit patterns, matching LLVM's i32 source type:
1.0becomes0x3f800000u(nibble 0), and0.15915494becomes0x3e22f983u(nibble 3). -
Refusals:
- e64 ABS and NEG are refused on the raw word.
- SDWA, op_sel and the wrong arity are refused.
- DPP16 with a source neg or abs doesn't decode.
- DPP8 and quad swaps are refused.
-
Uniformity: the
low16_onlyandUNIFORM_VALUmemberships are sound, because the op reads only bits [3:0] of its own lane. -
Cache revision:
x2w-startup-shader-14and14csare unchanged. I replayed the 844 distinctPipeline/ComputePipelineinputs built by 71 passing gfx2hlsl checks through the merge base and this head:- previously accepted shaders whose text changed: 0 of 330;
- accepted shaders now refused: none;
- previously refused shaders now accepted: 6, all
v_cvt_off_f32_i4.
So no bump is needed.
Commands executed (Windows 11 build 26300; AMD Radeon RX 9070 XT 1002:7550, driver 32.0.32029.2010, debug layer enabled; WARP 10.0.26100.9818; DXC/FXC from SDK 10.0.26100; LLVM 15.0.7)
python -B tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py
ctest --preset dev --no-tests=error -j1 -R '^startup_gfx2hlsl_cvt_off_f32_i4_(controls|warp|hardware)$' -V
python -B tests/startup_gfx2hlsl_{handler_arity,operand_count,bit_alu}_check.py| Test | Result |
|---|---|
…_controls |
pass |
…_warp |
pass: 14 draws matched, the 6 mutated draws read their mutated words, debug_errors=0 |
…_hardware (RX 9070 XT) |
pass: the same, with 0 debug errors or warnings |
| neighbouring checks | pass |
There were no capability skips. This is the AMD hardware run @triggered02 left as a limit, measured at the rebased head ce625973; @Makto94's RTX 3070 Ti run was on f2082044.
Negative control
Each mutation is one line of tools/startup/gfx2hlsl.py, applied alone and reverted. The draws ran on WARP and the RX 9070 XT, and the expected words are bf000000,bf000000,3ee00000,bd800000:
| Mutation | Controls | Draw actual |
|---|---|---|
| nibble read as unsigned | 820 … evaluations match RDNA2 ISA: MISMATCH |
3f000000,3f000000,3ee00000,3f700000 |
offset-binary (x & 15) − 8 |
TypeError in the CPU evaluator |
00000000,00000000,bd800000,3ee00000 |
| scale 1/32 | MISMATCH | be800000,be800000,3e600000,bd000000 |
| sign flipped | MISMATCH | 3f000000,3f000000,bee00000,3d800000 |
| SDWA refusal removed | refused: SDWA BYTE_1: MISMATCH |
(the draw has no SDWA rows) |
| e64 ABS/NEG guard removed | refused: e64 neg on inline 3: MISMATCH |
(the draw has no modifier rows) |
All were caught. With the offset-binary mutant, the CPU evaluator raises a TypeError rather than printing a mismatch line. It still fails, but a mismatch line would be clearer.
To resolve before merge
- Rebase:
docs/experiments.mdconflicts with currentmain(an append at the end; keep both). #2450 adds acheck_encodingblock at the same spot ingfx2hlsl.py; keeping both works, and both checks pass onmain+ #2452 + #2450. - Question, DPP16 quad broadcast: in a straight-line pixel stage,
v_cvt_off_f32_i4_dpp v0, v1 quad_perm:[k,k,k,k] row_mask:0xf bank_mask:0xfis now accepted through the genericdpp_broadcastpath, which admits anyVEC_U_TO_Fop. It lowers toQuadReadLaneAt(v1, …)followed by the conversion. The merge base refused it asDPP form of v_cvt_off_f32_i4. The lowering looks correct, but the description and docs only mention SDWA, and nothing tests it. Is this intended? If so, please add one broadcast row; otherwise refuse DPP the way SDWA is refused. - Nit: the "Measured checks" heading in the description still names
e8bd6cb2one06aca8b; the head isce625973.
AI-assisted; commands listed were executed locally.
ce62597 to
1f6cb0c
Compare
|
Rebased onto current main (�fba03c9) as @thevoid asked. Head is now 1f6cb0c (was ce62597); the single commit replayed, and the only conflict was the docs/experiments.md append-tail (main's newest section kept, this PR's record re-appended). No conflict markers. Verified on 1f6cb0c: ests/startup_gfx2hlsl_cvt_off_f32_i4_check.py exit 0; check file blob-identical to the pre-rebase head; CMakePresets.json parses and startup_gfx2hlsl_cvt_off_f32_i4_controls still matches the pr include regex; docs_links_check.py 19 files/472 links; git diff --check clean. Diff vs main is the PR's 7 files (+773/-4). PR is MERGEABLE and CI is running. |
|
Thanks for the rebase, @triggered02. Two things remain before I can merge this:
The stale "Measured checks ( AI-assisted. |
The generic Stage.dpp_broadcast path is op-agnostic: it proves whole-quad activity, reads the lane quad_perm names with QuadReadLaneAt, and then lowers the base operation on that value. v_cvt_off_f32_i4 is now in VEC_U_TO_F, so it takes that path like any other unary VOP1; the merge base refused every form of the op, which is why the DPP form was refused there too. Pin the acceptance (lane 2 and lane 3, the shader-model bump, and the nibble sign-extend on the broadcast value) plus the refusals that keep it sound: a non-broadcast and a mixed quad_perm, a partial row_mask, bound_ctrl:0, an entry mask that is not proven whole-quad, and a vertex stage. Refs R0Y00#2452
1f6cb0c to
2be3ae9
Compare
|
Both items done, head is 1. DPP16 quad broadcast — intended, and now pinned.
All 11 rows pass, and the whole check is 2. Rebased onto Verification on 3. Stale heading fixed: the description now reads |
The generic Stage.dpp_broadcast path is op-agnostic: it proves whole-quad activity, reads the lane quad_perm names with QuadReadLaneAt, and then lowers the base operation on that value. v_cvt_off_f32_i4 is now in VEC_U_TO_F, so it takes that path like any other unary VOP1; the merge base refused every form of the op, which is why the DPP form was refused there too. Pin the acceptance (lane 2 and lane 3, the shader-model bump, and the nibble sign-extend on the broadcast value) plus the refusals that keep it sound: a non-broadcast and a mixed quad_perm, a partial row_mask, bound_ctrl:0, an entry mask that is not proven whole-quad, and a vertex stage. Refs R0Y00#2452
2be3ae9 to
f6b8657
Compare
MasterDomino
left a comment
There was a problem hiding this comment.
Approved at head f6b86579, which is @triggered02's rebase onto main after #2450 with the DPP pin. Thanks for answering the open points.
What changed since my review of ce625973
- DPP16 quad broadcast: confirmed intended.
check_dpp_broadcast()now pins it: acceptance,QuadReadLaneAt, the conversion on the broadcast value, the lanequad_permnames, and refusal of mixed and non-broadcastquad_perm, a partialrow_mask, an unproven whole-quad entry mask and the vertex stage. - Both
check_encodingblocks kept: thev_sad_*guard from #2450, then thev_cvt_off_f32_i4guard. - The description heading now names the current head.
Re-verification at f6b86579 (Windows 11 build 26300; AMD Radeon RX 9070 XT 1002:7550, driver 32.0.32029.2010, debug layer enabled; WARP 10.0.26100.9818; DXC/FXC from SDK 10.0.26100)
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_(cvt_off_f32_i4_(controls|warp|hardware)|sad_(controls|warp|hardware))$' -V- 6/6 pass: this PR's controls and draws, and #2450's
v_sad_*controls and draws on the same tree, so both encoding guards work together. - The DPP rows: all seven
dpp_broadcast …: oklines print. - Merge: the head merges cleanly with current
main.
Negative control (new for the DPP pin)
I hard-coded the broadcast lane in dpp_broadcast (lanes.group(1) replaced with '2'). The check fails: dpp_broadcast reads the lane quad_perm names, not a fixed one: MISMATCH. After reverting, it passes. The semantic mutants from my earlier review (unsigned nibble, offset-binary, 1/32 scale, sign flip, SDWA and e64 guards) are against the unchanged lowering.
No cache bump is needed: this only accepts forms that were refused before, as established in my earlier review. That's independent of the 15/15cs revision #2467 just landed.
Merge checks: required CI passed at this head. The /O2 and coverage skips come from explicit workflow conditions. There are no unresolved review threads. I read the whole thread in full.
AI-assisted; commands listed were executed locally.
Lowers gfx1013
v_cvt_off_f32_i4(VOP10x0eand VOP3A_e640x18e) intools/startup/gfx2hlsl.py.### What changed-tools/startup/gfx2hlsl.py: -VEC_U_TO_F: added'v_cvt_off_f32_i4': (1, '(float(int({0} << 28) >> 28) * 0.0625)')(bits[3:0]as signed 4-bit two's complement[-8, +7]scaled by1/16to[-0.5, +0.4375]). -Stage.lower: added'v_cvt_off_f32_i4'to thelow16_only=Truetuple. -UNIFORM_VALU: added'v_cvt_off_f32_i4'. -Stage.sdwa&check_encoding: keep SDWA forms and VOP3AABS/NEGsource modifier bits refused.-tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py,CMakeLists.txt, anddocs/experiments.md.### Measured checks (2be3ae93onorigin/main82bb67ef)-tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py(pure Python): PASS — 12 decode vectors, 820 nibble/garbage/modifier evaluations (all 16 nibbles0..15, upper-bit garbage0x12345678/0xfffffff8,clamp/mul:2/mul:4/div:2), 7 constant-source checks, 5low16_onlychecks, 5UNIFORM_VALUchecks, 11 encoded-byte refusals + 4 arity refusals, and 2 unlowered controls.-tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py draw <dxc> <offscreen_check> warp <fxc>(Microsoft Basic Render Driver1414:008c,10.0.26100.9818): PASS — 14/14 draws matched (FXCps_5_1+ DXCps_6_0), and 6/6 mutated draws read their expected mutated words.- 66/66 parallel checks (63startup_gfx2hlsl_*,startup_translator_check.py,docs_links_check.py,bidi_controls_check.py) andgit diff --check: PASS.- 6 fail-first mutations ontools/startup/gfx2hlsl.py: all 6 caught (exit 1).### Not established- AMD hardware was not exercised. The physical-GPUhardwaredraw has since been measured by @Makto94 on an NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.2101), Windows 11 build 26300.9974, MSVC 19.44.35230,devpreset, serial-j1runs:startup_gfx2hlsl_cvt_off_f32_i4_hardwarepassed withdebug_errors=0 debug_warnings=0, 0 capability skips, and the hardware log reads14 draws matched, 6 mutated draws read their mutated words, so the mutated draws fail as intended (report: #2452 (comment) (Gemini).DPP16 quad broadcast
eeds_sm6. This is intended � the merge base refused every form of the op because the op itself was unsupported. ests/startup_gfx2hlsl_cvt_off_f32_i4_check.py now pins it: lane 2 and lane 3 broadcasts, the shader-model bump, the nibble sign-extend on the broadcast value, and refusals for a non-broadcast and mixed quad_perm, a partial
ow_mask, �ound_ctrl:0, an entry mask not proven whole-quad, and a vertex stage.
AI-assisted.