upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/testing.md
diff options
context:
space:
mode:
authormilk4sale <53350507+milk4sale@users.noreply.github.com>2026-11-24 12:30:40 -0600
committermilk4sale <53350507+milk4sale@users.noreply.github.com>2026-11-24 12:40:29 -0600
commitcec2c7074c8b086b28d276f573573c22899200af (patch)
tree1b2db7f56b461719293c0522026f54d70eb41027 /docs/testing.md
parent6293c1c4f88c7ea2088ec595fea51362f1759996 (diff)
tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-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>
Diffstat (limited to 'docs/testing.md')
-rw-r--r--docs/testing.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/testing.md b/docs/testing.md
index f8246f888..079145bf3 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -336,6 +336,28 @@ on an Apple M3 Max (MoltenVK 1.4.2 and 1.4.3): 17 workgroup shapes from 1 to 102
336subgroups, with and without full subgroups and register pressure, all 32 lanes in order. A device whose default 336subgroups, with and without full subgroups and register pressure, all 32 lanes in order. A device whose default
337isn't the requested size still prints `not available`, and those tests skip. 337isn't the requested size still prints `not available`, and those tests skip.
338 338
339`cs_w32_salu_ext` runs 38 scalar ALU ops that no other fixture runs: `s_sub_i32`, `s_andn2_b32`, `s_orn2_b32`,
340`s_xor_b32`, `s_ashr_i32`, `s_mul_hi_u32`, `s_lshl3_add_u32`, `s_lshl4_add_u32`, `s_pack_ll_b32_b16`,
341`s_pack_hh_b32_b16`, `s_abs_i32`, `s_bcnt0_i32_b32`, `s_bitset0_b32`, `s_bitset1_b32`, `s_brev_b32`, `s_flbit_i32`,
342`s_flbit_i32_b32`, `s_sext_i32_i8`, the six `s_cmp_*_i32`, `s_cmp_gt_u32`, `s_cmp_le_u32`, `s_bitcmp0_b32`,
343`s_bitcmp1_b32`, `s_addk_i32`, `s_mulk_i32`, `s_cmovk_i32`, `s_ashr_i64`, `s_lshl_b64`, `s_lshr_b64`,
344`s_bcnt0_i32_b64`, `s_bitset0_b64`, `s_cmov_b64` and `s_ff0_i32_b64`. Its sixteen operand words arrive in `s4..s19`
345through `VKC_SGPRS`, so each op reaches the driver as SPIR-V: a scalar op on literals is folded by the translator
346(the "Chained scalar constant folding" row of [design.md](design.md)) and only its result is stored. One thread stores
347every destination and four words of SCC bits: SCC after each op that writes it, each run on operands that set it
348and on operands that clear it; each compare and bit test both ways, the signed and the unsigned ones on words that
349tell the two apart; and SCC after each op that must keep it, set to 1 and to 0 in turn before them. The 73 expected
350words are literals in `check.py`, derived in the fixture's header, and `tests/test_gpu_salu_ext.py` recomputes them
351from the fixture's own instruction lines with the reference of `tools/salu_diff.py`, the model that was compared
352with hardware. Both GPU runners compare the whole 80-word heap, the untouched fill after the results included. Run
353it alone with `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_salu_ext --require-pass`.
354On an RTX 4070 Ti (NVIDIA 620.70.06, Linux) and on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) all 80 words match. Nine
355translator rules broken one at a time each failed it on both: `s_ashr_i32` shifting in zeros (word 8),
356`s_lshlN_add_u32` taking SCC from the add's carry alone (word 69), `s_abs_i32` negating (word 17), `s_mulk_i32` and
357`s_addk_i32` zero-extending their immediate (words 37 and 21), `s_cmovk_i32` ignoring SCC (word 38), the 64-bit
358shifts taking their count modulo 32 and `s_ashr_i64` shifting in zeros (word 51), and the 64-bit shifts taking SCC
359from the low dword alone (word 72).
360
339`cs_w32_shift64` checks `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64` with 64 memory-fed cases: 361`cs_w32_shift64` checks `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64` with 64 memory-fed cases:
340eight boundary values crossed with counts 0, 1, 31, 32, 33, 63, 64 and 65. The expected values come from Python 362eight boundary values crossed with counts 0, 1, 31, 32, 33, 63, 64 and 65. The expected values come from Python
341integers using the low six count bits, as specified by the [RDNA2 ISA, VOP3 opcodes 767–769](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). 363integers using the low six count bits, as specified by the [RDNA2 ISA, VOP3 opcodes 767–769](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content).