Skip to content

test(shader): GPU test for v_dot4_i32_i8, v_dot4c_i32_i8 and the carry forms - #2311

Open
evilclanker9000 wants to merge 6 commits into
ItsNotRexed:mainfrom
evilclanker9000:test/gpu-dot4-carry
Open

evilclanker9000 wants to merge 6 commits into
ItsNotRexed:mainfrom
evilclanker9000:test/gpu-dot4-carry

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-GPU-DOT4-CARRY, #2078 (comment)

What and why

v_dot4_i32_i8, v_dot4c_i32_i8, v_add_co_u32, v_add_co_ci_u32, v_sub_co_u32, v_sub_co_ci_u32 and v_subrev_co_u32 (also with VOP3 clamp) were only CPU-tested. This adds one wave32 GPU test, cs_w32_dot4_carry, that dumps 456 words:

  • dot products with signed bytes 0x80, 0x7f, 0xff, addend overflow past 2^31 for both forms, SGPR sources, v_dot4c accumulating twice, and v_dot4c per lane;
  • per-lane results of each carry op, with the carry-in taken from the SGPR mask 0x5a5a5a5a (so it differs per lane), a three-stage carry ripple through vcc_lo, and the four clamp forms;
  • one flag word per lane with each lane's carry/borrow bits (read back with v_cndmask_b32_e64, so the check does not depend on how a mask SGPR reads as data).

