Repository navigation
tests: GPU readback for the binary64 roundings, v_trunc_f64, v_ceil_f64, v_rndne_f64 and v_floor_f64 (GPU-ROUND-F64) - #1034
Merged
Conversation
…64, v_rndne_f64 and v_floor_f64 (GPU-ROUND-F64) The translator gives the four ops to the driver's double-precision Trunc, Ceil, RoundEven and Floor, and no fixture in runtime/test/shaders ran them, so what a driver does with ties, the largest value below 0.5, values at and above 2^52, signed zeros, subnormals, infinities and NaNs had never gone through the GPU suite. cs_w32_round_f64 is memory-fed, like cs_w32_shift64 and cs_w32_cmp_f64: check.py seeds 64 inputs and each thread loads one at run time and stores eight results: the four roundings, v_trunc_f64 with a neg source, v_ceil_f64 with an abs source, a v_floor_f64 whose destination pair overlaps its source pair, and a v_rndne_f64 run with the odd threads turned off, whose destination must keep the pair it held. The expected words come from Python floats (exact IEEE-754, the result keeping its source's sign) and are checked against exact rational rounding in tests/test_gpu_round_f64.py. Two kinds of input are judged by what Vulkan lets a driver do, not by RDNA2: a NaN may come back as another NaN, and a subnormal may be read as a zero of its sign, since the module declares no DenormPreserve for 64 bits. That is what the fixture measured: on an RTX 4070 Ti a signalling NaN comes back quiet, and on llvmpipe the smallest subnormals are also read as zero. The row in docs/design.md records both as an approximation. dump_test takes an optional judge for such a readback. No translator or runtime change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 24, 2026
Contributor
|
AMD run: RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11. Head
|
…undEven (GPU-ROUND-F64) linux-gpu-tools failed this fixture with `word 164 (thread 10): rndne of 0x3fe0000000000001 gave 0x0000000000000000`, on some runners and not on others. The cause is llvmpipe, not the translation: its double vectors are twice its native width (512 bits at the usual 256), and it has the exact Trunc and RoundEven only for a width the CPU has a vector extension for. Without AVX-512 the two ops go through the code it has for a float, where a magnitude above 2^24 comes back unchanged and RoundEven of a smaller one can give the other neighbouring integer. That is 48 of the 512 results, the same 48 with Mesa 25.2.8 (LLVM 20.1.2) on a runner and with Mesa 26.2.6 (LLVM 23.1.4) under GALLIUM_OVERRIDE_CPU_CAPS=avx, sse4.1 or sse2 on a Ryzen 9 7900X; Floor and Ceil are exact on that path, and with AVX-512 (or AVX at LP_NATIVE_VECTOR_WIDTH=128) so are all four. On llvmpipe the judge now lets v_trunc_f64 and v_rndne_f64 return what that path can give: the source itself above 2^24, either neighbouring integer with the source's sign from 0.5 up to it. Everything else stays exact there, and no other device gets the allowance (ROUND_F64_FLOAT_PATH, keyed like UNJUDGED_WORDS). dump_test hands the test program's output to a judge, for its device line. Tested: the fixture passes on llvmpipe natively and under each of the three overrides, at LP_NATIVE_VECTOR_WIDTH=128, and on the RTX 4070 Ti (NVIDIA 620.70.06) natively and with LEONIDA_W64_EMULATE=1; the previous judge fails under each override at word 164. tests/test_gpu_round_f64.py rebuilds the 48 measured results and checks that nothing wider passes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale
added a commit
to milk4sale/leonida
that referenced
this pull request
Nov 24, 2026
…s llvmpipe allowance ProjectLeonida#1034 gained a commit: on llvmpipe, v_trunc_f64 and v_rndne_f64 may return what its float code gives a double on a CPU without AVX-512. That fixture is in this stack and was this branch's red linux-gpu-tools (`word 164 (thread 10): rndne of 0x3fe0000000000001 gave 0x0000000000000000`); cs_w32_frexp_ldexp passed in that run. No conflict. Tested on this merge: `--filter cs_w32_` on llvmpipe (Mesa 26.2.6) natively and under GALLIUM_OVERRIDE_CPU_CAPS=avx, 15 of 23 passed and 8 skipped in both, and 23 of 23 on the RTX 4070 Ti (NVIDIA 620.70.06). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale
added a commit
to milk4sale/leonida
that referenced
this pull request
Nov 24, 2026
…dge keeps llvmpipe's float-path allowance ProjectLeonida#1034 gained a commit: on llvmpipe, v_trunc_f64 and v_rndne_f64 may return what its float code gives a double on a CPU without AVX-512 (the cause of this branch's red linux-gpu-tools, `word 164 (thread 10): rndne of 0x3fe0000000000001 gave 0x0000000000000000`). The judge here stays exact for every other word and device, a NaN and a subnormal included, and takes that one allowance; docs/testing.md says so next to "compared exactly". Tested on this merge: the fixture passes on llvmpipe (Mesa 26.2.6) natively and under GALLIUM_OVERRIDE_CPU_CAPS=avx and sse2, and on the RTX 4070 Ti (NVIDIA 620.70.06) natively and with LEONIDA_W64_EMULATE=1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
3 of 4 tasks
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings the branch up to date with main 6558d53, which now holds ProjectLeonida#1012 (GPU-CMP-F64), the pull request this one was stacked on. Git merged it without conflicts (git merge-tree, exit 0). GitHub had reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782); main is an ancestor of this commit. The merged tree was tested before the push: every standalone test file under tests/ passes except tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale
added a commit
to milk4sale/leonida
that referenced
this pull request
Nov 24, 2026
… with ProjectLeonida#1012 merged Takes the updated head of ProjectLeonida#1034's branch, which holds main 6558d53 (ProjectLeonida#1012, GPU-CMP-F64, is merged there). Git merged it without conflicts (git merge-tree, exit 0), and the tree is the one a direct merge of main gives. GitHub had reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782). Merging ProjectLeonida#1034's head instead of main leaves this branch with one merge base with main when ProjectLeonida#1034 merges. The merged tree was tested before the push: every standalone test file under tests/ passes except tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale
added a commit
to milk4sale/leonida
that referenced
this pull request
Nov 24, 2026
…ProjectLeonida#1012 merged Takes the updated head of ProjectLeonida#1034's branch, which holds main 6558d53 (ProjectLeonida#1012, GPU-CMP-F64, is merged there). Git merged it without conflicts (git merge-tree, exit 0), and the tree is the one a direct merge of main gives. GitHub had reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782). Merging ProjectLeonida#1034's head instead of main leaves this branch with one merge base with main when ProjectLeonida#1034 merges. The merged tree was tested before the push: every standalone test file under tests/ passes except tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Collaborator
|
Merged, after #1012. Checked locally on
A note for later, not blocking: on llvmpipe the float-path allowance lets AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: GPU-ROUND-F64 (#14 (comment))
Depends on: #1012 (this branch is one commit on top of it. Both add a memory-fed fixture next to
cs_w32_shift64and touch the same lines ofcheck.py,run_gpu_tests.pyandtests/test_shader_checks.py; the last commit is the one to review.)What and why
v_trunc_f64,v_ceil_f64,v_rndne_f64andv_floor_f64are translated to the driver's double-precisionTrunc,Ceil,RoundEvenandFloor(shaderFloat64). The row indocs/design.mdis CPU-checked and hardware-confirmed on gfx1036, but no fixture inruntime/test/shadersran the four ops, so what a driver does with ties, the largest value below 0.5, values at and above 2^52, signed zeros, subnormals, infinities and NaNs had never gone through the GPU suite.This adds
cs_w32_round_f64, memory-fed likecs_w32_shift64(#590) andcs_w32_cmp_f64(#1012):check.pyseeds 64 binary64 inputs throughVKC_HEAP_INIT; each thread loads one at run time, so nothing folds.v_trunc_f64with anegsource,v_ceil_f64with anabssource, av_floor_f64whose destination pair overlaps its source pair, and av_rndne_f64run with the odd threads turned off, whose destination must keep the pair it held.round_f64: exact IEEE-754, the result keeping its source's sign).tests/test_gpu_round_f64.pychecks that oracle against exact rational rounding and against the values the row names, and checks the judge, the assembly, the readback and the runner verdicts without a GPU.dump_testgets an optionaljudgefor a readback that is not compared word for word.What it found
Two differences between the row and what the translated module does on a driver, posted as a finding (#14 (comment)):
0x7ff0000000000001gives0x7ff8000000000001), on the RTX 4070 Ti and on llvmpipe. The hardware returns it unchanged.v_ceil_f64of the positive one gives +0 where the hardware gives 1. The 4070 Ti keeps them. The module declares noDenormPreservefor 64 bits, and neither device reportsshaderDenormPreserveFloat64.Vulkan allows a driver both, so the fixture judges those two kinds of input by that (a NaN may come back as any NaN; a subnormal may be read as a zero of its sign) and every other word exactly. The row now records both as an approximation. The fix is claimed separately as SHADER-ROUND-F64-SPECIALS and will make the judge exact; it is not in this pull request.
Added with
60c2ed910: a third difference, and the cause of the redlinux-gpu-toolshere. The job failed this fixture withword 164 (thread 10): rndne of 0x3fe0000000000001 gave 0x0000000000000000, on some runners and not on others. It is llvmpipe, not the translation: llvmpipe's double vectors are twice its native width (512 bits at the usual 256), and it has the exactTruncandRoundEvenonly for a width the CPU has a vector extension for. On a CPU without AVX-512 the two ops go through the code it has for a float: a magnitude above 2^24 comes back unchanged (v_trunc_f64of 123456789.0625 is 123456789.0625), andRoundEvenof a smaller one can give the other neighbouring integer (1 for 1.5, 0 for the value just above 0.5). That is 48 of the 512 results.FloorandCeilare exact on that path. My llvmpipe run passed because this machine has AVX-512;GALLIUM_OVERRIDE_CPU_CAPS=avx(orsse4.1,sse2) on the same machine gives the runner's failure word for word, with Mesa 26.2.6 as with the runner's 25.2.8.So on llvmpipe, and on no other device, the judge lets
v_trunc_f64andv_rndne_f64return what that path can give: the source itself above 2^24, either neighbouring integer with the source's sign from 0.5 up to it (ROUND_F64_FLOAT_PATHincheck.py, keyed by device name likeUNJUDGED_WORDS).v_floor_f64,v_ceil_f64, the kept pair and the inputs stay exact there.dump_testpasses the test program's output to a judge, for its device line.No translator or runtime change here.
Tested
At this head (
355c8c9c2;main82a2aabccplus #1012), llvm-mc 23.1.4, SPIRV-Tools v2026.4:python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_round_f64 --require-passon the RTX 4070 Ti: PASS natively and withLEONIDA_W64_EMULATE=1; on llvmpipe: PASS.--filter cs_w32_on the 4070 Ti: 22/22.rndnelowered asfloor(x + 0.5)(word 20, the sign of -0),trunclowered asFloor,ceillowered asFloor, thenegsource modifier ignored (word 8), theabsone ignored (word 26), the low result word taken from the high one (word 8), and the fixture without itsv_cmpx(word 30). One control did not fail and is not counted:RoundEvenreplaced by GLSLRoundgives the same words on both devices, because both send a tie to the even integer.python -I tests/test_gpu_round_f64.py(14 tests),tests/test_shader_checks.py(87),tests/test_run_gpu_tests.py(64),tests/test_gpu_cmp_f64.py,tests/test_gpu_shift64.py,tests/test_docs_design_rows.py,tests/test_docs_links.py,tests/test_docs_repo_paths.py,tests/test_text_write_line_endings.py,tests/test_regen_fixtures.py: OK.python -m compileall -q make_game.py tools testsandscripts/check_no_game_data.pyon the changed files: OK.git merge-treeof this branch againstmainfce586c6d: clean.60c2ed910: the fixture passes on llvmpipe (Mesa 26.2.6) natively, underGALLIUM_OVERRIDE_CPU_CAPS=avx,sse4.1andsse2, and atLP_NATIVE_VECTOR_WIDTH=128, and on the RTX 4070 Ti natively and withLEONIDA_W64_EMULATE=1. The judge of355c8c9c2fails under each of the three overrides at word 164, as the runner did; a scratch judge that lists every wrong result gave the same 48 under each.tests/test_gpu_round_f64.py(18 tests now) rebuilds those 48 and checks that nothing wider passes: not a non-neighbour, a lost sign, an unchanged value below 2^24, anything forceilorfloor, or anything on another device. On the CI image itself (ubuntu-24.04, Mesa 25.2.8, LLVM 20.1.2; the Runtime workflow run on my fork from a scratch branch that sets theavxoverride and counts): the fixture passes and 48 results take the allowance; three runs without the override landed on runners where none did. The whole GPU suite on llvmpipe gives the same verdict for every fixture natively and under theavxoverride (172 of 254 passed, 80 skipped; the two that fail arecs_imgload_tfeandcs_imgload_d16_tfe, which this branch's base predates the fix of, tests: correct resident TFE status expectations (SHADER-1266) #892), so no other fixture depends on that path. On the tree merged withmain4a50caf every standalone test file undertests/passes excepttests/test_ctest_registration.py, which fails onmainalone (test_ctest_registration: read a named skip code (kSkip) by its value (red on main since #927) #1252).Not run: the whole GPU suite and the whole standard-library test set at this head (both ran for #1012, one commit below, with the results given there); llvm-mc 19, which the
linux-gpu-toolsjob assembles with (not installed here); the translator suite (nothing undertools/ortests/semantic/changes); Windows; AMD hardware.GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); Mesa llvmpipe 26.2.6 (LLVM 23.1.4), same machine (Ryzen 9 7900X, also with
GALLIUM_OVERRIDE_CPU_CAPS=avx,sse4.1andsse2); Mesa llvmpipe 25.2.8 (LLVM 20.1.2) on a GitHub ubuntu-24.04 runnerAI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No new rule; the existing row now names the fixture and what it measured.)🤖 Generated with Claude Code