You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(semantic): value tests for v_floor/ceil/trunc/fract/rndne_f16 - #689
Claimed in #374 as: a new TEST item, semantic value tests for 16-bit float rounding/fraction VALU ops (claim)
What and why
v_floor_f16, v_ceil_f16, v_trunc_f16, v_rndne_f16, and v_fract_f16 had no semantic value tests in tests/semantic/. This adds a standalone test suite tests/semantic/test_valu_f16_round.py comparing tools/rdna2spirv.py + tests/semantic/spirv_mini_interp.py against an independent IEEE-754 binary16 Python reference without modifying the translator or interpreter:
v_floor_f16, v_ceil_f16, v_trunc_f16, v_rndne_f16 (end-to-end execution in spirv_mini_interp.py):
Finite values, exact integers, .5 ties including binary16 large-integer ties (1022.5 -> 1022.0, 1023.5 -> 1024.0), signed zero (-0.0) preservation in (-1.0, -0.0], subnormals, +-inf, and NaNs across _e32, _e64, and bare mnemonics.
Untouched 16-bit half preservation and all op_sel:[src,dst] combinations ([0,0], [1,0], [0,1], [1,1]).
VOP3 source modifiers (neg, abs, -|...|) and output modifiers (mul:2, mul:4, div:2, clamp) applied before narrowing to f16.
Inline f16 constants (0.5, -0.5, -1.0), SGPR sources with op_sel, destination aliasing, EXEC masking, and a SPIR-V sabotage negative control (Floor -> Ceil).
v_fract_f16 (oracle + SPIR-V structural check):
tools/rdna2spirv.py lowers v_fract_f16 to GLSL.std.450 Fract, which tests/semantic/spirv_mini_interp.py does not yet implement (UnsupportedConstruct: GLSL.std.450 Fract). Tested via an independent IEEE-754 binary16 oracle and structural SPIR-V verification (UnpackHalf2x16, GLSL.std.450 Fract, FClamp).
No existing files were modified.
Tested
CPU only, no game data, on Windows 11 with Python 3.12.10 (llvm-mc, spirv-as, and spirv-val are not installed in this environment; semantic checks ran in spirv_mini_interp.py):
Tested 149870e on Windows 11 / Python 3.12.14: all 10 tests in python -I tests/semantic/test_valu_f16_round.py passed against the base translator, including the deliberately altered SPIR-V control. This exercises the CPU path for source/output modifiers, op_sel, and preservation of the other half. AI-assisted, synthetic inputs.
Code read: the references look right. round() is round-half-to-even, as v_rndne needs. ref_fract gives 0.75 for −0.25 and +0.0 for −0.0. Non-finite values pass through floor/ceil/trunc/rndne unchanged. Since spirv_mini_interp has no GLSL.std.450 Fract, using the oracle plus a structural check for v_fract_f16 is reasonable. Adding Fract to the interpreter would be a natural follow-up.
For the v_fract_f16 gap: #494 (SHADER-45) adds GLSL.std.450 Fract to spirv_mini_interp.py (exact, rounded once to binary32). Once it lands, v_fract_f16 could run end to end here too. A small follow-up after both merge. (AI-assisted.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in #374 as: a new TEST item, semantic value tests for 16-bit float rounding/fraction VALU ops (claim)
What and why
v_floor_f16,v_ceil_f16,v_trunc_f16,v_rndne_f16, andv_fract_f16had no semantic value tests intests/semantic/. This adds a standalone test suitetests/semantic/test_valu_f16_round.pycomparingtools/rdna2spirv.py+tests/semantic/spirv_mini_interp.pyagainst an independent IEEE-754 binary16 Python reference without modifying the translator or interpreter:v_floor_f16,v_ceil_f16,v_trunc_f16,v_rndne_f16(end-to-end execution inspirv_mini_interp.py):.5ties including binary16 large-integer ties (1022.5->1022.0,1023.5->1024.0), signed zero (-0.0) preservation in(-1.0, -0.0], subnormals,+-inf, and NaNs across_e32,_e64, and bare mnemonics.op_sel:[src,dst]combinations ([0,0],[1,0],[0,1],[1,1]).neg,abs,-|...|) and output modifiers (mul:2,mul:4,div:2,clamp) applied before narrowing to f16.0.5,-0.5,-1.0), SGPR sources withop_sel, destination aliasing,EXECmasking, and a SPIR-V sabotage negative control (Floor->Ceil).v_fract_f16(oracle + SPIR-V structural check):tools/rdna2spirv.pylowersv_fract_f16toGLSL.std.450 Fract, whichtests/semantic/spirv_mini_interp.pydoes not yet implement (UnsupportedConstruct: GLSL.std.450 Fract). Tested via an independent IEEE-754 binary16 oracle and structural SPIR-V verification (UnpackHalf2x16,GLSL.std.450 Fract,FClamp).No existing files were modified.
Tested
CPU only, no game data, on Windows 11 with Python 3.12.10 (
llvm-mc,spirv-as, andspirv-valare not installed in this environment; semantic checks ran inspirv_mini_interp.py):python -m compileall -q make_game.py tools tests— passedpython -I tests/semantic/test_valu_f16_round.py -v—Ran 10 tests in 2.670s,OKpython -m unittest discover -s tests/semantic -v—Ran 815 tests in 203.802s,OKAI-assisted, as
AGENTS.mdasks contributors to say.Checklist
docs/design.md, with how it was confirmed. (Not applicable: tests only; no translator change.)