Skip to content

GPU test cs_w32_late_ext: ds_mskor, v_add/sub_nc_i16 clamp, s_buffer_load constant offset - #3039

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

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

Conversation

@LouisRiverstone

Copy link
Copy Markdown
Contributor

A GPU test, in the cs_w32_*_ext format CI runs on llvmpipe, for three merged changes that only had CPU checks: ds_mskor_b32/ds_mskor_rtn_b32 (#1954), v_add/sub_nc_i16 with clamp (#1974), and the s_buffer_load constant-SGPR-offset fix (#1948).

runtime/test/shaders/cs_w32_late_ext.asm: lane 0 of a wave32 group stores eight words (derivations in the header):

word op expected
0 ds_mskor_rtn_b32 old value (LDS 0x12345678, DATA 0xFF00, DATA2 0xAB00) 0x12345678
1 the LDS word after it 0x1234AB78
2 LDS after ds_mskor_b32 (LDS ~0, DATA 0xFFFF, DATA2 1) 0xFFFF0001
3 v_add_nc_i16 0x7FFF + 1 clamp 0x7FFF
4 v_sub_nc_i16 0x8000 - 1 clamp 0x8000
5 v_add_nc_i16 0x7FFF + 1, no clamp (wraps) 0x8000
6 s_buffer_load_dword with s12 = -4, offset:20 0
7 the same load with s12 = 12 (byte 32, never written) 0xEEEEEEEE

Why words 6 and 7 work: vk_compute_test fills the buffer with 0xEE and its V# has num_records = 0xFFFFFFFF (runtime/test/vk_compute_test.cpp). 0xFFFFFFFC + 20 isn't reduced mod 2^32, so it's out of range and reads 0. Before #1948, the folded constant wrapped to 16 and read the 0xEE fill instead. Word 7 is the in-range control. Both scalar loads run before any store, because a scalar load would not see a vector store without a cache invalidate.

LDS: EXEC is cut to lane 0 before the LDS ops, so 32 lanes never race on one address (the #1850 lesson).

Registration, as cs_w32_new_ops: WAVE32_DUMPS and CS_DUMPS in check.py, the dump list, expected words and wave32 exclusion in run_gpu_tests.py, and regen_fixtures.py, plus the fixture.

CPU check: tests/semantic/test_late_ext_fixture.py runs the fixture as one wave32 group in spirv_mini_interp, with the harness's buffer (0xEE fill and the max-num_records V#). It checks the eight words against values computed in the test, that both runners expect them, and that the v_cmpx comes before the first ds_. 4/4 pass; regen_fixtures.py --check passes. python -I -m unittest discover -s tests/semantic: 4146 tests OK (4 skipped). tests/test_shader_checks.py and tests/test_run_gpu_tests.py OK.

Not yet run on a GPU. I have no GPU or llvm-mc here, so CI's linux-gpu-tools job will be the first run. No game files.

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

@TieruYT

TieruYT commented Nov 22, 2026

Copy link
Copy Markdown

Hardware result for 4ef280bec103bc6f9c7f07c2c5c2d0bdde964a97: PASS on GeForce RTX 4070 Ti, NVIDIA 621.24, Windows 11. Built the Vulkan test programs from this head with MSVC and selected the RTX via LEONIDA_VK_DEVICE. The filtered scripts/run_gpu_tests.py --filter cs_w32_late_ext run assembled the fixture with LLVM 21.1.8, translated it and passed SPIR-V validation. The GPU returned all eight expected words, in order:

12345678 1234ab78 ffff0001 00007fff 00008000 00008000 00000000 eeeeeeee (hex).

For a negative control, in a separate checkout I removed only the clamp on the signed addition into v3 and left the expected words unchanged. The module still passed SPIR-V validation, but the GPU runner correctly exited 1: word 3 changed from 0x7fff to 0x8000 and the other seven matched. The four CPU fixture tests also passed on the unmodified PR. All inputs were synthetic.

AI-assisted verification · GPT-6.2 Astra Medium

@emirduran707

Copy link
Copy Markdown
Contributor

Tested 4ef280b 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. The checks above have no AMD run from outside the author; this adds an AMD card with native 64-wide subgroups.

  • python -I scripts/run_gpu_tests.py --build <build> --filter <fixture>, one run per new fixture:
    • cs_w32_late_ext: PASS, 305419896 305441656 4294901761 32767 32768 32768 0 4008636142; same with LEONIDA_W64_EMULATE=1
  • Whole suite (native wave64): 195 shaders translated, 195 pass spirv-val; 176/190 passed, 14 skipped, 0 failed. The skips are the 14 fixtures the d3d12_* tests run.
  • build.py + check.py: 215 shaders: 215 translated, 215 pass spirv-val; 165 of 168 pass, 3 skipped; ok for cs_w32_late_ext.
  • CPU: python -I -m unittest discover -s tests/semantic -p test_late_ext_fixture.py 4 OK, tests/test_shader_checks.py 69 OK, tests/test_run_gpu_tests.py 34 OK, tests/semantic/regen_fixtures.py --check clean. I did not run the whole tests/semantic suite.

Test programs: an MSVC 14.44 build of main ec8ec4c; this PR's runtime C++ and CMake are identical to that commit, and the translator, runner and check.py are this PR's. llvm-mc 21.1.8 (native), Vulkan SDK 1.4.363.0. No negative control run here. No game files. AI-assisted (Claude Code).

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Tested 4ef280be merged onto main 16282101 on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5, subgroup 32..64), Mesa 25.2.8, Ubuntu 24.04, LLVM 23.1.6, SPIRV-Tools 2026.4: pass.

  • python -I scripts/run_gpu_tests.py --build runtime/build/linux (runtime rebuilt from this branch): 173/190 passed, 15 skipped; the new cs_w32_late_ext passes (305419896 305441656 4294901761 32767 32768 32768 0 4008636142). Otherwise identical to plain main 16282101, including the two known Mesa 25.2 RADV failures cs_signed_zero_nan and cs_w32_salu64 (GPU test results (one comment per GPU and driver) #166).
  • tests/semantic/test_late_ext_fixture.py: 4 passed, 10 subtests.

gfx1151 is RDNA 3.5, not RDNA2: this shows the translated SPIR-V gives the modelled words on a real driver, not that RDNA2 hardware does. AI-assisted (Claude Code).

@steamaze0

Copy link
Copy Markdown

Tested 4ef280b on NVIDIA RTX 5060 Ti (Blackwell), subgroup 32..32, NVIDIA 621.01 (Vulkan 1.4.357), Windows 11: pass.

  • cs_w32_late_ext: PASS — all 8 words exact: 0x12345678 0x1234AB78 0xFFFF0001 0x7FFF 0x8000 0x8000 0x0 0xEEEEEEEE. First run on a real GPU; matches the header's derivations (word 6: the out-of-range constant offset reads 0; word 7: the in-range control reads the 0xEE fill).
  • run_gpu_tests.py (LEONIDA_W64_EMULATE=1): 175/190 passed, 15 skipped, 0 failed. build.py: 195 shaders, 195 translated, 195 pass spirv-val.
  • The 15 skips are expected here: ps_m*/vs_m* are run by the d3d12 draw tests (not built in this standalone Vulkan build), and ps_w64x_readlane can't require a 64-wide fragment subgroup on a 32-wide device.
  • CPU: python -I -m unittest discover -s tests/semantic -p test_late_ext_fixture.py -> 4/4 OK.

Tools: llvm-mc 23.1.6 (conda-forge, native Windows), Vulkan SDK 1.4.363.0 (spirv-as/spirv-val), clang 23.1.6 (llvm-mingw; standalone Vulkan tools with -DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF, no MSVC).

AI-assisted (Qoder): I built the tools, ran the GPU suite and the CPU test, and checked the eight words against the header.

@sarveshgamers

Copy link
Copy Markdown
Contributor

Dual-GPU Hardware Verification Report for #3039

Tested commit \4ef280bec103bc6f9c7f07c2c5c2d0bdde964a97\ across both physical host GPUs on Windows 11.

Hardware & Driver Environment

  1. AMD Radeon 780M Graphics
    • Device: RDNA3 iGPU, gfx1036/RDNA emulation target (subgroups 32..64)
    • Driver: Adrenalin 26.11.2 (LLPC) / Windows driver \32.0.32015.7029\
    • Vulkan API: 1.4.359
    • Selection: \ = 780M\
  2. NVIDIA GeForce RTX 5060 Laptop GPU
    • Device: Ada Lovelace architecture (subgroups 32..32)
    • Driver: NVIDIA 621.01 / Windows driver \32.0.16.2101\
    • Vulkan API: 1.4.357
    • Selection: \ = 5060\
  • Toolchain: ROCm \llvm-mc\ (AMDGPU target), Vulkan SDK 1.4.357, Python 3.14.5

Test Results

1. GPU Harness (\scripts/run_gpu_tests.py --filter cs_w32_late_ext)

Both physical GPUs assembled the fixture, translated cleanly via
dna2spirv.py, passed Vulkan 1.2 \spirv-val, and matched all 8 expected output words bit-for-bit:

\\ ext
=== rdna2spirv.py ===
1 shaders: 1 translated, 1 pass spirv-val

=== GPU TEST RESULTS ===
PASS cs_w32_late_ext 305419896 305441656 4294901761 32767 32768 32768 0 4008636142
1/1 passed
\\

Hexadecimal word breakdown:

  • \out[0]\ = \

@hidrogenone

Copy link
Copy Markdown
Contributor

Tested 4ef280be on NVIDIA GeForce RTX 5080 (Blackwell), driver 32.0.16.2124, Windows 11, Vulkan SDK 1.4.357.0. llvm-mc LLVM 21.1.8 (WSL Ubuntu).

scripts/run_gpu_tests.py --filter late_ext:

cs_w32_late_ext   1/1 passed

Translator: 1 shader translated, spirv-val clean — ds_mskor and v_add/v_sub_nc_i16 exact on this adapter. NVIDIA Blackwell (RTX 50-series) coverage. AI-assisted.

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

Verified on the PR head with a fresh MSVC 19.44 + Vulkan SDK 1.4.363 Ninja build: \cs_w32_late_ext\ -> PASS, 1/1, words \

@Yourrespawn

Copy link
Copy Markdown
Contributor

Tested 4ef280be on NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), driver 617.14, Vulkan API 1.4.351, Windows 11 Pro 10.0.26200: pass.

Closes the GPU-coverage gap for those three merged changes cross-vendor on NVIDIA.

AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine.

…load constant offset

ds_mskor_b32 / ds_mskor_rtn_b32 (ItsNotRexed#1954), v_add/sub_nc_i16 with clamp
(ItsNotRexed#1974) and the s_buffer_load constant-SGPR-offset fold (ItsNotRexed#1948) were
merged with CPU checks only. cs_w32_late_ext.asm stores eight words from
lane 0; the LDS ops run after EXEC is cut to lane 0, and the scalar loads
run before any store. With vk_compute_test's V# (num_records 0xFFFFFFFF)
s12 = -4, offset:20 must read 0: the old 32-bit wrap read byte 16, the
0xEE fill.

tests/semantic/test_late_ext_fixture.py runs the fixture on the CPU with
the harness's buffer (0xEE fill, num_records max), checks the words,
that both runners expect them, and the lane-0 order.
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

Heads-up: this fixture segfaults on llvmpipe (CI's GPU), which I could only check now with a local Mesa 26.0.8 build. Word 6's out-of-range s_buffer_load (s12 = -4, offset:20) is guarded correctly in the translated code, but llvmpipe runs the guarded load anyway, 4 GB past the buffer. The translator fix is #4573: the guarded load reads through the buffer's base when out of range, and with it this fixture passes on llvmpipe with all eight words right. This PR should merge after #4573, or CI's llvmpipe job will crash on it.

LouisRiverstone added a commit to LouisRiverstone/Leonida that referenced this pull request Nov 23, 2026
…d form still hoisted)

@wavehs's review on ItsNotRexed#4573 led to a fixture with more loads (cs_smem_oob_far)
that still segfaulted llvmpipe with the guarded load: inside the branch the
compiler knows the bound holds and folds the selected address back to the far
one, so the first version only passed ItsNotRexed#3039's fixture by luck. A selected heap
base (as suggested) segfaults too: the heap base is 0 in vk_compute_test.

The dword is now loaded with no branch, through OpSelect(in range, its address,
the V#'s base), and its value is OpSelect(in range, loaded, 0). Both host
addresses are computed once, outside the per-dword loop.

- test_scalar_mem_smem.py's evaluator models OpSelect %uint and keeps loads
  through the out-of-range side of an address select out of reads (in
  discarded): reads stays the addresses the hardware rule reads.
- test_smem_oob_safe_address.py checks the shape (no branch, the address and
  value selects on one condition), the discarded reads at the V# base, values
  unchanged, and the new fixture on the CPU.
- runtime/test/shaders/cs_smem_oob_far.asm: passes on llvmpipe with this rule,
  segfaults vk_compute_test without it.
- docs/design.md row updated.
@bobcatchris

Copy link
Copy Markdown
Contributor

First real-GPU run of the new fixture (the PR body says it had only been run in CI's llvmpipe job). Head 577b7809efbbea562d34f6801083961dadc2d7c2 on this Apple Silicon host (reports Apple M2 / Mac14,3, not M1), macOS 26.4, MoltenVK 1.4.2, subgroup range 4..32, llvm-mc 23.1.6; clean full build on AppleClang 17.

  • python -I scripts/run_gpu_tests.py --filter cs_w32_late_ext --build runtime/build/vulkan: 1 shader translated, 1 pass spirv-val; 1/1 passed — words 305419896 305441656 4294901761 32767 32768 32768 0 4008636142, 0 mismatches.
  • Full suite on the same head: 214 shaders translated, 214 pass spirv-val; 128/211 passed, 76 skipped, 7 failed. Current main d0835dd9f9ec0a88faee510126436f2427854c2e on this box gives 127/210 with the same seven failures; the only difference is this PR's new fixture, which passes. No common test changed status in either direction.

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

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 577b7809 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_late_ext: PASS on both GPUs (1/1 each).
  • tests/semantic/test_late_ext_fixture.py: 4 tests OK.
  • Control: test-only PR, so there are no non-test files to revert.

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.

@cxchhh

cxchhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 577b7809 on Tesla V100-SXM2-32GB (Volta, subgroup 32..32), NVIDIA 580.95.05, Ubuntu 24.04 (kernel 6.14.11), Python 3.12: pass.

Setup: the PR diff applied to main 98fa503f (applies cleanly), Linux Vulkan test programs built from that tree (cmake -S runtime -G Ninja), compared against an untouched main 98fa503f built the same way.

No game files. AI-assisted (Claude Code); I ran the commands above and checked the numbers against the logs.

@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 577b780 on AMD Radeon 610M (RDNA2 iGPU, AMD 26.11.2 / 32.0.21045.29003, subgroup 32..64) and NVIDIA GeForce RTX 5070 Ti Laptop GPU (Blackwell, 621.24, subgroup 32..32), Windows 11 Home 26200: pass. This adds an AMD GPU on the Windows driver to the runs above.

Same laptop, one GPU at a time through LEONIDA_VK_DEVICE. Test programs rebuilt from this head with llvm-mingw 23.1.6; llvm-mc 23.1.6 (conda-forge), SPIRV-Tools v2026.4 (Vulkan SDK 1.4.363.0), Python 3.13.14.

scripts/run_gpu_tests.py (full) Result cs_w32_late_ext
Radeon 610M, native 190/211 passed, 21 skipped, 0 failed PASS 305419896 305441656 4294901761 32767 32768 32768 0 4008636142
RTX 5070 Ti Laptop, native 165/211 passed, 46 skipped, 0 failed PASS, the same words
RTX 5070 Ti Laptop, LEONIDA_W64_EMULATE=1 196/211 passed, 15 skipped, 0 failed PASS, the same words

215 shaders translated, 215 pass spirv-val in each run. I did not run the CPU tests of this PR. One run of each. No game files. AI-assisted (Claude Code).

@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Thanks @bobcatchris (Apple M2), @kapitche (RTX 4080 SUPER + UHD 770), @cxchhh (V100, native and emulated) and @Etr0p (Radeon 610M, RTX 5070 Ti), all on the current head 577b7809. On llvmpipe this fixture still needs #4573: its out-of-range s_buffer_load segfaults vk_compute_test without it.

LouisRiverstone added a commit to LouisRiverstone/Leonida that referenced this pull request Nov 23, 2026
…rom the V# base (llvmpipe segfault)

Rebuilt on main, which replaced one selection per dword with one per load (to
cut the blocks of the cascade-shadow CS). That still segfaults llvmpipe (Mesa
26.0.8, LLVM 21) on ItsNotRexed#3039's s12 = -4, offset:20 and on cs_smem_oob_far: the
load inside the selection is hoisted and reads 4 GB past the buffer.

The loads now have no branch: they read through OpSelect(dword 0 in range,
the address, the V#'s base), at index i when in range and 0 otherwise (main's
indexing), and each value is OpSelect(dword i in range, loaded, 0). Out of
range they read the buffer's first dword and the values are discarded; no
extra blocks at all.

- test_scalar_mem_smem.py's evaluator models OpSelect %uint and keeps loads
  through the out-of-range side of an address select out of reads.
- tests/semantic/test_smem_oob_safe_address.py: the no-branch shape (one
  selected pointer on dword 0's bound, a value select per dword), discarded
  reads only at the V# base's first dword, values unchanged, the fixture on
  the CPU.
- runtime/test/shaders/cs_smem_oob_far.asm: passes on llvmpipe with this rule,
  segfaults vk_compute_test with main's translator.
- docs/design.md row added.
@lunarminus

Copy link
Copy Markdown

Tested 577b7809 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 PR changes no runtime C++ or CMake, so the Vulkan test programs are the Linux build of d0835dd9. The translator, the runner and check.py come from the merge.
  • scripts/run_gpu_tests.py, full suite, native: 215 shaders translated, 215 pass spirv-val; 197/211 passed, 14 skipped, 0 failed.
  • The same with LEONIDA_W64_EMULATE=1: 215 translated, 215 pass spirv-val; 197/211 passed, 14 skipped, 0 failed.
  • I compared each test with d0835dd9 without the PR (196/210 passed, 14 skipped in both modes). All 210 shared tests have the same PASS/FAIL/SKIP result in both modes. The only new line is cs_w32_late_ext, which passes in both modes: 305419896 305441656 4294901761 32767 32768 32768 0 4008636142 (= 0x12345678 0x1234AB78 0xFFFF0001 0x7FFF 0x8000 0x8000 0 0xEEEEEEEE).
  • --filter cs_w32_late_ext, native and emulated: 1 translated, 1 pass spirv-val, 1/1 passed, with the same eight words.
  • CPU: tests/semantic/test_late_ext_fixture.py 4 OK, tests/semantic/regen_fixtures.py --check clean, tests/test_shader_checks.py 75 OK, tests/test_run_gpu_tests.py 40 OK.
  • rdna2spirv: an out-of-range s_buffer_load reads through the buffer's base (llvmpipe segfault) #4573, the llvmpipe fix for the out-of-range s_buffer_load in word 6, is still open and not in d0835dd9. On RADV, word 6 reads 0 without it. I did not run llvmpipe here.

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

@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

Thanks @lunarminus (Radeon 760M, native and emulated, the per-test comparison with main). Nothing is pending here besides #4573, which this fixture needs on llvmpipe.

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

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 1b5f6c0 on Intel UHD Graphics 630 (CFL GT2), Mesa ANV, subgroup 8..32: run_gpu_tests.py --filter cs_w32_late_ext prints "PASS cs_w32_late_ext 305419896 305441656 4294901761 32767 32768 32768 0 4008636142" and "1/1 passed", which is 0x12345678 0x1234AB78 0xFFFF0001 0x7FFF 0x8000 0x8000 0 0xEEEEEEEE. With LEONIDA_VK_DEVICE=NoSuchDevice it fails with "no Vulkan physical device matches". tests/semantic test_late_ext_fixture runs 4 tests OK, and tests/test_shader_checks.py and tests/test_run_gpu_tests.py pass. The full tests/semantic suite and the full GPU suite were not run.

AI-assisted.

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

Copy link
Copy Markdown

Tested f3a6f326 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_late_ext 305419896 305441656 4294901761 32767 32768 32768 0 4008636142

AI-assisted (Claude Code).

@Itschotsch

Copy link
Copy Markdown

Tested f3a6f32 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).

# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/semantic/regen_fixtures.py
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.