Skip to content

GPU test cs_w32_movrels64: s_movrels_b64 - #4337

Open
LouisRiverstone wants to merge 5 commits into
ItsNotRexed:mainfrom
LouisRiverstone:gpu-test-movrels64
Open

LouisRiverstone wants to merge 5 commits into
ItsNotRexed:mainfrom
LouisRiverstone:gpu-test-movrels64

Conversation

@LouisRiverstone

Copy link
Copy Markdown
Contributor

#1598 merged s_movrels_b32/s_movrels_b64 with CPU-only checks, and #1850's cs_w32_pk_rel_ext covers only the b32 form. This adds a GPU fixture, runtime/test/shaders/cs_w32_movrels64.asm.

Setup: s20…s27 hold W[k] = 0x5EED0000 + 0x111·k, and lane 0 stores eight dwords:

word case expected
0, 1 s_movrels_b64 s[10:11], s[20:21], M0 = 1 (an odd pair): W[1], W[2] 0x5EED0111 0x5EED0222
2, 3 the same with M0 = 4 from v_readfirstlane, which the translator can't fold: W[4], W[5] 0x5EED0444 0x5EED0555
4 s_movrels_b32 s12, s22, M0 = 3 from v_readfirstlane: s25 0x5EED0555
5, 6 s_movrels_b64 s[21:22], s[21:22], M0 = 1: the destination overlaps the source, which is read first: W[2], W[3] 0x5EED0222 0x5EED0333
7 SCC set by s_cmp before an s_movrels and read after it (not written) 1

Registration: like the other wave32 fixtures, and not in the lane-mask list, so it also runs on llvmpipe.

Tests: tests/semantic/test_movrels64_fixture.py runs the fixture on the CPU against a model of the SGPR file. It also checks that both runners expect the same words and that two of the reads take a run-time M0. It passes 4/4, regen_fixtures.py --check is clean, and tests/test_shader_checks.py and tests/test_run_gpu_tests.py pass.

Not run on a GPU by me: CI's llvmpipe job will run it. No game files. Claimed on #4257 before starting.

AI-assisted (Claude Code): I reviewed and ran the change and the tests.

ItsNotRexed#1598 merged s_movrels_b32/b64 with CPU-only checks, and ItsNotRexed#1850's fixture covers
only the b32 form. Lane 0 checks the pair read at odd and even M0, M0 from
v_readfirstlane (not foldable), the b32 form at a base register, a
destination overlapping the source, and SCC kept. Registered in check.py,
run_gpu_tests.py and regen_fixtures.py; tests/semantic/
test_movrels64_fixture.py runs it on the CPU against an SGPR-file model.
@MKmajster

Copy link
Copy Markdown

The fixture doesn't assemble with LLVM 23, and that takes the whole GPU suite down. Tested 797f240 on Windows 11, llvm-mc 23.1.6 (gfx1013).

Line 33 of cs_w32_movrels64.asm:

s_movrels_b64 s[21:22], s[21:22]
<stdin>:33:15: error: invalid register alignment

On GFX10 a 64-bit SGPR operand has to start at an even SGPR, as with any _b64 SALU op. llvm-mc rejects s_mov_b64 s[21:22], s[24:25] the same way and accepts s_movrels_b64 s[20:21], s[20:21]. The other two movrels in the fixture (s[10:11], s[20:21] and s[14:15], s[20:21]) are fine. The "odd pair" comes from M0 = 1 at run time, not from the encoded base, so only the overlapping case is affected.

