Skip to content

GPU fixture for the packed integer dot products (cs_w32_dot_int) - #9781

Open
Joaco9020 wants to merge 3 commits into
ProjectLeonida:mainfrom
Joaco9020:gpu-fixture-int-dot
Open

Joaco9020 wants to merge 3 commits into
ProjectLeonida:mainfrom
Joaco9020:gpu-fixture-int-dot

Conversation

@Joaco9020

@Joaco9020 Joaco9020 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claim: #9522 (comment) (new TEST item)

Re-submission of #9672, which was closed in the PR cleanup. It builds on #7237 by @xelerb-debug (also closed in the cleanup): that PR's two commits, the ; mcpu: fixture header and its cs_global_csub fixture, are included here unchanged and keep @xelerb-debug as their author; this PR's own change is the last commit. If #7237 is re-opened and merged first, this reduces to that last commit.

What and why

docs/design.md's "Packed integer dot products" row is CPU-checked (tests/semantic) and measured with tools/hw_oracle, but no checked-in fixture runs the translation of v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_u32_u8, v_dot8_i32_i4 or v_dot8_u32_u4 on a GPU.

runtime/test/shaders/cs_w32_dot_int.asm is a wave32 dump like cs_w32_new_ops / cs_w32_dot2_f16: lane 0 stores eight words, each derived in the file header from the row's rule (element products + S2, sign- or zero-extended elements, 32-bit wrap; clamp saturates the exact sum):

out instruction operands value
0 v_dot2_i32_i16 0x0003fffe, 0x0005fff9, 100 (-2)(-7) + 3·5 + 100 = 129
1 v_dot2_u32_u16 0xffff8001, 0xffff0003, 0xffffff00 wraps once: 0xffff7f04
2 v_dot4_u32_u8 0x80ff0102, 0x7f02ff03, 5 17032
3 v_dot8_i32_i4 0x8f01f7a3, 0x12345678, -3 -38
4 v_dot8_u32_u4 same, 7 260
5 v_dot2_u32_u16 … clamp all 0xffffffff saturates: 0xffffffff
6 v_dot2_i32_i16 … clamp 0x80008000 twice, -2 2^31 - 2 = 0x7ffffffe: the products overflow, the sum does not, so no saturation
7 v_dot2_i32_i16 … clamp 0x80008000 twice, 0 saturates: 0x7fffffff

Out 1 and 3/4 use the same bits signed and unsigned, so a signedness mix-up changes a word; out 6 vs 7 checks that clamp saturates the exact sum, not a wrapped one.

Registered in check.py (WAVE32_DUMPS + expected words) and run_gpu_tests.py (the three wave32 lists). The design row gets one sentence. The VOP2 v_dot*c_* forms don't assemble with llvm-mc for gfx1013 or gfx1030, so they stay CPU-checked; the sentence says so.

Tested

Windows 11, NVIDIA GeForce RTX 3070 (Ampere), driver 621.01, MSVC 19.44 (VS 2022 Build Tools), Vulkan SDK 1.4.363.1, llvm-mc 23.1.6 (conda-forge, AMDGPU), Python 3.12.10, on this branch (rebased onto main 2d53a8055):

AMD: @ThomasSAMP ran it on an RX 9070 XT (RDNA4, Windows): the same eight words, plus a negative control (a zero-extended v_dot8_i32_i4 changes only out[3]); see the comments. An RDNA2 run is still open.

AI-assisted: yes (Claude).

🤖 Generated with Claude Code

xelerb-debug and others added 3 commits November 23, 2026 20:06
…u:" fixture header

The GPU fixture runners assemble every .asm for gfx1013, which has no GFX10.3 instructions: llvm-mc rejects
global_atomic_csub and buffer_atomic_csub there, so the csub rows of docs/design.md could get no GPU check. A
fixture may now name its target in the leading comment ("; mcpu: gfx1030"), next to "; mattr:", in
scripts/run_gpu_tests.py, runtime/test/shaders/build.py and the decoder parity test; without it nothing changes.

