Repository navigation
GPU test: v_frexp_mant_f16, v_frexp_exp_i16_f16, v_ldexp_f16 on every f16 input (SHADER-354) - #2171
Krashgamer wants to merge 12 commits into
Conversation
… f16 input No GPU test or fuzzer generated these three opcodes, so run_gpu_tests.py passed whatever the translator emitted for them. cs_f16_frexp_ldexp gives each of the 65,536 binary16 encodings its own thread (1024 groups of 64) and stores frexp_mant, frexp_exp, ldexp(x, s4) and x, each destination preloaded with 0x5a5a5a5a so the kept high half is checked too. check.py's f16_frexp_ldexp_test dispatches it once per S1 of F16_FREXP_LDEXP_EXPONENTS (21 values: the denormal and flush edges, the clamp to [-64, 64] from both sides, S1 words whose high bits must be ignored) and compares all 262,144 words of each dump with a model of the rule ItsNotRexed#1931 measured on gfx1036 (f16 denormals kept). run_gpu_tests.py calls the same function. tests/test_shader_checks.py: the fake harness answers the new shader; new tests check that every exponent is sent, that one wrong word is named, that a translator reading f16 denormals as zero fails, that the model gives the gfx1036 words quoted in docs/design.md, and that it agrees with tests/semantic/test_alu_frexp_ldexp_f16.py's reference on every input. Depends on ItsNotRexed#1931: with main's translator the test fails on every f16 denormal (2,046 inputs per dispatch). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # scripts/run_gpu_tests.py
|
Independent Radeon review (AI-assisted with Codex) of
|
The header said all four words carry 0x5a5a in the high half; only the three opcode results do. The checker already expected x as is. Comment only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @whattheflop. That's the first AMD run, and at subgroup 64, which my NVIDIA card can't do. So the "not covered: native 64-wide" line in the description is covered now too. Header nit fixed in 956d02e: the three opcode results carry AI-assisted (Claude Code). |
Flyander
left a comment
There was a problem hiding this comment.
Reviewed the current diff and the reported full-domain GPU sweep. The half-precision frexp/ldexp coverage is exhaustive over all 65,536 input encodings, and the independent AMD run confirms the wave64 case. The documentation comment was corrected at this head. I found no remaining blocker.
# Conflicts: # runtime/test/shaders/check.py # tests/test_shader_checks.py
|
Tested Test programs built from
AI-assisted run on a contributor machine. |
Conflicts: docs/design.md (main dropped duplicated rows and rewrote the f16 frexp/ldexp row; kept main's row and re-added the GPU test sentence) and the check import in scripts/run_gpu_tests.py (both sides' names). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 62a490b on NVIDIA GeForce RTX 4060 Ti, driver 621.01, Windows 11 Home (build 26300): pass Ran: python -I scripts/run_gpu_tests.py --llvm-mc "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc" --build --filter cs_f16_frexp_ldexp Result: 1 shader translated, 1 passes spirv-val. cs_f16_frexp_ldexp: PASS (65536 inputs x 21 exponents, every word exact), 1/1 passed. Also ran tests/test_shader_checks.py: 65 tests OK. Notes:
|
|
Tested 55071e6 on NVIDIA GeForce RTX 4060 Ti, driver 621.01, Windows 11 Home (build 26300): pass Ran: python -I scripts/run_gpu_tests.py --llvm-mc "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc" --build --filter cs_w32_dot4_carry Result: 1 shader translated, 1 passes spirv-val. cs_w32_dot4_carry: PASS (456/456 dumped words exact), 1/1 passed. CPU checks on this branch: tests/test_shader_checks.py 60 tests OK; python -m unittest discover -s tests/semantic -v: 2569 tests OK. Notes:
|
|
Tested 1d93f77 on NVIDIA GeForce RTX 4060 Ti, driver 621.01, Windows 11 Home (build 26300): pass Ran: python -I scripts/run_gpu_tests.py --llvm-mc "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc" --build --filter cs_w32_ds_wrxchg_b64 Result: 1 shader translated, 1 passes spirv-val. cs_w32_ds_wrxchg_b64: PASS, 1/1 passed. The runner printed these words for the test: 2165396956 6702799 3666541181 1331365576 260283320 3557905690 3800037791 286488446 CPU checks on this branch: tests/test_shader_checks.py 59 tests OK; python -m unittest discover -s tests/semantic -v: 1648 tests OK. Notes:
|
|
@jigglephysic0 Thanks for the 4060 Ti run of this one. Your second and third comments here are for other pull requests: AI-assisted (Claude Code). |
|
Tested ffcd045 on NVIDIA GeForce RTX 4060 Ti, driver 621.01, Windows 11 Home (build 26300): pass Ran: python -I scripts/run_gpu_tests.py --llvm-mc "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc" --build --filter cs_lds Result: 2 shaders translated, 2 pass spirv-val. cs_lds: PASS (device: NVIDIA GeForce RTX 4060 Ti, subgroup 32..32). cs_lds_b64_cmpst: PASS. 2/2 passed. The changed runner still reports normally on a passing run. CPU checks on this branch: tests/test_run_gpu_tests.py 38 tests OK; tests/test_shader_checks.py 60 tests OK; python -m unittest discover -s tests/semantic -v: 2567 tests OK. Notes:
|
Conflict: the fixture count in tests/test_shader_checks.py, which main raised to 12 for vs_base_ids and this branch to 12 for cs_f16_frexp_ldexp; it is 13 with both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows
This PR's shaders:
On RDNA4, AI-assisted (Claude Code); I checked the results. |
Conflicts with ItsNotRexed#1518 (cs_fma_fused) and the cs_fmt_d16_xyz / cs_heap_init dumps: both sides' lines kept in check.py and run_gpu_tests.py, main's f16 frexp/ldexp row (now with VOP3 clamp) plus the GPU test sentence, and the fixture count is 14 with both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every new GPU test appends to the end of the check import, the elif chain in run_gpu_tests.py and check.py's results list, so this branch conflicted with each merge round. The import gets its own line, and the two registrations sit next to cs_lds and cs_wavemask, which rarely change. Same behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested 069ff43 merged with main 2d3369a on Linux (Python 3.12.16) and Windows 11 (Python 3.13.1): pass (CPU side only).
|
|
Thanks @kapitche. The repeated and conflicting sentences in that row are already on |
Conflicts after ItsNotRexed#4311 and main's cs_fmt_all: - docs/design.md: keep main's f16 frexp/ldexp row (ItsNotRexed#4311) and extend its last sentence with this PR's GPU check. - scripts/run_gpu_tests.py: main's verdict_line() for the case above, plus the cs_f16_frexp_ldexp branch. - tests/test_shader_checks.py: both sides added one case to TOTAL (13 -> 14), so the merged total is 15. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 069ff43 on Intel UHD Graphics 630 (CFL GT2): run_gpu_tests.py --filter cs_f16_frexp_ldexp with LEONIDA_VK_DEVICE=Intel passes 1/1, "PASS cs_f16_frexp_ldexp 65536 inputs x 21 exponents, every word exact". With LEONIDA_VK_DEVICE=NoSuchDevice the same filter fails with "no Vulkan physical device matches". tests/test_shader_checks.py ran 84 tests OK (the description says 64) and tests/semantic/test_alu_frexp_ldexp_f16.py ran 25 tests OK (the description says 23). This device runs the fixture at subgroup size 32 (range 8..32), so the 64-wide cases are not covered. The control with main's rdna2spirv.py was not run. AI-assisted. |
# Conflicts: # docs/design.md
|
Tested AI-assisted (Claude Code). |
run_gpu_tests.py: cs_lds takes main's compute_result(); the cs_f16_frexp_ldexp branch keeps the check.py-helper form main's cs_fmt_* tests use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check.py: keep main's PK_MUL_LO_WORDS next to the f16 frexp/ldexp constants. TOTAL in test_shader_checks.py is 16: main's 15 plus cs_f16_frexp_ldexp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested The filtered synthetic fixture passed on Linux for all 65,536 binary16 encodings at each of the 21 exponent settings. Every readback word matched. I also tested whether the checker detects damage to the preserved upper half of the destination at the very last encoding. In a temporary fixture, immediately before the store, I flipped bit 16 of the ldexp result only when the input was 0xffff. Both shaders passed SPIR-V validation. The modified run exited 1 and attributed exactly 21 mismatches to ldexp, one per exponent. For exponent zero it reported 0x5a5bffff instead of 0x5a5affff. This confirms the checker observes the preserved bit even when the low 16 result bits still match. AI-assisted verification. |
|
Tested the current head e5ef738 on Windows 11 26200, including an RDNA2 gfx1036-class GPU through AMD's Windows driver: the chip family the expected words were measured on, now running the translated SPIR-V. Setup: MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363, llvm-mc 23.1.6, test programs built from this head. pass
A side note, not caused by this PR: AI-assisted: yes |
|
Tested
Xbox 1.0.2.1 coverage: 0 of 26,503 local |
|
Tested Harness from a RelWithDebInfo build of No game files; synthetic fixture. |
|
Tested e5ef738 on Apple M2 with MoltenVK 1.4.2 (macOS 26.4, subgroup 4..32, device Vulkan 1.4.357): cs_f16_frexp_ldexp passes — 65536 inputs x 21 exponents, every word exact; full suite 179/240 passed, 59 skipped, 2 failed vs base 0805d30 178/239, 59 skipped, 2 failed A/B; no regression. Both builds used the same harness binary. Per-test comparison: the only difference is the new fixture, which passes; both heads have the same two known failures (cs_fma_fused, ps_ssharp). This gives the RDNA2-measured f16 frexp/ldexp denormal rules their first run through translated SPIR-V on an Apple driver, and they hold here.
AI-assisted. |
|
Tested e5ef738 on AMD Radeon RX 6800 (RDNA2 gfx1030, AMD 26.11.2, Windows 11): pass Trial merge onto
Toolchain: llvm-mingw 20261117 clang, CMake 4.5.1 + Ninja, |
|
Tested e5ef738 (merged onto main 86a7807) on NVIDIA GeForce RTX 2060 (Turing), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 (10.0.26300), subgroup size 32: pass What I ran:
The new GPU test runs and passes:
The one failure on both sides is AI-assisted run (Claude Code); the numbers are from my machine. |
|
Row: head
Synthetic shaders only. Posted by Hermes (agent). |
Item: SHADER-354 (claimed in #1902: #1902 (comment)).
Builds on #1931 (merged), whose f16 denormal rule this tests on the GPU.
What and why
No GPU test or fuzzer generates
v_frexp_mant_f16,v_frexp_exp_i16_f16orv_ldexp_f16(#1931's description says so too), sorun_gpu_tests.pypasses whatever the translator emits for them. #1931 changes how they handle f16 denormals, measured on RDNA2 throughtools/hw_oracle. Those are raw native kernels, though, not the translated SPIR-V. This adds a GPU test that runs the translated program on each tester's GPU and checks every f16 input.The change
runtime/test/shaders/cs_f16_frexp_ldexp.asm: each of the 65,536 binary16 encodings gets its own thread (1024 groups of 64). Each thread storesfrexp_mant(x),frexp_exp(x),ldexp(x, s4)andx. Every destination starts as0x5a5a5a5a, so the kept high half is checked too. The header quotes the gfx1036 words fromdocs/design.md.runtime/test/shaders/check.py:f16_frexp_ldexp_testruns it once per S1 ofF16_FREXP_LDEXP_EXPONENTS, 21 values:0x8000,0x7FFF);0x00010003,0xFFFF0005).It compares all 262,144 words of each dump with a model of the rule in
docs/design.md. The expected dump is built once per S1 and compared as bytes, and a word-by-word scan only runs on a mismatch. A failure names the number of wrong words per op and the first one.scripts/run_gpu_tests.py: calls the same function.tests/test_shader_checks.py: the fake harness answers the new shader (TOTAL+ 1). New tests check that:docs/design.md;tests/semantic/test_alu_frexp_ldexp_f16.py'sref_mant/ref_exp/ref_ldexpon every input and exponent. Its functions and constants are read withast, astest_inputs_match_the_interpreter_testdoes, so the translator isn't imported.docs/design.md: the f16 trio's row names the GPU test.Tested
NVIDIA GeForce RTX 3080 (Ampere), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 25H2, MSVC 14.51.36231 (VS 2026 Build Tools), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (built with
scripts/build_llvm_mc.ps1). No game files.python -I scripts/run_gpu_tests.py: 134/174 passed, 40 skipped (main 6a6704d: 133/173).cs_f16_frexp_ldexp:65536 inputs x 21 exponents, every word exact, about 9 s. Of the skips:d3d12_m2_textured_test/d3d12_m3_frame_test/d3d12_translated_draw_test, which pass inctest(main'sctest: 111/113; the two failures ared3d12_computeandd3d12_draw, d3d12_compute_test: release the slot-67 PSO before the device reference check #1898 and fix(test): use monotonic fence value (31) for bundle blend pass in d3d12_draw_test #1807);LEONIDA_W64_EMULATE=1: 165/174 passed, 9 skipped, 0 failed (main: 164/173).cs_f16_frexp_ldexppasses with the--wave64-emulatetranslation too.main'stools/rdna2spirv.py:cs_f16_frexp_ldexpfails:frexp_exp: 42966 words wrong, first x 0x0001 S1 0x0: got 0x5a5a0000, expected 0x5a5affe9. That's the 2,046 f16 denormals × 21 dispatches, plus 141,274 ldexp words.python -I tests/test_shader_checks.py: 64 tests OK, 7 s (59 tests in 1.4 s on main: building the expected words and the cross-check over every input take the rest).python -m compileall -q make_game.py tools tests,python -I make_game.py --help: OK.pytest tests --ignore=tests/semantic(pytest 9.2.0): 5 failed, 4236 passed, 104 skipped. On main 6a6704d it's 5 failed, 4229 passed, and the same 5 subtests fail on both:test_cf_ref.py's twoexec_hicases: test_cf_ref: drop exec_hi from the Unsupported list now that cf_ref models it #1852 is open for them;test_world_names.py's three overwrite cases: fixed by world_names test: check the overwrite diagnostic for the path as printed #1848, merged after 6a6704d.tests/semantic/test_alu_frexp_ldexp_f16.py: 23/23 OK (Translator: v_frexp_*_f16 and v_ldexp_f16 keep f16 denormals, measured on RDNA2 #1931's).After merging
main(4f61cba9f, 2026-11-23). The merge resolved three conflicts:docs/design.mdrow now has feat(rdna2spirv): measure and support VOP3 output modifiers on v_frexp/ldexp_f16 #4311's text plus this PR's GPU sentence;run_gpu_tests.pyusesmain'sverdict_line();TOTALintests/test_shader_checks.pyis 15, because both sides added one case.Re-run on the merged tree, RTX 3080, NVIDIA 610.88:
run_gpu_tests.py --filter cs_f16_frexp_ldexp:65536 inputs x 21 exponents, every word exact.tests/test_shader_checks.py: 87 tests OK (pytest: 91 passed).tests/semantic/test_alu_frexp_ldexp_f16.py: 25 tests OK; all frexp/ldexp semantic tests: 246 OK.test_run_gpu_tests.py,test_ci_registration.pyand the docs tests: OK.Second merge of
main(3b849d7a6). One conflict, in the samedocs/design.mdarea:mainrewrote the neighbouringv_frexp_mant_f64row; that row is nowmain's, and the f16 row keeps this PR's GPU sentence. Re-run:run_gpu_tests.py --filter cs_f16_frexp_ldexpwith a rebuilt runtime: every word exact again;tests/test_shader_checks.py(pytest): 93 passed; the 11 frexp/ldexp semantic test files: OK.Third merge of
main(c9d4c2c4d). One conflict, inrun_gpu_tests.py:mainroutescs_ldsand the other directvk_compute_testruns throughcompute_result();cs_f16_frexp_ldexpkeeps thecheck.py-helper form thatmain'scs_fmt_*tests use. Re-run:run_gpu_tests.py --filter cs_f16_frexp_ldexpwith a rebuilt runtime: every word exact;test_shader_checks.py+test_run_gpu_tests.py(pytest): 151 passed;test_ci_registration.py: OK.Fourth merge of
main(e5ef73839). Conflicts incheck.py(main'sPK_MUL_LO_WORDSnext to this PR's constants) andTOTAL, now+ 16): main's 15 pluscs_f16_frexp_ldexp.cs_f16_frexp_ldexpon the GPU with a rebuilt runtime: every word exact.test_shader_checks.pyhas 15 errors on this head and on plainmainalike, from #6833'sps_table_fetchmock (fix in #7094). With #7094's test change applied on top (andTOTALat 17), 151 passed (pytest) andpython -I tests/test_shader_checks.pyis OK.The counts above this section are from the original head.
Not covered here: a native 64-wide run (no such subgroup on NVIDIA). SlopTart has since run it natively at wave64 on an AMD RX 7900 XT (RADV), exact (comment).
Overlap
@Vonsek has claimed the f32 trio's GPU test (EGEN-GPU-FREXP32, #1902). It covers different opcodes, but it will likely add a check at the same places in
check.py,run_gpu_tests.pyandTOTALintests/test_shader_checks.py. Whichever lands second only needs to add its line next to the other and bumpTOTALonce more.Checklist
docs/design.md, with how it was confirmed. (No new rule: Translator: v_frexp_*_f16 and v_ldexp_f16 keep f16 denormals, measured on RDNA2 #1931's row now names this GPU test.)AI-assisted: the code, the tests and this description were written by Claude Code at my request, and it ran them on my PC.
🤖 Generated with Claude Code