shader: lower v_pk_fmac_f16 in pixel_aot #997
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1004"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T20:44:38Z.
Refs #990
Summary
VOP2packed binary16 multiply-accumulate instruction (v_pk_fmac_f16/v_pk_fmac_f16_e32, AMD RDNA 2 ISA §12.11 opcode0x3c, LLVM 15VOP2Instructions.td:V_PK_FMAC_F16) intools/pixel_aot.pyusingvdstas the implicit packed accumulator (vdst.f16[0] = src0.f16[0] * vsrc1.f16[0] + vdst.f16[0],vdst.f16[1] = src0.f16[1] * vsrc1.f16[1] + vdst.f16[1]), reusingvop3p_f16_word,widen16, binary32mad, andpack16_rne.vdst(or scalarhalf16value), non-VGPRvsrc1, modifiers (clamp,op_sel,op_sel_hi,neg_lo,neg_hi,abs,-,mul), unmodelled encodings (_e64, DPP, SDWA), out-of-range/unbound operands, and round-toward-zero mode.draw-pk-fmacintests/pixel_aot_check.py(exactR32G32B32A32_UINTreadback across four constant sets covering VGPR/SGPR/32-bit literal/inline-f16src0, chained accumulation, in-placedst == src1, exact binary16 halfway ties, subnormals under both-denorm preserveand-denorm ftz, and signed infinity overflow), three negative draw controls (dropped accumulator, swapped halves, truncated rounding—each must reportpixel_mismatch), static refusal controls, and binary round-trip registration incheck_binary.pixel_aot_pk_fmac_warpandpixel_aot_pk_fmac_hardware(SKIP_RETURN_CODE 77,FORM_COVERAGE_RECORD) inCMakeLists.txt, addcheck_pk_fmac_coverage()intests/form_coverage_check.py, and document the fixture indocs/experiments.md.Verification
Commit:
09c7583(based onorigin/maind7c52d2), Windows 10 x64, D3D12 debug layer enabled.ctest --preset dev --no-tests=error -R "^pixel_aot_pk_fmac_" -V:pixel_aot_pk_fmac_hardware(NVIDIA GeForce RTX 3060, driver32.0.15.9636,debug_layer=enabled,debug_errors=0 debug_warnings=0): Passedpixel_aot_pk_fmac_warp(Microsoft Basic Render Driver, driver10.0.19041.5794,debug_layer=enabled,debug_errors=0 debug_warnings=0): Passedctest --preset release --no-tests=error -R "^pixel_aot_pk_fmac_" -V:pixel_aot_pk_fmac_hardware: Passed (4.25 sec)pixel_aot_pk_fmac_warp: Passed (2.21 sec)ctest --preset dev --no-tests=error -R "^pixel_aot_"andctest --preset release --no-tests=error -R "^pixel_aot_":devandrelease(includingpixel_aot_warp,pixel_aot_hardware,pixel_aot_pk_fmac_warp,pixel_aot_pk_fmac_hardware,pixel_aot_blend_scalar_warp,pixel_aot_title_loads_hardware).pixel_aot_blend_scalar_hardware(RTX 3060) andpixel_aot_title_loads_warp(Win10 WARP10.0.19041.5794)..\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: Passed (form coverage checks passed).\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py: Passed (Checked 13 Markdown files and 205 links.).\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: Passed (Checked 827 tracked source, script and build/CI files: no bidirectional controls.)tests/pixel_aot_check.py binary: LLVM 15 (llvm-mc-15/libLLVM-15) is not installed locally on this Windows host;pk_fmac_program()is registered incheck_binaryfor Ubuntu CI.AI-assisted (Claude Code)
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:46:03Z.
The current reference explicitly rounds the accumulated result to binary32 before packing, and the generated HLSL takes the same path. That does not cover the fused binary16 result discussed in #990. Please add the exact discriminator from that thread to the actual readback: low halves
0x3e00,0x3956, accumulator0x0001give direct half RNE0x3c01, intermediate f32 then half0x3c00. Use an exact reference (integer or rational), establish the claimed denormal mode independently, and make the intermediate-f32 mutant fail at that lane. A broader input domain needs evidence for accepted NaNs, infinities, signed zero, and overflow. The fixture and alias checks can stay while the precision path is corrected.Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T21:46:08Z.
Thanks. Addressed in
5b2b07b(plus a merge ofmain, no force-push):fma16_rne) forms the exact 22-bit significand product, aligns the accumulator with a sticky bit, and rounds once to binary16 RNE, independent of-denorm ftz.0x3e00 × 0x3956 + 0x0001is lane 0 low half of theprecisionprogram and lane 3 high half ofalias_chain. Both read back0x3c01on WARP and RTX 3060, dev and release, under-denorm preserveand-denorm ftz.pack16_rne(mad(widen16(...)))reportspixel_mismatchonly at those lanes:expected=0xbc003c01 actual=0xbc003c00andexpected=0x3c010401 actual=0x3c000401. The other channels are unchanged.fractions.Fractionand rounds once to binary16 RNE.0x0001 × 0x3c00 + 0x0001 = 0x0002,0x0400 × 0x3800 = 0x0200, and a subnormal-to-normal carry0x0001 × 0x4000 + 0x03ff = 0x0401. Flush-in and flush-out mutants fail at exactly those lanes. The fixture asserts the preserve profile.The alias checks, distinct lane inputs, uninitialized-destination and modifier refusals stay. Tests:
ctest -R "^pixel_aot_pk_fmac_"2/2 in dev and release; neighbourspack_b32,dpp_extra,f16_arithandregion_bodypass on the merged tree, along with the three Python checks.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T21:56:03Z.
The updated
4648502fpasses the LLVM 15 round trip and both focused Windows draws on RTX 4060 Laptop and in-box WARP. I reproduced0x3c01in both witness lanes, and the intermediate-f32 mutation returned0x3c00where expected. The emitted 32-bit integer helper also matched an independent exact-integer reference across 163,824 finite triples, including cancellations, signed zeros, subnormals and the overflow boundary. The accepted slice remains statically proven finite operands, declared f16 preserve and RNE.