Skip to content

GPU fixtures: masked SAD, v_swaprel and s_movrels - #4615

Open
YaBulochka wants to merge 1 commit into
ItsNotRexed:mainfrom
YaBulochka:feat/fixtures-batch2
Open

YaBulochka wants to merge 1 commit into
ItsNotRexed:mainfrom
YaBulochka:feat/fixtures-batch2

Conversation

@YaBulochka

Copy link
Copy Markdown
Contributor

Three GPU fixtures for rows that had no hardware check: masked byte SAD (v_msad_u8, v_mqsad_u32_u8), v_swaprel_b32, and relative SGPR reads (s_movrels_b32, s_movrels_b64).

  • cs_msad_mqsad.asm covers the masked-byte semantics (a zero S1 byte skips that byte), the wrapping 32-bit accumulator, the four sliding windows of v_mqsad_u32_u8, and UMax - UMin on one byte.
  • cs_swaprel.asm swaps VGPR[D + M0[25:16]] with VGPR[S0 + M0[9:0]], with the M0 bits outside the fields ignored and a self-swap case, and checks that untouched registers survive.
  • cs_movrels.asm moves s[D + M0] / s[D + M0 : D + M0 + 1] from a relative source, including an overlapping destination that reads the next register and an s_cselect proving SCC is not disturbed.

All three are registered in check.py and scripts/run_gpu_tests.py (dumps, wave32 list, wave64 exclusions), with semantic fixture disassembly and CPU tests that pin the words against the model. The four docs/design.md rows now name the fixtures and the measured result instead of "Not GPU-verified".

Measured on the RDNA2 iGPU (gfx1036, RADV RAPHAEL_MENDOCINO, Mesa 27.0.0-devel), exact:

cs_msad_mqsad   48 4294967284 4294967290 7 2147483654 305419900 3735928559 255
cs_swaprel      11 22 55 44 77 55 66 88
cs_movrels      170 204 187 204 187 187 1 238

No translator change was needed: all three matched the derived words on the first run.

