Skip to content

GPU test cs_w32_movrels64: s_movrels_b64 - #4337

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

LouisRiverstone wants to merge 3 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.

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