tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-EXT) #1114
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1114
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1114/head"
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?
@milk4sale on GitHub · 2026-11-24 18:43 UTC · original
milk4sale:gpu-test/salu-ext→main· +879 −5 · 8 files · 2 commits · merged 2026-11-25 01:49 UTCClaimed in the coordination issue as: GPU-SALU-EXT (#14)
What and why
38 scalar ALU ops had no fixture in
runtime/test/shaders, so no GPU test ran the SPIR-V their rules emit:s_sub_i32,s_andn2_b32,s_orn2_b32,s_xor_b32,s_ashr_i32,s_mul_hi_u32,s_lshl3_add_u32,s_lshl4_add_u32,s_pack_ll_b32_b16,s_pack_hh_b32_b16,s_abs_i32,s_bcnt0_i32_b32,s_bitset0_b32,s_bitset1_b32,s_brev_b32,s_flbit_i32,s_flbit_i32_b32,s_sext_i32_i8, the sixs_cmp_*_i32,s_cmp_gt_u32,s_cmp_le_u32,s_bitcmp0_b32,s_bitcmp1_b32,s_addk_i32,s_mulk_i32,s_cmovk_i32,s_ashr_i64,s_lshl_b64,s_lshr_b64,s_bcnt0_i32_b64,s_bitset0_b64,s_cmov_b64ands_ff0_i32_b64.cs_w32_salu_extruns them in one thread and stores 73 words:s4..s19throughVKC_SGPRS. A scalar op on literals is folded by thetranslator (the "Chained scalar constant folding" row of
docs/design.md) and only its result reaches thedriver; with run-time operands each op reaches it as SPIR-V.
operands that set it and on operands that clear it (each compare and bit test both ways, the signed and the
unsigned ones on words that tell the two apart), and SCC after each of the 14 ops that must keep it, set to 1
and to 0 in turn before them.
check.py, derived in the fixture's header.tests/test_gpu_salu_ext.pyrecomputes them from the fixture's own instruction lines with the reference of
tools/salu_diff.pyand checksthat every op that writes SCC is seen with both values.
All 38 ops gave the expected words on both devices, so nothing changes in the translator.
One existing test had to change to let the fixture in. This is the first fixture with bit 15 set in the immediate
of a signed SOPK op (
s_addk_i32 s52, 0x8000).tools/rdna2_decode.pygives that immediate sign-extended(-32768) and llvm-mc 23.1.4 prints the same word as
0x8000, sotest_parity_with_llvm_mc_on_shader_fixturesfailed on it. It now compares the immediates of the ten signed SOPK ops as the 16 bits they are, which is what it
already does for SOPP branch offsets. The encodings are still compared whole, and the translator reads the low
16 bits of either spelling. A new hand-encoded test pins which of the sixteen SOPK ops with an immediate the
decoder sign-extends. The decoder itself is not changed.
Docs: a paragraph in
docs/testing.md; the rows ofs_sext_i32_i8/s_flbit_i32(marked "not GPU-checked"until now) and of
s_lshl1..4_add_u32indocs/design.mdname the fixture.It does not build on #1012, #1034, #1047 or #1063: its case is counted in a different term of
TOTALintests/test_shader_checks.py, and a merge ofmain, this branch and those four passes that file.Tested
RTX 4070 Ti (NVIDIA 620.70.06, Linux) and llvmpipe (Mesa 26.2.6, LLVM 23.1.4); llvm-mc 23.1.4, SPIRV-Tools v2026.4.
python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_salu_ext --require-pass:80 words exact (73 results of 38 scalar ops and the untouched fill)on both devices, natively and withLEONIDA_W64_EMULATE=1.17 skipped with
LEONIDA_W64_EMULATE=1; none failed.s_ashr_i32shifting inzeros (word 8),
s_lshlN_add_u32taking SCC from the add's carry alone (word 69),s_abs_i32negating(word 17),
s_mulk_i32ands_addk_i32zero-extending their immediate (words 37 and 21),s_cmovk_i32ignoring SCC (word 38), the 64-bit shifts taking their count modulo 32 and
s_ashr_i64shifting in zeros(word 51 each), and the 64-bit shifts taking SCC from the low dword alone (word 72).
python -I tests/test_gpu_salu_ext.py(13 tests),tests/test_shader_checks.py(87),tests/test_run_gpu_tests.py(64) and
tests/test_rdna2_decode.py(20; before the change its parity test failed atcs_w32_salu_ext.asm: s_addk_i32).s_addk_i32, and sign-extendings_cmpk_gt_u32as well, each fail the new test; one wrong low bit in theimmediate of
s_mulk_i32still fails the parity test atcs_w32_salu_ext.asm: s_mulk_i32.tests/withpython -I(490 files): all pass.python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6168 tests, 0 files failed.python -I scripts/check_no_game_data.pyon the eight changed files, andpython -m compileall.Not run: llvm-mc 19 (the version CI uses), Windows, and an AMD or Intel GPU.
GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); llvmpipe (Mesa 26.2.6, LLVM 23.1.4)
AI-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; two rows now name the GPU fixture.)🤖 Generated with Claude Code
@abnalstlll-byte on GitHub · 2026-11-24 18:48 UTC · original · approved these changes
Reviewed and verified. Excellent fixture coverage in cs_w32_salu_ext.asm exercising 38 scalar ALU operations using dynamic runtime operands from s4..s19 via VKC_SGPRS, successfully bypassing static constant folding. Validates SCC write/preserve invariants across all 38 ops. Decoder parity adjustment for signed 16-bit SOPK immediates in est_rdna2_decode.py is sound. 100% clean room compliant.
@madhyn on GitHub · 2026-11-24 19:23 UTC · original
Tested
cec2c7074on Arch Linux + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan):python3 -m unittest tests/test_gpu_salu_ext.py tests/test_shader_checks.py: 104 tests passedpython3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w32_salu_ext --require-pass(native): 1/1 passed (80 words exact (73 results of 38 scalar ops and the untouched fill))LEONIDA_W64_EMULATE=1 python3 scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w32_salu_ext --require-pass: 1/1 passed (80 words exact)AI-assisted: yes
@Deedlyy on GitHub · 2026-11-24 20:16 UTC · original
Recommendation: [MERGE]
Reasoning: Adds a GPU readback fixture covering 38 scalar ALU ops that had no GPU coverage, plus checker/decoder test updates and docs. Test-only expansion (+879); no translator behaviour change. Verified by madhyn on RTX 3060 Ti (104 unit tests plus the GPU run). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with
main. Merge once the queued checks are green.Impact level: 3/10
@milk4sale on GitHub · 2026-11-25 02:55 UTC · original
Local stand-in for this pull request's CI, which has been queued here since 22:31 UTC (about 580 runs waiting).
Tested:
0c3acdc03merged withmainb4b7756e8(2026-11-25 01:13 UTC), in one tree together with #1087, #1089, #1090, #413, next tomainalone. The trees came fromgit merge-tree, and nothing was pushed. Each job used the workflow's own selection fromci.ymlandruntime.yml.main+ the five pull requestsmainalonechecksteps: compileall,make_game.py --helpstdlib-tests-linux(every standalone file, run to the end)translator-tests(pytest files)viewer-testssemantic-testslinux-gpu-tools: ctestlinux-gpu-tools:run_gpu_tests.py, plain,LEONIDA_W64_EMULATE=1 --filter cs_,LEONIDA_BARY_FALLBACK=1no-game-data:scripts/check_no_game_data.pyon this pull request's filesThis pull request's fixture,
cs_w32_salu_ext, passes in all three passes on both devices (80 words exact), andtests/test_gpu_salu_ext.py,tests/test_rdna2_decode.pyandtests/test_shader_checks.pypass.The two pytest failures are
main's:tests/test_translate.pyon the text-only fixturecs_dpp_cmp.asm(test_gpu_samples_translate_and_validate,test_wave64_emulate_uses_no_subgroup_ops). With #1375 applied, both pass.Not covered: the Windows and macOS jobs.
Setup: Linux (CachyOS), Python 3.14.10 (CI uses 3.12), llvm-mc 23.1.4 (CI uses 19), Node 26.13.1. GPU suite on lavapipe from Mesa 26.2.6 with
GALLIUM_OVERRIDE_CPU_CAPS=avx, the code path of CI's runners, which lack AVX-512; and on an RTX 4070 Ti, NVIDIA 620.70.06.AI-assisted (Claude Code).
@adrianmjim on GitHub · 2026-11-25 06:32 UTC · original
Post-merge note. I tested
cec2c7074applied onto main66d4f5aa3; the fixture andtests/test_gpu_salu_ext.pydid not change between that head and the merged0c3acdc03. Setup: AMD Radeon RX 7900 XT (RDNA3, gfx1100), AMD proprietary driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, Vulkan SDK 1.4.363.0, llvm-mc 23.1.5. No game files.cs_w32_salu_ext: PASS,80 words exact, natively and withLEONIDA_W64_EMULATE=1. The whole GPU suite gives 237/253 passed, 16 skipped, 0 failed, against 236/252 onmain; the only difference is the new pass.Two small follow-ups, both still true on
main42537e7b6:s_mul_hi_u32,s_pack_hh_b32_b16,s_bitset0_b32ands_mulk_i32each run once, with SCC = 1 and a non-zero result. A translator that wrongly wrote SCC = (D != 0) on one of them would leave word 71 unchanged. Running each once more with SCC = 0 would catch it.docs/design.mdrow for scalar select and pack still sayss_cmovk_i32,s_cmov_b64and the others_pack_*forms have no GPU test on main. This fixture now coverss_cmovk_i32,s_cmov_b64,s_pack_ll_b32_b16ands_pack_hh_b32_b16. That row also repeats several sentences, apparently from merges.