Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/design.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,28 @@ on an Apple M3 Max (MoltenVK 1.4.2 and 1.4.3): 17 workgroup shapes from 1 to 102
subgroups, with and without full subgroups and register pressure, all 32 lanes in order. A device whose default
isn't the requested size still prints `not available`, and those tests skip.

`cs_w32_salu_ext` runs 38 scalar ALU ops that no other fixture runs: `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` and `s_ff0_i32_b64`. Its sixteen operand words arrive in `s4..s19`
through `VKC_SGPRS`, so each op reaches the driver as SPIR-V: a scalar op on literals is folded by the translator
(the "Chained scalar constant folding" row of [design.md](design.md)) and only its result is stored. One thread stores
every destination and four words of SCC bits: SCC after each op that writes it, each run on 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 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, and `tests/test_gpu_salu_ext.py` recomputes them
from the fixture's own instruction lines with the reference of `tools/salu_diff.py`, the model that was compared
with hardware. Both GPU runners compare the whole 80-word heap, the untouched fill after the results included. Run
it alone with `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_salu_ext --require-pass`.
On 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
translator rules broken one at a time each failed it on both: `s_ashr_i32` shifting in zeros (word 8),
`s_lshlN_add_u32` taking SCC from the add's carry alone (word 69), `s_abs_i32` negating (word 17), `s_mulk_i32` and
`s_addk_i32` zero-extending their immediate (words 37 and 21), `s_cmovk_i32` ignoring SCC (word 38), the 64-bit
shifts taking their count modulo 32 and `s_ashr_i64` shifting in zeros (word 51), and the 64-bit shifts taking SCC
from the low dword alone (word 72).

`cs_w32_shift64` checks `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64` with 64 memory-fed cases:
eight boundary values crossed with counts 0, 1, 31, 32, 33, 63, 64 and 65. The expected values come from Python
integers 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).
Expand Down
28 changes: 28 additions & 0 deletions runtime/test/shaders/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,33 @@ def shift64_test(tools, spirv, env=None):
USER_SGPRS = [0x4F000000, 0xDEADBEEF, 7, 0xFFFFFFFF]
USER_SGPRS_ENV = {"VKC_SGPRS": ",".join(hex(w) for w in USER_SGPRS)}
USER_SGPRS_WORDS = USER_SGPRS + [0xEEEEEEEE] * 4
# cs_w32_salu_ext.asm: the sixteen operand words vk_compute_test puts in s4..s19, and the 73 words the shader stores
# (each derived in its header; tests/test_gpu_salu_ext.py recomputes them with the reference of tools/salu_diff.py).
SALU_EXT_SGPRS = [0x7FFFFFFF, 0x80000000, 0xFFFFFFFF, 0x00000001, 0x12345678, 0xDEADBEEF, 0x0000FF80, 0x00000025,
0x00000040, 0x00000000, 0x00000001, 0x80000001, 0xFFFF0000, 0xFFFFFFFF, 0x00000000, 0x00000047]
SALU_EXT_WORDS = [
0xFFFFFFFF, 0x12345677, 0xCC89A887, 0x00000000, 0x33765778, 0x00000000, 0xCC99E897, 0x00000000,
0xFC000000, 0x00000000, 0x00000000, 0x12345680, 0x01F3266F, 0x00000011, 0x80000000, 0x00000001,
0x00000000, 0x12345678, 0x00000008, 0x00000000, 0x80000000, 0x1233D678, 0x7FFFFFFF, 0x0FD5BDEE,
0xBEEF5678, 0xDEAD1234, 0x1E6A2C48, 0x00000001, 0xFFFFFFFF, 0x0000001F, 0x00000010, 0xFFFFFFFF,
0x00000000, 0xFFFFFF80, 0x00000078, 0xFFFFFFDF, 0x00000020, 0xC962FC98, 0x12345678, 0xFFFF8000,
0x00000040, 0x00000000, 0x00000001, 0x80000001, 0xFFFF0000, 0xFFFFFFDF, 0xFFFFFF7F, 0xFFFFFFFF,
0x00000000, 0x00000020, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x02000000, 0xFF000000, 0x00000000,
0x00000000, 0x00000000, 0x00000020, 0x00000080, 0x00000080, 0x00000000, 0x00000000, 0x07FFFFFF,
0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0x0056D555, 0x000D5555, 0x00555555,
0x0000015B]
SALU_EXT_HEAP_WORDS = 80 # the 73 results, then words that must keep the harness's fill


def salu_ext_test(tools, spirv, env=None):
"""cs_w32_salu_ext: 38 scalar ALU ops on the operands of SALU_EXT_SGPRS, every destination and SCC stored. The
whole 80-word heap is compared: the 73 results and the untouched fill after them."""
child = dict(os.environ if env is None else env, VKC_SGPRS=",".join(f"{w:#x}" for w in SALU_EXT_SGPRS))
child.setdefault("VKC_SUBGROUP_SIZE", str(subgroup_size(spirv, "cs_w32_salu_ext") or 32))
expected = SALU_EXT_WORDS + [0xEEEEEEEE] * (SALU_EXT_HEAP_WORDS - len(SALU_EXT_WORDS))
return dump_test(tools, spirv, "cs_w32_salu_ext", expected, SALU_EXT_HEAP_WORDS, child)


# cs_fma_fused.asm: single-rounded f32 multiply-adds (and one f16). The operands arrive in s4..s7 so no driver can fold
# them; FMA_FUSED are the exact single-rounded words and FMA_SPLIT are the exact split-rounded words (derivations in
# the .asm header; out[7] is f16 round-to-odd, never GLSL Fma, so it is always 0x7351). Under --fma khr
Expand Down Expand Up @@ -1880,6 +1907,7 @@ def main():
results.append((name, compute_test(tools, spirv, name, groups, "dump", expected_words=want)))
results.append(("cs_user_sgprs", compute_test(tools, spirv, "cs_user_sgprs", "1", "dump",
expected_words=USER_SGPRS_WORDS, env=USER_SGPRS_ENV)))
results.append(("cs_w32_salu_ext", salu_ext_test(tools, spirv)))
results.append(("cs_heap_init", compute_test(tools, spirv, "cs_heap_init", "1", "dump",
expected_words=HEAP_INIT_EXPECTED, env=heap_init_env())))
results.append(("cs_w32_shift64", shift64_test(tools, spirv)))
Expand Down
Loading
Loading