cs_global_csub.asm runs both forms on a few seeded dwords (DATA above, equal to and below M, 0xffffffff on
0x80000000, no glc with the data register kept) and 32 lanes of one wave subtracting 1 from 20 at once (old values
20..1 then 0 twelve times, M ends at 0). Passes on an RTX 4060 (NVIDIA 621.01) through both runners; the translator
with the clamp removed, or with a signed compare, fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
conftest.Shader, which tests/test_translate.py uses for every runtime/test/shaders/*.asm, still assembled for
gfx1013 only, so test_gpu_samples_translate_and_validate and test_wave64_emulate_uses_no_subgroup_ops failed on
cs_global_csub.asm (found by @tikD1337 in review). It now reads "; mcpu:" and "; mattr:" the way build.py and
run_gpu_tests.py do. tests/test_translate.py: 647 passed (both cases failed without this change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_u32_u8, v_dot8_i32_i4 and
v_dot8_u32_u4 were CPU-checked and measured with hw_oracle, but no fixture
ran the translation on a GPU. A wave32 dump of eight words covers the signed
and unsigned elements, the 32-bit wrap, u32 and i32 clamp saturation, and the
clamp case whose products overflow while the sum stays below INT32_MAX.
Assembled for gfx1030 through ProjectLeonida#7237's "; mcpu:" header (gfx1013 has no dot
instructions). Registered in check.py and run_gpu_tests.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@djasdh

djasdh commented Nov 23, 2026

Copy link
Copy Markdown

Tested d24ef7559 on AMD Radeon RX 6900 XT (RDNA2, gfx1030), RADV NAVI21, Mesa 26.3.1-arch1.2, Vulkan 1.4.363, Linux 7.3.5, Python 3.14.10, llvm-mc 23.1.5 (AMDGPU), on this branch:

  • python -I scripts/run_gpu_tests.py --build <cmake build> --filter cs_w32_dot --require-pass: translate 1/1, spirv-val pass, GPU PASS — 129 4294934276 17032 4294967258 260 4294967295 2147483646 2147483647. All eight words as derived in the file header, including the clamp pair (out 6 keeps 0x7ffffffe because the exact sum does not overflow, out 7 saturates to 0x7fffffff).
  • Negative control: the same fixture with out[3]'s v_dot8_i32_i4 replaced by v_dot8_u32_u4 gives out[3] = 250 and leaves out[0..2] and out[4..7] byte-identical, so the signed/unsigned nibble split is what the fixture pins, not an artefact of identical operands elsewhere.

That is the RDNA2 run the description lists as still open; the RDNA4 numbers from @ThomasSAMP reproduce here for the same eight words.

AI-assisted.

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Tested d24ef7559 (on main 2d53a8055) on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5), Mesa 25.2.8, Ubuntu 24.04, runtime rebuilt from this branch in a clean sandbox: the two new fixtures pass.

  • cs_w32_dot_int: 129 4294934276 17032 4294967258 260 4294967295 2147483646 2147483647 (the eight header cases: signed/unsigned element products, 32-bit wrap, both clamp saturations)
  • cs_global_csub: 0x10070905 0xd070000 0x630064 0x80000000 0x0 0xfffffffe 0xc0500 0x1d800d2
  • scripts/run_gpu_tests.py: 228/250 passed, 17 skipped. The five failures (cs_w32_salu64, cs_imgload_tfe, cs_imgload_d16_tfe, cs_w32_exec_computed, cs_w64_exec_computed) are the same as on plain main
  • CPU: tests/test_rdna2_decode.py 17 OK (1 skipped), tests/semantic/test_alu_dot_complete.py 9 OK, tests/semantic/test_atomic_csub.py 6 OK, tests/test_run_gpu_tests.py 62 OK
  • python3 -I scripts/check_no_game_data.py on the eight changed files: clean

; mcpu: gfx1030 is what lets llvm-mc assemble these (gfx1013 has none of the opcodes). Nothing else to report.

AI-assisted.

@DaviTostes

Copy link
Copy Markdown

Tested d24ef7559 (base 2d53a8055) on AMD Radeon RX 9060 XT (RDNA4, gfx1200), RADV Mesa 26.3.1, Vulkan 1.4.363, Linux 7.3.5, llvm-mc 23.1.5: pass, no new failure.

  • scripts/run_gpu_tests.py --filter cs_w32_dot_int: PASS with the derived words: 129 4294934276 17032 4294967258 260 4294967295 2147483646 2147483647, 1/1; cs_global_csub also passes.
  • Full scripts/run_gpu_tests.py: 229/250 passed, 16 skipped, 257/257 fixtures translated and pass spirv-val.
  • Five failures, but four of them are on 2d53a8055 itself in this environment: cs_imgload_d16_tfe and cs_imgload_tfe (exit 1) and cs_w32_exec_computed / cs_w64_exec_computed (same words on base), so they are not from this branch. The fifth is the known ms_wave_info_s3 flake.

The fixture's words are exact on this RADV/RDNA4 card.

Counts and pass/fail only; no game files. AI-assisted (DeepSeek V4.1 Flash coding agent).

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.

5 participants