run_gpu_tests.py assembles every fixture before running any, and assemble_to_s raises on an llvm-mc error. So on this branch the full run stops at once: python -I scripts/run_gpu_tests.py exits 1 with that error and 0 tests run. The description says CI's llvmpipe job will run it, but it would hit the same error if that job's llvm-mc is 21+ (the README's LLVM 23.1.5 run).

To keep the overlap check, the base needs to be even with the overlap coming from M0. For example s_movrels_b64 s[20:21], s[20:21] with M0 = 1 reads s[21:22], which overlaps its own destination pair (the expected words change accordingly). Or keep a separate even destination, as the first two cases do.

AI-assisted (Claude).

@tylerstraub

Copy link
Copy Markdown
Contributor

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

Confirmed the alignment error on Linux with LLVM 21.1.8 at 797f240d. The unmodified cs_w32_movrels64 fixture stops at line 33 before GPU dispatch.

I tested an aligned overlap that also detects an early write to the low destination register. With M0 = 1, use s_movrels_b64 s[22:23], s[20:21] and store s22 and s23 as output words 5 and 6. The effective source is s21:s22, so the correct output is the old s21 and the old s22. Writing s22 before reading the high source would incorrectly duplicate the first word.

In a local fixture variant with those two expected words updated, run_gpu_tests.py --filter cs_w32_movrels64.asm --require-pass assembled, passed spirv-val, and passed on an RTX 5090 (595.99.02). All eight words matched: 5eed0111 5eed0222 5eed0444 5eed0555 5eed0555 5eed0111 5eed0222 00000001. The translator was unchanged. The fixture, both runners' expectations, and the generated semantic fixture should agree on the chosen pair in the PR.

AI-assisted (Codex). Synthetic shader only.

AI-assisted verification.

@2-CD

2-CD commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check: NVIDIA GeForce RTX 5080 (driver 621.01) + AMD Radeon 610M iGPU (driver 32.0.13018.6), Windows 11, MSVC (VS BuildTools 18) + Ninja, RelWithDebInfo, llvm-mc 21.1.8 (gfx1013), spirv-as/spirv-val. Tested head 797f240d (base 03b09a08).

Result: the new GPU fixture does not assemble on this toolchain - FAIL.

  • CPU semantic side is fine: tests/semantic/test_movrels64_fixture.py passes 4/4 (disasm fixture + translator OK).
  • GPU fixture runtime/test/shaders/cs_w32_movrels64.asm fails to assemble with llvm-mc 21.1.8:
    <stdin>:33:15: error: invalid register alignment on s_movrels_b64 s[21:22], s[21:22].
    A 64-bit SGPR pair (*_b64) must start on an even SGPR; s[21:22] starts on odd SGPR 21, so MC rejects it. This is the same alignment error tylerstraub saw on Linux with LLVM 21, and MKmajster's LLVM 23 failure - so the fixture is un-assemblable on both LLVM 21 and 23, not only 23.
  • Suite-wide impact (matches MKmajster's "takes the whole GPU suite down"): scripts/run_gpu_tests.py does not catch this per-fixture - assemble_to_s raises a RuntimeError that propagates out of run_suite (observed traceback: run_gpu_tests.py:728 -> :116), so the whole GPU run aborts at this fixture rather than skipping it.
  • The failure is toolchain-side (assembly), so it is identical on both GPUs - the fixture never reaches the GPU, and no GPU readback was possible on either the RTX 5080 or the iGPU.

Suggested fix: the destination-overlapping-source case (fixture comment lines 6-7) should use an even-aligned pair, e.g. s_movrels_b64 s[22:23], s[22:23] (or s[20:21]), so the b64 pair is valid; the expected out[5]/out[6] words would follow the new pair.

Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine.

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS. The header derivation and expected words (0x5EED0111..., the decimal Run: line) match check.py/run_gpu_tests.py, and the runtime-M0, overlap and SCC-kept cases are modelled correctly. Registered in check.py:88,119, run_gpu_tests.py:947,975,1063 and regen_fixtures.py:24; no game data. The fixture is hand-written, regen_fixtures --check and compileall are clean, fixture tests 4/4, test_shader_checks 75, test_run_gpu_tests 40, and no GPU/LLVM is needed.

Coordination: #4331 and #4323 insert at the same anchors (check.py:88,119, run_gpu_tests.py:947,975,1063, regen_fixtures.py:24) and conflict on top of this one, so the later two need a rebase. Whichever lands first is fine.

Approve. AI-assisted review, no game files, no GPU.

@theswiss24

Copy link
Copy Markdown

Fails on two GPUs: llvm-mc rejects the fixture's last s_movrels_b64, so scripts/run_gpu_tests.py stops before running anything.

RuntimeError: llvm-mc failed on cs_w32_movrels64:
<stdin>:33:15: error: invalid register alignment
s_movrels_b64 s[21:22], s[21:22]
              ^
  • 797f240d (contains main 03b09a08) on NVIDIA GeForce RTX 4070, driver 621.24, Windows 11, llvm-mc 21.1.8: LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py exits 1 with the error above.
  • The same tree on NVIDIA GeForce RTX 2060 SUPER, driver 580.178.04, Ubuntu 24.04, llvm-mc 20.1.2: the same error.
  • On the server, llvm-mc -arch=amdgcn -mcpu=gfx1013 accepts s_movrels_b64 s[20:21], s[22:23] ([0x16,0x2f,0x94,0xbe]) and rejects s[21:22], s[21:22]. A 64-bit SGPR operand must be even-aligned in the assembly.

The semantic test passes because it reads tests/semantic/fixtures/disasm/cs_w32_movrels64.s, which never goes through llvm-mc. CI's llvmpipe job should hit the same error. One way to keep the overlap case is to write it even-aligned and let M0 make it odd: s_movrels_b64 s[20:21], s[20:21] with M0 = 1 reads s[21:22] while writing s[20:21]. The expected words would change accordingly. No game files.

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

@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Fixed in 922b5aac. Thanks @MKmajster for finding it: LLVM 22+ rejects the odd-based 64-bit SGPR pair s[21:22] ("invalid register alignment"), and my local LLVM 21 accepted it, so the fixture would have stopped the whole GPU run (TEST-961, which @vibryxcx has).

The overlap case is now s_movrels_b64 s[22:23], s[20:21] with M0 = 1. It reads the pair s21, s22, which overlaps the destination s22, so words 5 and 6 are W[1], W[2] (0x5EED0111 0x5EED0222) only if the source is read before the destination is written. The expected words are updated in check.py, run_gpu_tests.py and the fixture test. The fixture test also checks now that every SGPR range in the file starts at an even register.

test_movrels64_fixture.py passes 5/5, regen_fixtures.py --check is clean, and tests/test_shader_checks.py and tests/test_run_gpu_tests.py pass. I still have no LLVM 22+ here to assemble it myself.

…:22])