The .asm header derives every word from the ISA pseudocode. gfx10 has no VOP2 v_*_co_u32, so the plain forms are VOP3 with vcc_lo as carry-out. The same shader is a semantic fixture (test_dot4_carry_fixture.py: hand constants plus a plain-Python model). I did not use VCC holding data as a carry-in mask (that is #2206's area). Dot4 clamp/op_sel are refused by the translator, so they are not tested. No translator change; docs/design.md gets a sentence on the dot4 row.

Tested

  • RTX 5080 (driver 616.92) and AMD Radeon iGPU (driver 26.10.1), wave32: run_gpu_tests.py --filter cs_w32_dot4_carry 456/456 words exact on both.
  • Negative controls (each fails the test, then reverted): OpBitFieldSExtract -> UExtract on the first dot4 operand (RTX 5080: word 0 expected 0x00010000, got 0xffff0000; the CPU fixture fails too); carry-in ignored in the *_co_ci ops (Radeon: word 73); clamp ignored on the carry ops (Radeon: word 312).
  • python -m unittest discover -s tests/semantic OK (1673 tests); regen_fixtures.py --check clean; python -I tests/test_shader_checks.py OK.

Checklist

  • Hand-written expected words with derivation
  • Negative control shown
  • No game data

AI-assisted.

…(cs_w32_dot4_carry)

Per-lane wave32 dump of signed dot products and v_add/sub/subrev_co(_ci)_u32 with SGPR carry-in, a carry ripple and clamp; same shader as a semantic fixture.

AI-assisted.
@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 55071e6b78de75dc8fbf92a0aeaac6ede64ad267 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent Vulkan check of 55071e6b78de75dc8fbf92a0aeaac6ede64ad267 on NVIDIA GeForce RTX 5090 (595.99.02, Linux 7.0.0-43-generic, LLVM 21.1.8, SPIRV-Tools v2026.1). AI-assisted. Synthetic input only.

Rebuilt the harnesses from this head and ran scripts/run_gpu_tests.py --filter cs_w32_dot4_carry. The fixture translated, passed SPIR-V validation, and matched all 456 dumped words. This covers both signed-byte dot-product forms, the lane-dependent carry and borrow cases, the carry chain, and the clamp variants in the fixture.

Both targeted CPU semantic tests, all 60 shader-check tests, and fixture regeneration passed.

AI-assisted verification.

@emirduran707

Copy link
Copy Markdown
Contributor

Tested 55071e6 on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44 (LLPC, Vulkan driver 2.0.395), Windows 11 Pro 10.0.26300, subgroup 32..64: pass.

  • python -I scripts/run_gpu_tests.py --build <build> --filter cs_w32_dot4_carry: PASS cs_w32_dot4_carry 456/456 dumped words exact. Same with LEONIDA_W64_EMULATE=1.
  • Whole suite (native wave64): 191 shaders translated, 191 pass spirv-val; 171/186 passed, 15 skipped, 0 failed. The skips are the 14 fixtures the d3d12_* tests run, and ps_w64x_readlane (skipped on main too, see check.py: judge ps_w64x_readlane where vk_harness required 64 (its line has no "required") #2085; not from this PR).
  • build.py + check.py: 205 shaders translated, 205 pass spirv-val; 160 of 164 pass, 4 skipped (the 3 mesh fixtures and ps_w64x_readlane); cs_w32_dot4_carry ok.
  • CPU: python -I -m unittest discover -s tests/semantic -p test_dot4_carry_fixture.py 2 OK, tests/test_shader_checks.py 60 OK, tests/test_run_gpu_tests.py 30 OK, tests/semantic/regen_fixtures.py --check clean.

Test programs: an MSVC 14.44 build of 4947579, this PR's base. The PR changes no C++ or CMake, so they are what its head builds; the translator, runner and check.py are this PR's. llvm-mc 21.1.8 (native), Vulkan SDK 1.4.363.0.

The check above is NVIDIA (32-wide); this one is an AMD card with native 64-wide subgroups, RDNA4. No negative control run here. No game files. AI-assisted (Claude Code).

@lunisahdidouch

Copy link
Copy Markdown

Tested 55071e6 on an RX 9070 (RDNA4), AMD 26.11.1 (LLPC), Vulkan 1.4.359, Windows 11: pass

Full run_gpu_tests.py run with native wave64: 171/186 passed, 15 skipped, nothing failed. cs_w32_dot4_carry passes with 456/456 words exact, and everything else is the same as on main 4947579.

AI-assisted

Conflicts:
	runtime/test/shaders/check.py
	scripts/run_gpu_tests.py
	tests/test_shader_checks.py

AI-assisted.
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py
tests/test_shader_checks.py

AI-assisted.
@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 960a6be7 (the rebased head) on NVIDIA GeForce RTX 3060 Ti (subgroup 32..32), driver 580.173.02, Linux (kernel 6.18), Python 3.14: pass.

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed. cs_w32_dot4_carry: 456/456 dumped words exact.
  • ctest: 47/47 passed.
  • pytest tests/semantic/test_dot4_carry_fixture.py tests/test_shader_checks.py: 81 passed, 686 subtests passed.

No game files. AI-assisted (Claude Code).

@amarovndres

Copy link
Copy Markdown

Tested 960a6be7 on AMD Radeon RX 9060 XT (RDNA4, discrete, subgroup 32..64), AMD 26.10.1 (32.0.32015.7029, LLPC, Vulkan 1.4.359), Windows 11 Pro (build 26200): pass.

  • scripts/run_gpu_tests.py (full suite; test programs built from this head with llvm-mingw, llvm-mc 23.1.6): 197/211 passed, 14 skipped, 0 failed. main d0835dd9 on the same machine: 196/210 passed, 14 skipped.
    • PASS cs_w32_dot4_carry 456/456 dumped words exact
    • PASS cs_w32_dot4_carry 64/64 dumped words exact
  • tests/semantic/test_dot4_carry_fixture.py: 2 tests, OK
  • tests/test_shader_checks.py: 75 tests, OK

AI-assisted (Claude Code). Synthetic shaders only, no game files.

@throny

throny commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 960a6be on NVIDIA RTX 4080, driver 610.88, Windows 11: pass

This is the head rebased on aa2988cc. Ran (MSVC 19.44 / VS 2022 BuildTools, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0, native llvm-mc 23.1.6; this PR has no runtime C++ change, so the test programs were built from the aa2988cc tree):

  • python -I scripts/run_gpu_tests.py --build <build>: 165/211 passed, 46 skipped, 0 failed. cs_w32_dot4_carry PASS, 456/456 and 64/64 dumped words exact.
  • test_dot4_carry_fixture (run from tests/semantic): 2 tests OK.

AI-assisted.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 960a6be7 (merge base aa2988cc) on an NVIDIA GeForce RTX 5070 Ti (Blackwell, subgroup 32..32), driver 616.56, Windows 11 10.0.26300. Runtime test programs were built from main aa2988cc (MSVC 19.44); spirv-as/spirv-val and llvm-mc 21 came from WSL Ubuntu. Result: fail. The cause is in the harness, not the GPU or the translator.

  • The head moved to 89c15aaa (a main merge) while this ran. The same lines are still there at 89c15aaa:scripts/run_gpu_tests.py:908-910, so the result below holds for it too.
  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed. But cs_fmt_sint32 (PASS on main) is missing from the report, and cs_w32_dot4_carry is listed twice: once 456/456 dumped words exact and once 64/64 dumped words exact.
  • Cause: the new elif name == "cs_w32_dot4_carry": block was inserted between problem = fmt_sint32_test(...) and that branch's results.append(...). So cs_fmt_sint32 still runs, but its result is never recorded, and a failure there would not show up. Its results.append ended up under the dot4 branch, labelled "64/64". Moving that one line back above the new elif fixes it. The same slip is on Tests: xy/xyz typed buffer formats, DST_SEL and bounds on the GPU; add 32_32_32_UINT #1529, and in main's cs_tbuffer_store row, which I claimed on Coordinating who works on what (24) (moved to #4683) #4571 and will fix with a guard that fails a run when a name is recorded twice.
  • The new cs_w32_dot4_carry itself passes: 456/456 dumped words exact. Every other result matches main aa2988cc test by test.

Not run: LEONIDA_W64_EMULATE=1, other vendors. No game files.

AI-assisted (Claude Code).

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 / MoltenVK validation of head 89c15aaa (hardware reports Apple M2 / Mac14,3, not M1), macOS 26.4, MoltenVK 1.4.2, subgroup range 4..32, llvm-mc 23.1.6. Python/translator-only change; the C++ harness was built once from the shared base 3eb4410b for a clean A/B.

  • New GPU fixture cs_w32_dot4_carry PASS: cs_w32_dot4_carry 456/456 dumped words exact
  • Full suite on the PR head: 217 shaders translated, 217 pass spirv-val; 153/218 passed, 58 skipped, 7 failed (the known MoltenVK expected set). Base 3eb4410b with the identical harness: 152/217, 58 skipped, 7 failed. The only difference is this PR's new passing fixture; no common test changed status in either direction.

No code changes, no game data; synthetic fixture and counts only.

AI-assisted.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 89c15aa (merge base 7b7d73f) on NVIDIA GeForce RTX 5080, Linux 580.65.06: fail

Tested the PR head merged with current main 7b7d73f8 (clean merge, not pushed). Runtime harnesses built from main 7b7d73f8, llvm-mc 21, Python 3.13, Vulkan SDK 1.4.363, Linux native.

Check main 7b7d73f8 this PR
run_gpu_tests.py native 170/217 passed, 47 skipped 171/218 passed, 47 skipped
run_gpu_tests.py with LEONIDA_W64_EMULATE=1 201/217 passed, 16 skipped 202/218 passed, 16 skipped
failed (native / emulated) 0 / 0 0 / 0
tests/semantic/regen_fixtures.py --check ok ok
pytest tests/semantic/test_dot4_carry_fixture.py tests/test_find_hash_lookup.py tests/test_first_look_shim_report.py tests/test_shader_checks.py tests/test_shader_checks.py tests/test_run_gpu_tests.py tests/test_cf_diff.py 162 passed, 315 subtests passed (3 shared files) 168 passed, 1 skipped, 771 subtests passed in 9.00s

Line-by-line against my main run (results that differ from main):

  • native:
    • cs_fmt_sint32 main: PASS pr: -
    • cs_w32_dot4_carry main: - pr: PASS 64/64 dumped words exact
  • emulated:
    • cs_fmt_sint32 main: PASS pr: -
    • cs_w32_dot4_carry main: - pr: PASS 64/64 dumped words exact

Why fail: a bug in the PR's scripts/run_gpu_tests.py hunk, not a GPU mismatch. The new elif name == "cs_w32_dot4_carry": block was inserted between the existing problem = fmt_sint32_test(...) line of the cs_fmt_sint32 branch and that branch's results.append(...) line. So the PR has that results.append (with the "64/64 dumped words exact" text) under cs_w32_dot4_carry a second time and none under cs_fmt_sint32. Effect on the RTX 5080: the existing cs_fmt_sint32 result disappears from the report (main has it as PASS), and cs_w32_dot4_carry is printed twice (456/456 dumped words exact, then a bogus 64/64 dumped words exact), so the counts are 171/218 instead of 172/218. The new cs_w32_dot4_carry itself is exact: 456/456 dumped words, native and emulated. Minimal fix: move the line results.append((name, not problem, problem or "64/64 dumped words exact")) back up to directly under problem = fmt_sint32_test(a.build, spirv_dir, cs_env), above the new elif.

Not run: the full unittest discover -s tests/semantic (about 6 minutes, and main alone has failures there); only the test files this PR touches plus the shared checker tests ran. No other GPU vendor, no Windows. No game files.

AI-assisted (Claude Code).

@tylerstraub

Copy link
Copy Markdown
Contributor

Replying to @tedin7.

I verified the failure-reporting consequence on the unmerged PR head 89c15aaa, using a Linux RTX 5090 (595.99.02) and harnesses built from that head. In a temporary copy I changed only the first expected word for cs_fmt_sint32 from 0x80000000 to 0x80000001.

  • With the original runner, --filter cs_fmt_ exited successfully with 5/5 passed. It omitted cs_fmt_sint32 and printed two rows for cs_fmt_d16_xyz. Filtering to cs_fmt_sint32 alone exited with “no runnable GPU test cases.”
  • After moving the misplaced 64-word result append as proposed above, the isolated fixture correctly failed on word 0 (expected 0x80000001, got 0x80000000). Restoring the expected word gave exactly one PASS row for that fixture (64/64) and one for cs_w32_dot4_carry (456/456) in their respective filtered runs.

For regression coverage, asserting that each selected fixture appears exactly once would catch the missing and duplicated rows even when the total looks right.

AI-assisted verification.

AI-assisted.

tunczzz added a commit to tunczzz/Leonida that referenced this pull request Nov 23, 2026
…rds a test twice

The merge 3eb80d7 (in main since 66ff7cb) left the cs_tbuffer_store branch of run_suite without its
results.append: the line sat under cs_fmt_d16_xyz, which then recorded two rows. A full run listed
cs_fmt_d16_xyz twice and no cs_tbuffer_store, so a tbuffer_store failure changed neither the report nor
the exit code. Open PRs ItsNotRexed#1529 and ItsNotRexed#2311 repeat the slip for cs_fmt_xy_xyz and cs_fmt_sint32.

Move the line back, and make run_suite exit 1 with an error when a test name is recorded more than once:
each test records one row, and every case of this slip shows up as a duplicate. Unit tests run each
one-function format row with a failing and a passing checker and require exactly one row.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants