Repository navigation
Conversation
The VEC_F table lowers v_floor_f32, v_ceil_f32, v_trunc_f32, v_fract_f32 and v_rndne_f32 to HLSL floor, ceil, trunc, frac and round, and no check ran any of them. tests/startup_gfx2hlsl_float_round_check.py draws them with the shared per-lane runner (byte-identical copy of tests/startup_gfx2hlsl_lane_alu.py) against references written from the RDNA 2 ISA: signed zero results, round half to even, and fract capped at 0x3f7fffff, on exact halves and quarters, 1000000.5, the binary32 just below 0.5, 8388607.5 and -2^-30. Each operation has a mutated lowering whose first draw must read its own words. All 20 draws match on WARP and an RX 6600 through FXC ps_5_1 and DXC ps_6_0, the 10 mutated draws read their mutated words, and frac(-2^-30) reads 0x3f7fffff on both adapters.
tedin7
left a comment
There was a problem hiding this comment.
Review of head 8ff3dddf38854a2b59e036c89274442f38c7925f. Tests, CMake, CI list and docs only; tools/startup/gfx2hlsl.py is unchanged. Verdict: 0 P1, 1 P2 (design note, not blocking), plus coverage nits.
Linux limits. Linux x86_64, llvm-mc-19 (the new CI entry pins llvm-mc-15), Python 3.14. No Windows, no DXC/FXC, no WARP or GPU: I could NOT run the draw mode, so the WARP/RX 6600 results in the docs (20 draws, 10 mutated draws, frac(-2^-30) = 0x3f7fffff) are not verified by me. Nothing was run through HLSL; the lowerings are only read as text.
What I ran (worktree at that head)
python3 -B tests/startup_gfx2hlsl_float_round_check.py(controls): passes.... binary llvm-mc-19:fixture words match llvm-mc.git diff --check origin/main...HEAD,docs_links_check.py,bidi_controls_check.py: clean. The diff has one non-ASCII line (the->arrows in the docs).- References, read against the ISA wording: zero results keep the source sign (
ceil(-0.75),trunc(-0.75),rndne(-2^-30)give -0),v_rndne_f32is half-to-even (Pythonroundon the double is also half-to-even; 2.5 -> 2, 3.5 -> 4, -2.5 -> -2, 1000000.5 -> 1000000),v_fract_f32is x - floor(x) capped at0x3f7fffff.0xb0800000is -2^-30 and0x3effffffis the binary32 below 0.5. TheVEC_Ftext is plainfloor/ceil/trunc/frac/round. - Mutations (restored with
git checkout -- .):- production
v_fract_f32frac->trunc: controls FAILED (AssertionError: ('v_fract_f32', 0)); this happens because the control's mutation regex no longer matches the changed text. - test body word of
v_ceil_f32opcode 0x45 -> 0x44: FAILED inbinary(assembled words differ). - production
floor({0})->floor({0} + 0.0000001): controls andbinaryPASSED, not caught on Linux. - production
round({0})->round(-{0}): controls andbinaryPASSED, not caught on Linux. - test reference of
v_rndne_f32changed to ties-up: controls andbinaryPASSED (only the draw reads it).
So a wrong value that keeps the shape of the text is caught only by the draws on a Windows adapter; please make sure they ran for this head.
- production
P2 (design note). The cap of v_fract_f32 at 0x3f7fffff is part of the reference, but the translator emits a bare frac(x); the docs say both adapters returned 0x3f7fffff "without an explicit comparison". For -2^-30 the exact difference rounds to 1.0, so on an adapter or compiler path that computes frac as x - floor(x) in binary32 the result would be 0x3f800000. The new test will then fail on that adapter rather than the lowering being fixed; a min(..., 0x3f7fffff) in the lowering, or a note that the cap is adapter-dependent, would settle it.
Coverage nits
- No NaN, infinity or -0.0 source in any set:
floor(NaN),rndne(-0.0),ceil(-0.0),trunc(+/-inf)are unchecked, although the task of the check is the sign-of-zero rule. binary32values at and above 2^23 (no fractional bits) appear only as 8388607.5 and 1000000.5.
Not approving (comment only).
AI-assisted; commands listed were executed locally.
|
A heads-up for In LooperSalty/AnyXboxX#160, HLSL It did not reproduce on an RTX 4060 Laptop (Ada), driver 32.0.16.1047: LooperSalty/AnyXboxX#160 (comment). So it is either Blackwell-specific or new in recent drivers. What this means here:
AI-assisted (Claude Code). The measurements are from the linked AnyXboxX threads, not from runs of this PR. |
Draw mode on Windows, and one thing to fix in the CMake blocktedin7's review says it could not run the draw mode, so the independent confirmation was missing. It is here now — with one caveat about the test registration, below. 2026-11-24, head Result, with the FXC path passed explicitly: Same counts as the table in the PR body, on a different architecture:
|
|
Independent run of ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_float_round_' -j1 -VEnvironment: driver 32.0.16.2101 (621.01); Windows 11 Pro 10.0.26300.9974; DXC 1.9.2602.17; Hardware, second WARP, same draw, same build:
The test stops at that draw. A local wrapper that records a failed draw and continues (not the PR command) shows the other 9 unmutated hardware draws matching and the 5 mutated draws reading their mutated words, including: Not covered by this run: the FXC path (the registered command passes |
|
Hardware run of head 8ff3ddd. Windows 11 Pro 26100.9168, DXC/FXC from Windows SDK 10.0.26100,
The floor, ceil and trunc rows pass on the Quadro too. The failing draw: Lane 2 is
This looks like a real difference in the lowering, not in the fixture. No changes made. |
|
@Asimmimx the two NVIDIA results in this thread come from the lowering, not from your draw: I have opened #2010, which puts that capped helper in the gfx2hlsl preamble, points the table entry at it, and adds a check that pins the emitted text. It targets Two things worth knowing. There is no NVIDIA adapter on my machine — RX 9070 XT and WARP only — so I cannot confirm that the Maxwell and Turing rows turn green; the reasoning above comes from your two reports and from the rule this repository had already written, not from a measurement. And your branch does not carry the AI-assisted. |
|
@Asimmimx one change your branch will need when it lands, so that it does not break quietly.
The rest is good news for your draw. The form that survives FXC is to compare the encoding rather than Your branch also predates #1728, so a rebase conflicts in the preamble where AI-assisted. |
|
@Asimmimx could you rebase this branch onto current GitHub reports head Files that conflict with current
Commands run locally: Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally. |
Refs #1149.
Change
No check ran the rounding operations of the
VEC_Ftable intools/startup/gfx2hlsl.py:v_floor_f32,v_ceil_f32,v_trunc_f32,v_fract_f32andv_rndne_f32. They lower to HLSLfloor,ceil,trunc,fracandround.This PR adds a check only. The translator does not change.
tests/startup_gfx2hlsl_float_round_check.pydraws them with the per-lane runnertests/startup_gfx2hlsl_lane_alu.py. The runner is byte-identical to the copies in #1703, #1706, #1708 and #1712. In each draw:_e32and_e64;binarymode.The references follow the AMD RDNA 2 ISA reference:
ceil(-0.75),trunc(-0.75)andrndne(-2^-30)give -0 (0x80000000).v_rndne_f32rounds halves to even. 2.5 → 2, 3.5 → 4, -2.5 → -2, 1000000.5 → 1000000, 8388607.5 → 8388608.v_fract_f32isx - floor(x), capped at the largest binary32 below 1.0. For -2^-30 the exact difference rounds to 1.0, and the instruction gives0x3f7fffff. The compute translator lowers fract with an explicit cap because HLSLfraccan return 1.0 there on some adapters; see thev_fract_f32note indocs/experiments.md.The inputs also include the binary32 just below 0.5 (
0x3effffff).Each operation has one mutated lowering, and the first draw with it must read the mutation's own reference words:
x - trunc(x)for frac;Results
Commit
8ff3dddfonorigin/main. Windows 11 26300.9974, DXC 1.8.2502.11, FXC 10.0.26100, debug layer on.There were no skips.
binarywith llvm-mc 19.1.1 givesfixture words match llvm-mc.frac(-2^-30). On both adapters, through both compilers, the plain HLSLfracread0x3f7fffff. The gfx2hlsl lowering, which has no explicit cap, therefore matches the ISA on these two adapters. An adapter whosefracreturns 1.0 there would fail this draw. That is intended: the check would then show that gfx2hlsl needs the same cap ascompute_store_aot.AI-assisted (Claude Code).