llvm-mc 23 rejects the odd-based 64-bit SGPR pair s[21:22] (invalid register
alignment), and one fixture it can't assemble stops the whole GPU run
(MKmajster's finding, TEST-961). The overlap case is now
s_movrels_b64 s[22:23], s[20:21] with M0 = 1: it reads s21, s22, which
overlaps the destination s22, so W[1], W[2] only if the source is read
first. The fixture test checks that every SGPR range starts at an even
register.
@tylerstraub

Copy link
Copy Markdown
Contributor

Replying to @LouisRiverstone.

Verified the submitted fix at 922b5aac with the same Linux LLVM 21.1.8 / gfx1013 toolchain that rejected line 33 at 797f240d. The unchanged fixture now assembles, passes spirv-val, and passes the focused GPU suite on RTX 5090 (595.99.02). All eight words matched: 5eed0111 5eed0222 5eed0444 5eed0555 5eed0555 5eed0111 5eed0222 00000001. In particular, word 6 retains the old s22 value across the overlapping write.

AI-assisted (Codex). Synthetic fixture only.

AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor

The GPU run the author could not do. Tested head 922b5aa on Apple M2 (Mac14,3), macOS 26.4, MoltenVK 1.4.2 (direct), subgroup 4..32, llvm-mc 23.1.6, clean full build on AppleClang 17.

python -I scripts/run_gpu_tests.py --filter cs_w32_movrels64 --build runtime/build/linux: 1 shader translated, 1 pass spirv-val; 1/1 passed — out words 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1, 0 mismatches. Adds a real Apple/MoltenVK run to the CPU-only evidence in the PR body. Head fetched read-only, no rebase/edit/push. Synthetic shader and counts only; no game files.

AI-assisted.

@vibryxcx

Copy link
Copy Markdown

Tested 922b5aa on AMD Radeon RX 6800 (RDNA2), AMD 26.8.1 (Windows 32.0.21045.5002), Windows 11 Pro 25H2 (build 26200), with llvm-mc 23.1.6 (conda-forge), since you had no LLVM 22+: pass.

  • The fixture assembles with 23.1.6 (no "invalid register alignment"), translates and passes spirv-val.
  • run_gpu_tests.py --filter cs_w32_movrels64 --require-pass: 1/1 in three runs, 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1. Words 5 and 6 are 0x5EED0111 0x5EED0222, the W[1], W[2] you expect when the source pair is read before the destination is written.
  • tests/test_shader_checks.py 75 OK, tests/test_run_gpu_tests.py 40 OK.

The runtime programs came from main aa2988c (this PR changes no C++). No game files.

AI-assisted (Claude Code).

python -I on the file failed with ModuleNotFoundError: support, as the folder
was not on sys.path (found by @justr4mzi on ItsNotRexed#4323, the same template). It is
now inserted, as test_cs_shared_memory_limit does.
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Thanks @tylerstraub. 922b5aac uses exactly the aligned overlap you suggested (s_movrels_b64 s[22:23], s[20:21] with M0 = 1), and your RTX 5090 run at that head matches all eight words. Thanks also @bobcatchris for the Apple M2 run. The latest head adds only the python -I import fix in the fixture test (found by @justr4mzi on #4323).

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Follow-up at ed47f5f2 (even-aligned overlap; 797f240d stopped at llvm-mc on this card):

Automated test: ed47f5f2 merged onto main 03b09a08 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. Result: pass.

  • scripts/run_gpu_tests.py: 193/210 passed, 15 skipped (plain main: 192/209 passed, 15 skipped).
    • new test cs_w32_movrels64: pass (1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1)
  • Python tests this PR touches: 5 passed, 10 subtests passed.

Same machine and setup as my earlier manual reports. AI-assisted (Claude Code).

@Kev-Ball

Copy link
Copy Markdown

Tested ed47f5f2 on an NVIDIA GeForce RTX 3080 Ti (32-lane subgroups), driver 620.73.04, CachyOS Linux 7.3.5-2-cachyos. I rebuilt the Vulkan harnesses from this revision and selected the NVIDIA device explicitly.

Ran scripts/run_gpu_tests.py --filter cs_w32_movrels64 --require-pass end to end with the local LLVM assembler. The aligned fixture assembled, translated and validated; GPU readback passed with the eight words 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1 (decimal).

AI-assisted verification with synthetic inputs.

@kapitche

Copy link
Copy Markdown
Contributor

Tested ed47f5f2 merged with main 3eb4410b on Windows 11, RTX 4080 SUPER + Intel UHD 770 (MSVC 14.51): pass.

  • scripts/run_gpu_tests.py --filter cs_w32_movrels64: PASS on both GPUs (1/1 each).
  • tests/semantic/test_movrels64_fixture.py: 5 tests OK.
  • Control: test-only PR, so there are no non-test files to revert; compile-only is not applicable either, since the fixture runs.

The GPU test programs are the runtime build of main 7b7d73f8 (the same exes for every run); the PR's tools/, scripts/ and runtime/test/shaders come from the merge.

@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested ed47f5f (a re-test at the new head) on AMD Radeon RX 9070 XT (RADV GFX1201, wave32/64) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

  • Full python -I scripts/run_gpu_tests.py (Linux build of this branch's runtime/, LEONIDA_VK_DEVICE per GPU): 197/211 passed, 14 skipped, 0 failed on both GPUs. The new cs_w32_movrels64 passes on both. Every other test has the same result as at the merge base 03b09a0.
  • python -m unittest discover -s tests/semantic: 7461 run, 7 failures and 2 errors. That is main's known set at 03b09a0 (test_cmp_class_f64, test_mutations, test_loop_ballot_barrier). The PR adds none.
  • Note: main has moved 917 commits past that merge base, so this doesn't cover the branch merged onto current main.

No game files. AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested ed47f5f2 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • The merge was clean. The fixture assembles with llvm-mc 23.1.5 (no "invalid register alignment"). This PR changes no C++, so the runtime test programs came from the d0835dd9 build.
  • scripts/run_gpu_tests.py, with LEONIDA_W64_EMULATE unset and with it set to 1: 215 shaders translated, 215 pass spirv-val, 197/211 passed, 14 skipped in both modes. Plain d0835dd9 gives 196/210 passed, 14 skipped.
  • Per-test comparison with d0835dd9 without the PR (the PASS/FAIL/SKIP word and test name of every result line), in both modes: the only difference is the new cs_w32_movrels64 line. No existing test changed.
  • New test cs_w32_movrels64: pass in both modes, 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1. That is 0x5EED0111 0x5EED0222 0x5EED0444 0x5EED0555 0x5EED0555 0x5EED0111 0x5EED0222 1, so out[5] and out[6] keep the old s21 and s22 across the overlapping write. --filter cs_w32_movrels64 --require-pass gave 1/1.
  • Python checks: tests/semantic/test_movrels64_fixture.py 5/5 OK, regen_fixtures.py --check clean, tests/test_shader_checks.py 75 OK, tests/test_run_gpu_tests.py 40 OK, compileall clean.

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

@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.

Built the runner and ran at ed47f5f27 on Windows 11, RTX 5070 Ti: run_gpu_tests.py --filter movrels64 -> 1/1 passed, cs_w32_movrels64 -> 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1; translator 1/1 + spirv-val; tests/semantic/test_movrels64_fixture.py -> 5 tests, OK.

s_movrels_b64 now has a GPU fixture matching the expected words, and the fixture runs under python -I. No blocking issue.

@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Thanks @Kev-Ball (RTX 3080 Ti), @kapitche (RTX 4080 SUPER + UHD 770), @sperm (RX 9070 XT + gfx1036), @lunarminus (per-test diff against main, only the new line differs) and @Kam471 (RTX 5070 Ti). All on the current head ed47f5f2, with the even-aligned overlap; nothing is pending.

# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/semantic/regen_fixtures.py
@javdc

javdc commented Nov 23, 2026

Copy link
Copy Markdown

Tested 91b639a on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass.

  • pytest tests/semantic/test_movrels64_fixture.py -q: 5 passed, 10 subtests passed.
  • Targeted GPU filter cs_w32_movrels64: 1/1 pass.
  • Full GPU suite (python3 -I scripts/run_gpu_tests.py --build /home/deck/opencode/Leonida/runtime/build): 213/233 passed, 16 skipped, 0 failed (expected skips; total includes the new fixture).

No runtime C++ changes in this PR; tested from the PR worktree against the existing runtime build.

AI-assisted (OpenCode).

# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/semantic/regen_fixtures.py
@Racurs156

Copy link
Copy Markdown

Tested 6a06621 on Windows 11, NVIDIA GeForce RTX 4060 Ti (Ada), driver 621.01. All five fixture tests passed. The PR translator and the checked-in synthetic disassembly produced a module that passed spirv-val. On the GPU, three fresh dispatches each confirmed subgroup size 32 and all eight output words matched the fixture, including the overlapping register pair and the final SCC value.

I used the project's Windows vk_compute_test from upstream run 45037994684. AI-assisted hardware verification.

@Mortify7612

Copy link
Copy Markdown

Tested 6a06621c merged onto main 1cc6e3c1 (clean) on AMD Radeon RX 9060 XT (RDNA4, GFX1200, subgroup 32..64), RADV Mesa 25.0.7, Debian 12 Linux, llvm-mc 23.1.6: pass. I ran run_gpu_tests.py --filter <fixture> for the fixture(s) this PR adds or changes, not the full suite:

PASS cs_w32_movrels64 1592590609 1592590882 1592591428 1592591701 1592591701 1592590609 1592590882 1

AI-assisted (Claude Code).

@Itschotsch

Copy link
Copy Markdown

Tested 6a06621 on NVIDIA GeForce RTX 4090, driver 595.99.02, Linux (Debian 13 userspace), llvm-mc 21.1.8: pass

Test programs built from main 1cc6e3c (this PR changes no C++). Run in an isolated container; AI-assisted (Claude Code).

@LukeOsland1

Copy link
Copy Markdown

Tested 6a06621c6f 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_w32_movrels64 — 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): s_movrels_b64 0. The counts describe opcode presence. The GPU readback above uses the hand-written fixture. AI-assisted with Codex.

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.