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 2 commits into
ItsNotRexed:mainfrom
LouisRiverstone:gpu-test-late-ext
Open

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

9 participants