Repository navigation
shader: lower quad-local DPP16 and DPP8 binary16 fmac, ldexp and int16 conversions in pixel_aot - #2485
Conversation
…6 conversions in pixel_aot Lower the quad-local DPP16 and DPP8 spellings of the six remaining contracted binary16 opcodes (12 forms total across gfx1013 and rdna2): - VOP2 fused/scale: v_fmac_f16_dpp, v_ldexp_f16_dpp - VOP1 int16 <-> f16: v_cvt_f16_i16_dpp, v_cvt_f16_u16_dpp, v_cvt_i16_f16_dpp, v_cvt_u16_f16_dpp Add int16_dpp_source() alongside half16_dpp_source() to enforce the existing R0Y00#839 contracts: - src0 is quad-swizzled via emit_quad_swizzle_u32 while src1 and the v_fmac_f16_dpp accumulator stay on the current lane. - DPP16 allows bit-15 abs/neg modifiers on float sources only (src0/src1 on v_fmac_f16_dpp, src0 on v_ldexp_f16_dpp and v_cvt_{i16,u16}_f16_dpp); DPP8 and integer operands refuse modifiers. - v_fmac_f16_dpp uses fma16_rne for single-rounding fused multiply-add, v_ldexp_f16_dpp requires a proven signed 16-bit exponent in [-64, 64], v_cvt_f16_i16_dpp accepts runtime i16/low16 sources while v_cvt_f16_u16_dpp requires a static proof < 65520, and v_cvt_{i16,u16}_f16_dpp truncates proven in-range binary16 values into ("low16", alu). - Explicit half_denorm="preserve" and HW_REG_MODE RNE remain required. Extend pixel_aot_dpp_f16_{warp,hardware} with four 4-channel programs (fmac_ldexp_dpp16, fmac_ldexp_dpp8, cvt_int16_dpp16, cvt_int16_dpp8) in both default and -denorm ftz modes plus 13 numerically distinct mutations and a per-lane runtime quad-routing witness (DPP_F16_CVT_I16_LANES), add all five to check_binary, update check_dpp_f16_contract_controls and docs/experiments.md, and add check_dpp_f16_cvt_fmac_ldexp_forms in tests/form_coverage_check.py.
The modifier matrix the comment describes is exactly what the code does — I probed it instruction by instruction
That is the whole rule as stated in the comment — "DPP16 allows bit-15 abs/neg modifiers on float sources (src0 and src1 for fmac, src0 only for ldexp); DPP8 and integer src1 refuse modifiers" — and every clause of it holds on the real code path, including the asymmetric one (fmac takes modifiers on both, ldexp only on src0) that is the easiest to get wrong and the hardest to notice. The two "accepted" rows that end in a different error ( What the fixture itself asserts beyond that
One suggestionThe Docs
AI-assisted; all eight probes were run locally on Windows 11 build 26300.9974 on the PR branch head, no GPU needed since this path is pure Python. |
|
Thanks @ChazY11 for probing the modifier matrix and the suggestion! Pushed |
tedin7
left a comment
There was a problem hiding this comment.
Review of head 408ce23 (comment only; the head is the PR branch updated with main, own change unchanged at ef9c434).
Checked against origin/main:
- New
v_fmac_f16_dpp,v_ldexp_f16_dpp,v_cvt_f16_{i16,u16}_dppandv_cvt_{i16,u16}_f16_dpplowerings intools/pixel_aot.pyfollow the same static finite-proof contract as the sibling plain ops and the merged DPP binary16 ops (#419, #1971). DPP8 refuses float modifiers, integer sources refuse them too, the ldexp exponent needs a static proof within the limit, and overflow of the proven result is refused. - No other open or merged PR covers this slice.
- The new fixtures are drawn in
check_dpp_f16_draw(D3D12 WARP and hardware), with per-lane i16 routing and op/modifier mutations that must report a mismatch, in default and-denorm ftzmodes.
Commands run:
- Linux, on the PR head before the update:
tests/pixel_aot_check.pyPASS,tests/docs_links_check.pypass,tests/bidi_controls_check.pypass,git diff --check origin/main...HEADclean.tests/form_coverage_check.pyneedsiced_x86, not available on Linux here; it passed on Win2025. - Mutation of the new cvt_i16_f16 lowering (
trunc->round): the Linux check FAILS. - Mutation of the new ldexp scale (
127 + exponent->128 + exponent): the Linux check still passes, because the numeric result is only proven by the WARP draw. That draw is covered by the Win2025 run below (receipt on this head). - Win2025 dev and release on this head:
ctest -R 'pixel_aot_dpp_f16|pixel_aot_dpp_cvt|pixel_aot_f16'14/14 passed in both.
AI-assisted; commands listed were executed locally.
|
Win2025 WARP receipt for head 408ce23 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
What this changes
Extends the quad-local
DPP16/DPP8binary16 slice (#1971) to lower the six remaining contracted binary16 opcodes (+12 forms acrossgfx1013andrdna2):VOP2DPP16 + DPP8):v_fmac_f16_dpp,v_ldexp_f16_dppVOP1DPP16 + DPP8):v_cvt_f16_i16_dpp,v_cvt_f16_u16_dpp,v_cvt_i16_f16_dpp,v_cvt_u16_f16_dppLowering & contract (
tools/pixel_aot.py)int16_dpp_source()alongsidehalf16_dpp_source()under the existing#839contracts:src0is quad-swizzled viaemit_quad_swizzle_u32;src1and thev_fmac_f16_dppaccumulator stay on the current lane.DPP16allows bit-15abs/negmodifiers on float sources only (src0/src1onv_fmac_f16_dpp,src0onv_ldexp_f16_dppandv_cvt_{i16,u16}_f16_dpp);DPP8and integer operands refuse modifiers.v_fmac_f16_dppusesfma16_rnefor single-rounding fused multiply-accumulate with overflow checked viaf16_pk_fmac_lane_result.v_ldexp_f16_dpprequires a statically proven signed 16-bit exponent in[-64, 64]and checks overflow viaf16_ldexp_result.v_cvt_f16_i16_dppaccepts runtimei16/low16sources;v_cvt_f16_u16_dpprequires a static proof< 65520(f16_cvt_int_result). Both tag destinations("half16", alu)with proven bits when statically known.v_cvt_{i16,u16}_f16_dpptruncates proven in-range binary16 values (f16_to_int_result) into("low16", alu).half_denorm="preserve"andHW_REG_MODERNE remain required.Tests & docs (
tests/pixel_aot_check.py,tests/form_coverage_check.py,docs/experiments.md)pixel_aot_dpp_f16_{warp,hardware}with:fmac_ldexp_dpp16,fmac_ldexp_dpp8,cvt_int16_dpp16,cvt_int16_dpp8) covering fused-vs-non-fused rounding (0x1c01vs0x1c00), subnormal preservation (in both default denorm mode and-denorm ftz), ties-to-even rounding, the65519max finiteu16boundary, truncation toward zero,half16/low16chaining, noisy upper-16 halves, preloaded sentinels, andDPP16-/|.|modifiers, plus 13 numerically distinct mutations (none relying on a signed-zero-only delta).DPP_F16_CVT_I16_LANES) forv_cvt_f16_i16_dppover signed 16-bit lane values{-4, -3, -2, -1}with noisy upper halves (0x1234) across bothDPP16AcrossXandDPP8cyclic rotation, with permutation mutations.check_binary(for LLVM 15 assembly/disassembly round-trip in CI).check_dpp_f16_contract_controlsand existing plain f16 control lists, addscheck_dpp_f16_cvt_fmac_ldexp_forms()intests/form_coverage_check.py, and documents the slice indocs/experiments.md.Verification (Linux)
python3 tests/pixel_aot_check.py: PASS (includingcheck_dpp_f16_contract_controlsand all updated f16 controls).form_coverage_check(check_dpp_f16_cvt_fmac_ldexp_forms,check_dpp_f16_arith_round_forms,check_f16_fmac_ldexp_forms,check_f16_cvt_int16_forms,check_f16_to_int16_forms): PASS (exact +12 forms ingfx1013.tsvandrdna2.tsv, unlowered neighbours excluded).python3 tests/docs_links_check.py: PASS (19 files, 466 links).python3 tests/bidi_controls_check.py: PASS (1,726 files).python3 tests/rdna2_tools_check.py: PASS (156 tests OK, 19 skipped).DPP_F16_CVT_FMAC_LDEXP_MUTATIONSproduce non-zero-sign-only channel diffs.git merge-tree --write-tree --name-only origin/main HEAD&git diff --check origin/main: clean.Windows draws (
pixel_aot_dpp_f16_{warp,hardware}) and LLVM 15check_binaryrun in CI. Synthetic fixture coverage only; console behavior is not measured.AI-assisted: yes.