pytest for the new semantic tests, the runner tests and the shader checks: 129 passed. build.py: 3/3 translated and spirv-val clean; regen_fixtures.py --check clean; docs tests pass. A full semantic discovery in this worktree reports 7 failures + 2 errors in unrelated files (test_loop_ballot_barrier, test_cmp_class_f64, test_mutations), untouched by this change and present in the base tree.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at a6f69651 on Windows 11, RTX 5070 Ti.

  • Semantic tests (the repo's no--I invocation, since these import support): test_msad_mqsad_fixture.py 4 tests, OK, test_rel_addressing_fixture.py 6 tests, OK; git diff --check clean.
  • GPU fixtures, built through the runner's translator:
    • --filter msad -> PASS cs_msad_mqsad 48 4294967284 4294967290 7 2147483654 305419900 3735928559 255 (1/1)
    • --filter swaprel -> PASS cs_swaprel 11 22 55 44 77 55 66 88 (1/1)
    • --filter movrels -> PASS cs_movrels 170 204 187 204 187 187 1 238 and PASS cs_movrelsd_2 11 33 33 55 1717 77 1515 1717 (2/2)

All three fixtures translate and spirv-val clean, and the words match check.py's table on hardware. No blocking issue.

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested a6f69651 on Windows Radeon iGPU with the AMD 25.10.30.02 proprietary driver. All three validated stock fixtures passed at native subgroup 32, 24/24 readback words matched, and zero Khronos validation errors or warnings were reported. Details in #166. AI-assisted.

@Bushyon

Bushyon commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested a6f6965 on AMD Radeon RX 7800 XT (RDNA3), RADV Mesa 26.2.6 (ACO), Vulkan 1.4.354, subgroup 32..64, Fedora 44; llvm-mc 22.1.8, GCC 16.2.1: pass.

@theswiss24

Copy link
Copy Markdown

Tested a6f69651 (contains main d0835dd9) on two GPUs, test programs built from main d0835dd9 (this PR changes no C++), Linux Mint 22.3, llvm-mc 20.1.2, LEONIDA_W64_EMULATE=1: pass. The three new fixtures pass on both, and every other test has the same result as main:

GPU driver run_gpu_tests.py new
Intel UHD 630 (Gen9.5, subgroup 8..32) Mesa ANV 25.2.8 184/213 passed, 27 skipped (main: 181/210, the same 2 known Intel failures) cs_movrels, cs_msad_mqsad, cs_swaprel PASS
NVIDIA MX150 (Pascal) 580.178.04 188/213 passed, 25 skipped, 0 failed (main: 185/210) cs_movrels, cs_msad_mqsad, cs_swaprel PASS

No game files.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested head a6f69651 — Windows, CPython 3.15.2, CPU only, synthetic fixtures, no game files: pass (Python side).

  • python -m unittest discover -s tests/semantic -p "test_msad_mqsad_fixture.py" -> 4/4 OK.
  • python -m unittest discover -s tests/semantic -p "test_rel_addressing_fixture.py" -> 6/6 OK.
  • Control (main's tree + the PR's test files and .s disasm fixtures): test_msad_mqsad_fixture.py 2 failures + 1 error, test_rel_addressing_fixture.py 4 failures — the expected translation differs on main, as intended.
  • git diff --check and scripts/check_no_game_data.py clean.
  • Not exercised: the new .asm GPU fixtures under runtime/test/shaders/ (they run through run_gpu_tests.py; a GPU pass would cover them separately).

AI-assisted (Devin).

@YaBulochka

Copy link
Copy Markdown
Contributor Author

Rebased onto 98fa503f: head is now eb31ed1a. Conflicts were only the three docs/design.md rows (SAD, v_swaprel_b32, relative SGPR reads); the rebase keeps main's newer rows and applies this PR's text to each.

Re-ran after the rebase: 134 tests / 329 subtests green, and run_gpu_tests.py on gfx1036: cs_msad_mqsad 1/1, cs_swaprel 1/1, cs_movrels 2/2. Same words as before.

@jimokulou2-ops

Copy link
Copy Markdown

Tested eb31ed1 merged onto main 98fa503 (clean merge) on AMD Radeon RX 9070 XT (RDNA4), AMD 26.11.2 (32.0.32029.2010, LLPC, Vulkan 1.4.359), Windows 11 Pro 26300: pass.

  • Test programs built from main with llvm-mingw (the PR doesn't touch the runtime C++), llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363.0, LEONIDA_VK_DEVICE=9070.
  • scripts/run_gpu_tests.py, full suite: 205/220 passed, 15 skipped, 0 failed; 224 shaders translated, 224 pass spirv-val. main 98fa503 on the same machine: 202/217, the same 15 skipped. The only difference is the 3 new tests:
    • cs_movrels: PASS 170 204 187 204 187 187 1 238
    • cs_msad_mqsad: PASS 48 4294967284 4294967290 7 2147483654 305419900 3735928559 255
    • cs_swaprel: PASS 11 22 55 44 77 55 66 88
  • tests/semantic/test_msad_mqsad_fixture.py: 4 OK; test_rel_addressing_fixture.py: 6 OK.
  • tests/semantic/regen_fixtures.py --check: clean.

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

@tylerstraub

Copy link
Copy Markdown
Contributor

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

All three new synthetic fixtures passed with the runtime built from this head: cs_msad_mqsad, cs_movrels, and cs_swaprel. The move filter also ran the existing cs_movrelsd_2, which passed.

I checked the final self-swap in a temporary copy of cs_swaprel with different base registers. With destination v1 + 5 and source v2 + 4, both operands select v6. The eight output words matched the stock fixture, including 66 at out[6]. Increasing just the source offset to 5 selected v7. Only out[6] changed, from 66 to 55, and the runner rejected the modified fixture as expected. All tested modules passed spirv-val.

AI-assisted verification.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested eb31ed1 on Apple M2 with MoltenVK 1.4.2 (macOS 26.4 (25E246), subgroup 4..32, device Vulkan 1.4.357): three new GPU fixtures pass; full suite 155/220 passed, 58 skipped, 7 failed vs base 0db7fed 152/217, 58 skipped, 7 failed A/B; no regression.

  • cs_msad_mqsad: PASS — 48 4294967284 4294967290 7 2147483654 305419900 3735928559 255.
  • cs_swaprel: PASS — 11 22 55 44 77 55 66 88.
  • cs_movrels: PASS — 170 204 187 204 187 187 1 238.
  • Full suite on the PR head: 223 shaders translated, 223 pass spirv-val; 155/220, 58 skipped, 7 failed — the seven known MoltenVK expected failures. Base 0db7fed551c4 with the identical shared harness: 152/217, 58 skipped, 7 failed. The only differences are the three new passing fixtures; no common test changed status in either direction. The lane-relative SGPR and VGPR cases therefore run correctly on a 32-wide subgroup here.

Clean configure and build of the six GPU-suite targets on AppleClang 17 (llvm-mc 21.1.8, Python 3.13.18). No code changes of my own.

No game data; synthetic fixtures and counts only.

AI-assisted.

@EvgHaze

EvgHaze commented Nov 23, 2026

Copy link
Copy Markdown

Tested eb31ed1a on Apple M3 (10-core, subgroup 32), macOS 27.0 arm64:

  • MoltenVK 1.4.2: full suite 155/220 passed, 58 skipped, 7 failed.
  • KosmicKrisp 26.3.1 (Mesa 26.3.1, through the Vulkan loader): full suite 160/220 passed, 60 skipped, 0 failed.

The seven failures on MoltenVK are exactly the ones main has on this GPU (five ps_vcmp*, cs_fma_fused, ps_ssharp), unchanged by this PR.

The three new fixtures pass on both drivers, bit-exact:

Fixture MoltenVK 1.4.2 KosmicKrisp 26.3.1
cs_msad_mqsad PASS 48 4294967284 4294967290 7 2147483654 305419900 3735928559 255 PASS, same words
cs_swaprel PASS 11 22 55 44 77 55 66 88 PASS, same words
cs_movrels PASS 170 204 187 204 187 187 1 238 PASS, same words

tests/test_run_gpu_tests.py 41 tests OK and tests/test_shader_checks.py 79 OK on macOS too.

For comparison, main at 98fa503 on the same machine and the same build is 152/217 on MoltenVK and 157/217 on KosmicKrisp, so the PR adds three passing fixtures and no new failure. Built with AppleClang 21.0.0, CMake 4.4.4 + Ninja, Homebrew llvm-mc 23.1.4 (AMDGPU), SPIRV-Tools 1.4.363.0.

AI-assisted.

@memorypressure

Copy link
Copy Markdown

FAIL, reproduced against main 3faac55: everything substantive is green on the merged tree — both new fixture suites (4 + 6 tests), the SAD/movrel semantic siblings, clean merge, hand-written .asm fixtures — but tests/test_docs_design_rows.py fails here and is green on main: the rewritten SAD row at docs/design.md:392 uses backslash-space-pipe escapes inside the ABSDIFF spelling, which split the row into 5 cells under the 3-cell header (confirmed the offending escapes on that line). Escape as a tight backslash-pipe or use a non-pipe absolute-value spelling and this should be ready. Also worth a look: possible coverage overlap with #3545 for v_mqsad_u32_u8. Checks pending; the branch otherwise merges clean with #4617 (verified pairwise). AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@jordi-vancuijlenborg-vinci

Copy link
Copy Markdown

Tested eb31ed1ae on Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 621.01, Vulkan 1.4.357, subgroup size 32). Built the Vulkan test tools from the same revision with LLVM-MinGW 23.1.6 and ran scripts/run_gpu_tests.py --require-pass with each fixture selected individually. cs_msad_mqsad, cs_swaprel, and cs_movrels all passed, with 24/24 exact output words. All three shaders passed spirv-val (SPIRV-Tools 2026.4, assembled with llvm-mc 23.1.6). Focused semantic tests passed 10/10. Synthetic fixtures only. AI-assisted.

@LukeOsland1

Copy link
Copy Markdown

Tested eb31ed1aee on Windows 11 build 26300, NVIDIA RTX 4070 Ti SUPER, driver 610.88. I used the PR’s GPU runner with LLVM 23.1.6 and the MSVC-built harness from the tested sources. The Vulkan loader was restricted to the NVIDIA ICD.

  • cs_movrels — 8 expected output words matched.
  • cs_msad_mqsad — 8 expected output words matched.
  • cs_swaprel — 8 expected output words matched.

Xbox 1.0.2.1 coverage: 0 of 26,503 local shaders.rpf listings contain at least one of the following mnemonics. Static instruction counts (combining e32/e64 spellings): v_msad_u8 0, v_swaprel_b32 0, s_movrels_b32 0. The counts describe opcode presence. The GPU readback above uses the hand-written fixtures. AI-assisted with Codex.

cs_msad_mqsad covers v_msad_u8 and v_mqsad_u32_u8: masked bytes, the
sliding 64-bit windows, and 32-bit accumulator wraps.
cs_swaprel covers both M0 fields, ignored M0 bits and a self-swap;
cs_movrels covers s_movrels_b32/b64, an overlapping destination and
an unchanged SCC. All three are wave32 dumps registered with check.py
and scripts/run_gpu_tests.py, with CPU fixtures in tests/semantic.

Measured on the RDNA2 iGPU (gfx1036, RADV, Mesa 27.0.0-devel):
all three match their headers bit-for-bit.
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.