Repository navigation
feat(shader): allow directed rounding modes for packed f16 multiply - #16889
adriadam10 merged 2 commits into
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
gabichuuuuu
left a comment
There was a problem hiding this comment.
The Intel and Turing cells. Head 06c15ccb9e (stacked on #16739's two commits) merged onto main 302864d48c (clean). Windows 11 x64, WinLibs GCC 15.2.0 r7, Release, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_packed_(add|mul)_f16_rounding', 3 runs per GPU.
| GPU | result |
|---|---|
| NVIDIA laptop GPU (Turing), driver 610 | 34 of 34 pass (17 mul, 17 add), 3 of 3 runs |
| Intel iGPU, same machine | 34 of 34 pass, 3 of 3 runs |
So the new multiply rows, every rounding mode in wave32 and wave64, integer and float, give the expected bits on both drivers, and #16739's add rows still pass with this on top. Not run with VK_LAYER_KHRONOS_validation.
AI-assisted: yes.
|
Thanks for the Turing and Intel runs. The 17th test per op is the default no-argument registration every tests/execution source gets ( |
|
Independent Windows/AMD GPU result for exact head @gabichuuuuu already supplied Turing and Intel Windows results on this head; this adds RDNA3 Windows coverage. I did not run a title, compare against |
|
A check of the semantics on RDNA2 hardware, independent of the recompiler. The four Modes: FLOAT_MODE was set the way the test sets it, through the oracle's flags: Reference: each result was compared with the test's own expected value. Result: 8,192 of 8,192 packed results equal the expected values. That includes:
So the reference the test pins matches the hardware instruction on gfx1036. gfx1013 itself is not measured. AI-assisted: yes. |
06c15cc to
f58d6d9
Compare
|
Thanks for the gfx1036 run. It is now recorded in docs/dev/debt/shader.md in f58d6d9, the same way #16739 records packed add, with gfx1013 still listed as unmeasured. The branch is also rebased onto #16739's new head f719df5; that base change touches only shader.md, so the code and test are unchanged. |
f58d6d9 to
236b0fb
Compare
Round exact half products once through the interpolation arithmetic, following RDNA2 ISA section 12.10 and LLVM 19.1.0 VOP3PInstructions.td. Cover rounding, tininess, lane selections, modifiers and native fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tiply The four v_pk_mul_f16 encodings of PackedMulF16Rounding.cpp match the test's reference on gfx1036 in every f16 round, f16 denormal, IEEE, DX10_CLAMP and FP16_OVFL mode, as measured with tools/hw-oracle on the pull request. gfx1013 remains unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
236b0fb to
b5cf88e
Compare
|
Rebased onto main now that #16739 has merged, so the branch is only this PR's two commits on 527b309 and Depends on is none. The 34 packed add and multiply rounding tests pass on lavapipe with the Khronos validation layer and no VUID errors, and the 12 directed multiply variants still fail with main's FloatInstructions.cpp. |
|
An RDNA 3.5 data point for the semantics this PR implements for Setup:
Rows: 576 per mode and form, two results each.
Forms:
Reference. Written separately in Python with exact fractions, not copied from the PR's test:
Results:
The rows reach the interesting cases. In one mode (
So gfx1151 agrees with the semantics in the description in every mode and form measured: a single rounding per half in the mode's direction, tininess decided after rounding with an unbounded exponent when f16 results are flushed, Not covered:
Not run: the recompiler side (no Windows build of the runner here), and the PR's tests. AI-assisted: yes (measurement scripted with Claude Code; rows and results checked by me). |
|
Checked the directed-multiply lowering in |
What
v_pk_mul_f16threwpacked f16 at pc … in FLOAT_MODE … (f16 rounding not to nearest even) is not implementedwhenever the shader'sFLOAT_MODEselected a directed f16 rounding (toward +∞, −∞ or zero). My #16739 lifted that guard forv_pk_add_f16; this PR does the same for packed multiply, with the same design, and builds on #16739.Sources:
V_PK_MUL_F16);VOP3PInstructions.tdlines 95–99, whereFPDPRounding = 1, so the instruction uses the mode's rounding;How it works:
v_interp_p2_f16interpolation arithmetic feat(shader): allow directed rounding modes for packed f16 add #16739 uses (FPInterpolateF16with a factor of 1 and a zero addend of the product's sign).neg_lo/neg_hi, clamp,FP16_OVFLand the NaN rules are unchanged.Debt:
shader.mdnow listsv_pk_mul_f16withv_pk_add_f16andv_pk_min/max_f16as the packed ops that accept directed rounding. It records that its four encodings match RDNA2 (gfx1036) in every mode on the test's rows, and that gfx1013 is not measured, the same way #16739 records packed add. Only those two entries changed.Tested
New test:
agc_driver_packed_mul_f16_rounding_*, 16 variants: wave32 and wave64 × rounding 0–3 × native and forced integer paths. Each variant compares 4,096 words against an independent integer significand-and-exponent reference. They cover:op_sel/op_sel_hilane selections, negation and clamp;The key case:
0x3c01 × 0x3c01gives0x3c02to nearest even and0x3c03toward +∞.Linux x86-64 (Ubuntu 26.04, GCC 15, Release, lavapipe / Mesa 26.0.8, with
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation):VUID-lines and no missing-layer warning in either run.Windows 11, RTX 3060: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release, NVIDIA driver 610.88, Vulkan SDK 1.4.363, same validation environment, with the Khronos validation layer confirmed loaded):
VUID-lines and no missing-layer warning in either run;After rebasing onto
main527b309dd9(feat(shader): allow directed rounding modes for packed f16 add #16739 merged): on lavapipe (llvmpipe, LLVM 21.1.8) with the same validation environment, all 34 packed add and multiply tests pass with noVUID-lines and no missing-layer warning; withmain'sFloatInstructions.cppthe 12 directed multiply variants fail with the throw again.RDNA2 hardware reference (run by Nawid3333 on this PR with
tools/hw-oracle, gfx1036, AMD Windows driver 32.0.21045.16010, HIP, wave32): the test's fourv_pk_mul_f16encodings in all 128 combinations of f16 round, f16 denormal, IEEE, DX10_CLAMP and FP16_OVFL give 8,192 of 8,192 results equal to the test's expected values.Other results posted on this PR: the 34 tests pass on an NVIDIA Turing laptop GPU and an Intel iGPU (gabichuuuuu) and on an AMD RX 7800 XT (DonRyuzaki). An RDNA 3.5 measurement on gfx1151 with
tools/hw-oracleand an independent exact-fraction reference matches in all 73,728 lane results of each of the four forms, in every f16 round, f16 denormal, IEEE and FP16_OVFL mode (Jirka135).Mutation check: forcing nearest-even in the directed multiply fails with
actual=bc023c02 expected=bc023c03.python3 tools/check_conventions.py --base origin/main: no errors. The two warnings are about thev_fma_mixlo_f16and packed-NaN entries, which were already over 1,000 characters onmain; this PR only addsv_pk_mul_f16to one clause in each.python3 tools/pr_overlap.py: no other PR implements directed packed multiply.mainafter it.FloatInstructions.cpp, as it already does with feat(shader): allow directed rounding modes for packed f16 add #16739. Whoever merges second keeps both conditions in the native-path test (!directedAdd && !directedMul).shader.mdclauses or distant code. docs(debt): separate entries with blank lines and drop derived export totals #14212 only reformats debt entries.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)main)🤖 Generated with Claude Code