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 8 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 |
Item: SHADER-354 (claimed in #1902: #1902 (comment)).
Depends on: #1931. Until #1931 merges, this diff also shows its commit (31579b9); this PR's change is the last commit.
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).Not covered: a native 64-wide run (no such subgroup on NVIDIA). The kernel has no cross-lane operations, so lane width shouldn't change its words.
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