mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1034] [MERGED] tests: GPU readback for the binary64 roundings, v_trunc_f64, v_ceil_f64, v_rndne_f64 and v_floor_f64 (GPU-ROUND-F64) #1072
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1072
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1034
Author: @milk4sale
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:gpu-test/round-f64📝 Commits (4)
355c8c9tests: GPU readback for the binary64 roundings, v_trunc_f64, v_ceil_f64, v_rndne_f64 and v_floor_f64 (GPU-ROUND-F64)60c2ed9tests: cs_w32_round_f64 allows llvmpipe's float path for Trunc and RoundEven (GPU-ROUND-F64)e040dceMerge main into gpu-test/round-f6469935f8Merge main into gpu-test/round-f64📊 Changes
7 files changed (+581 additions, -5 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
docs/testing.md(+37 -0)📝
runtime/test/shaders/check.py(+153 -2)➕
runtime/test/shaders/cs_w32_round_f64.asm(+56 -0)📝
scripts/run_gpu_tests.py(+5 -0)➕
tests/test_gpu_round_f64.py(+319 -0)📝
tests/test_shader_checks.py(+10 -2)📄 Description
Claimed in the coordination issue as: GPU-ROUND-F64 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138391743)
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 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7138652249):
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, #892), so no other fixture depends on that path. On the tree merged withmain4a50cafc7every standalone test file undertests/passes excepttests/test_ctest_registration.py, which fails onmainalone (#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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.