Repository navigation
shader: measure RDNA2 v_cvt_f16_f32 output modifiers under RTZ and preserve div:2 underflow sign - #3141
Conversation
…eserve div:2 underflow sign
|
Tested Independent Linux Vulkan check of The Reverting only the translator change produced positive zero in both negative-underflow cases. The other seven result words stayed exact. Both modules assembled with LLVM 21.1.8 and passed SPIR-V validation for Vulkan 1.2. All five focused semantic tests passed. Synthetic inputs only. AI-assisted. AI-assisted verification. |
|
Apple M2 data point. Tested head 22c5f58 on Apple M2 (Mac14,3), macOS 26.4 (25E246), MoltenVK 1.4.2 (direct), subgroup 4..32, llvm-mc 23.1.6, Python 3.13.18.
Build note: full build fails on AppleClang 17 at vk_pipeline_check.cpp:567 (BUILD-822, fixed by open PR #2927); GPU binaries built, so the run above is valid. Head fetched unchanged into a separate worktree; no rebase/edit/push. Synthetic shaders and counts only; no game files. AI-assisted. |
AI-assisted PR. No game files were read, modified, or committed; everything uses synthetic assembly,
tools/hw_oracle,tools/rdna2spirv.py, and unit/semantic tests.Claim: #3047 (comment)
Summary
(±65504 under MODE toward zero, unmeasured)note indocs/design.mdby measuringv_cvt_f16_f32VOP3 output modifiers (mul:2,mul:4,div:2,clamp, and combinedclamp+ omod) on native RDNA2 (gfx1036, wave32 & wave64) across 5 float modes including dynamicMODEswitches (s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 3), viatools/cvt_f16_omod_probe.py.Gen.f16_omod(tools/rdna2spirv.py):div:2underflowing an exponent-1 normal (e == 1,-2^-14..-(2 - 2^-10)*2^-14) returns signed zero (h & 0x8000, so-0.0/0x8000) in both RNE andMODEtoward-zero, whereas pre-omod zero/denorm (e == 0) flushes to+0.0(0x0000) and trailingclampturns-0.0back into+0.0. PreviouslyGen.f16_omodtreatede < 2identically and returned0x0000fore == 1.docs/design.mdand adds unit/semantic regression tests.Hardware Measurements (
gfx1036)Measured on AMD Radeon(TM) Graphics (
gfx1036, Windows 11, driver32.0.21045.29003) viatools/cvt_f16_omod_probe.py:e == 0(±0.0,±denormflushed to 0): gives+0.0(0x0000) under all omods (mul:2,mul:4,div:2).div:2underflow ofe == 1normal (-2^-14,-1.5*2^-14,0xb8ffe000): produces-0.0(0x8000), preserving the sign bit (h & 0x8000). Combinedclamp div:2yields+0.0(0x0000) becauseclampapplies after omod.MODEtoward-zero (FP_ROUND = 3):mul:2/mul:4finite overflow saturates to±65504(0x7bff/0xfbff), true±infremains±inf(0x7c00/0xfc00), and±65520/±FLT_MAXwithdiv:2round to±65504before halving to±32752(0x77ff/0xf7ff). On0xb8fffe00, RNE rounds up to-2^-13(0x8800) then halves to-2^-14(0x8400), whereas RTZ truncates to0x87ff(e == 1) then halves to-0.0(0x8000).denorm16_64=3orieee=1, omod is ignored whileclampstill applies. Wave32 and wave64 match bit-for-bit (0xaaaahigh half preserved in all 2,880 evaluations).Files Changed
tools/rdna2spirv.py— preserveh & 0x8000inGen.f16_omodwhendiv:2underflowse == 1normalstools/cvt_f16_omod_probe.py— self-checking RDNA2 hardware probe + reference model +--self-testtests/test_cvt_f16_omod_probe.py— 12 stdlibunittesttests (FakeOracle, reference edge cases, live AMD clang assembly whenLEONIDA_AMD_CLANGis set)tests/semantic/test_cvt_f16_omod.py— 5 semantic translator +spirv_mini_interpregression tests (including negative controls)docs/design.md— updatev_cvt_f16_f32output modifiers contract row withgfx1036measurementsVerification
gfx1036hardware probe (LEONIDA_AMD_CLANG=...):python -I tools/cvt_f16_omod_probe.py --hw-arch gfx1036->2880 evaluations across 2 wave(s) x 5 mode(s) x 8 mod(s): lo_mismatches=0, hi_mismatches=0, wave_diffs=0, dyn_rtz_diffs=0python -I tests/test_cvt_f16_omod_probe.py -v->Ran 12 tests ... OKLEONIDA_VK_VALIDATION=1on AMD Radeon RX 9070 XT (driver26.11.2,32.0.32029.2010) and AMD Radeon(TM) Graphics (driver26.11.2,32.0.21045.29003):ps_outmods_f16viascripts/run_gpu_tests.py:PASS ps_outmods_f16 4096/4096 pixels exact(1/1 passed) on both GPUsdiv:2exp-1-0.0,clamp div:2, and dynamic RTZmul:2/div:2+ RNE switchback (spirv-val+vk_compute_test.exe): all 9 words exact (0xaaaa8000, 0xaaaa8000, 0xaaaa0000, 0xaaaa0000, 0xaaaa7bff, 0xaaaafbff, 0xaaaa77ff, 0xaaaa7c00, 0xaaaa7c00) on both GPUsLEONIDA_AMD_CLANG):python -I tools/cvt_f16_omod_probe.py --self-test->self-test ok (36 inputs, 1440 cases/wave)python -I -m compileall -q make_game.py tools tests-> passpython -I tests/test_cvt_f16_omod_probe.py -v->Ran 12 tests ... OK (skipped=1)python -I tests/semantic/test_cvt_f16_omod.py -v->Ran 5 tests ... OKpython -m unittest discover -s tests/semantic -p test_value_semantics.py -v->Ran 33 tests ... OKpython -m unittest discover -s tests/semantic->Ran 4147 tests ... OKpython -I tests/test_text_write_line_endings.py -v->Ran 2 tests ... OKpython -I tests/test_resource_hygiene.py -v->Ran 2 tests ... OKpython -I tests/test_ci_registration.py -v->Ran 5 tests ... OKpython -I tests/test_docs_links.py -v->Ran 5 tests ... OKpython -I tests/test_docs_repo_paths.py -v->Ran 2 tests ... OKpython -I tests/test_docs_list_items.py -v->Ran 2 tests ... OK