mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:20:53 +01:00
[PR #1114] [MERGED] tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-EXT) #1149
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#1149
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/1114
Author: @milk4sale
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @ubiquitarianism
Base:
main← Head:gpu-test/salu-ext📝 Commits (2)
cec2c70tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-EXT)0c3acdcMerge main into gpu-test/salu-ext📊 Changes
8 files changed (+879 additions, -5 deletions)
View changed files
📝
docs/design.md(+2 -2)📝
docs/testing.md(+22 -0)📝
runtime/test/shaders/check.py(+28 -0)➕
runtime/test/shaders/cs_w32_salu_ext.asm(+516 -0)📝
scripts/run_gpu_tests.py(+5 -0)➕
tests/test_gpu_salu_ext.py(+270 -0)📝
tests/test_rdna2_decode.py(+26 -1)📝
tests/test_shader_checks.py(+10 -2)📄 Description
Claimed in the coordination issue as: GPU-SALU-EXT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140488039)
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.