Repository navigation
tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-EXT) - #1114
Conversation
…ALU-EXT) No fixture in runtime/test/shaders ran 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 six s_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_b64 or s_ff0_i32_b64. cs_w32_salu_ext gets sixteen operand words in s4..s19 from VKC_SGPRS, so each op reaches the driver as SPIR-V and is not folded by the translator as an op on literals is. One thread stores every destination and four words of SCC bits: SCC after each op that writes it, run on operands that set it and on operands that clear it, each compare both ways, and SCC after each op that must keep it, set to 1 and to 0 in turn before them. The 73 expected words are literals in check.py, derived in the fixture's header. tests/test_gpu_salu_ext.py recomputes them from the fixture's own instruction lines with the reference of tools/salu_diff.py, checks that every op that writes SCC is seen with both values, and checks the readback and both runners' verdicts. The fixture is the first in the folder with bit 15 set in the immediate of a signed SOPK op (s_addk_i32 s52, 0x8000). tools/rdna2_decode.py gives that immediate sign-extended and llvm-mc 23.1.4 prints the same word as 0x8000, so test_parity_with_llvm_mc_on_shader_fixtures failed on it. That test now compares the immediates of the ten signed SOPK ops as the 16 bits they are, as it already does for SOPP branch offsets, and a hand-encoded test pins which of the sixteen ops the decoder sign-extends. No translator, decoder or runtime change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
abnalstlll-byte
left a comment
There was a problem hiding this comment.
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.
|
Tested
AI-assisted: yes |
|
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 Impact level: 3/10 |
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>
Fourteen commits main gained after ProjectLeonida#968: ProjectLeonida#413, ProjectLeonida#1114, ProjectLeonida#1090 and ProjectLeonida#1491. Two conflicts, both in the shader check lists: scripts/run_gpu_tests.py imports both sides' cases, and tests/test_shader_checks.py counts eight cases next to COMPUTE (main's cs_w32_salu_ext) and ProjectLeonida#939's IMAGE_STORE_CASES table in place of main's fixed seven store shaders. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Local stand-in for this pull request's CI, which has been queued here since 22:31 UTC (about 580 runs waiting). Tested:
This pull request's fixture, The two pytest failures are 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 AI-assisted (Claude Code). |
|
Post-merge note. I tested cec2c70 applied onto main 66d4f5a; the fixture and
Two small follow-ups, both still true on
|
Claimed in the coordination issue as: GPU-SALU-EXT (#14 (comment))
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