Skip to content

Translator: ds_read2_b64, ds_write2_b64 and their st64 forms - #810

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
LouisRiverstone:lds-read2-write2-b64
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
LouisRiverstone:lds-read2-write2-b64

Conversation

@LouisRiverstone

@LouisRiverstone LouisRiverstone commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Depended on #592, which is now merged; the branch is up to date with main, so the diff is this PR's change only.

tools/rdna2spirv.py translates ds_read2_b32 / ds_write2_b32 and their st64 forms, but raises Unsupported on the 64-bit versions: ds_read2_b64, ds_write2_b64, ds_read2st64_b64 and ds_write2st64_b64. They aren't in the translated corpus, so this is future-proofing. Claimed in #634.

Change

  • tools/rdna2spirv.py: the b64 forms share the b32 code.
    • The two elements are at vaddr + offset0 * unit and vaddr + offset1 * unit. unit is the element size, 8 bytes for b64, and ×64 for st64 (RDNA2 ISA, DS 2-address forms).
    • A b64 element is two consecutive dwords, low first. read2_b64 fills v[d:d+3], and all four loads happen before the first write, so a vdst that overlaps vaddr is safe. write2_b64 takes two VGPR pairs.
    • The b32 forms behave as before.
  • tests/semantic/test_lds_read2_write2_b64.py (new, stdlib unittest):
    • Each case runs a compute listing as one invocation on the CPU, with a 4 KiB LDS from a synthetic header.
    • The write2 forms are checked by reading each dword back with ds_read_b32.
    • The read2 forms are checked after seeding LDS with ds_write_b32.
    • A write2_b64 → read2_b64 round trip uses swapped offsets.
    • Offsets go up to 255 elements, including the 512-byte stride of st64, all compared with a plain-Python LDS model.

Tested

  • python -I -m unittest discover -s tests/semantic: all pass, including the existing LDS tests. Without the translator change, the new file has 15 errors (Unsupported).
  • python -I tests/test_lds_fuzz.py passes. python -m compileall -q tools tests passes. Not run on a GPU, and no game files used.
  • tools/lds_fuzz.py doesn't generate the b64 2-address forms yet. That could be a follow-up for FUZZ-6.

AI-assisted (Claude Code): it wrote the change and the tests, and ran the checks listed above.

All four raised Unsupported. They access two 64-bit elements at
vaddr + offset0 * unit and vaddr + offset1 * unit, with unit = 8 bytes (x64
for st64), each element two consecutive dwords; read2 fills v[d:d+3] after
all loads, write2 takes two VGPR pairs. The b32 forms share the code with
unit 4, unchanged.

tests/semantic/test_lds_read2_write2_b64.py runs compute listings on the CPU
(one invocation, LDS as a Workgroup variable from ItsNotRexed#592) and checks every
dword against a plain-Python LDS model.
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026

@quackottu quackottu 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 aae7b07 on NVIDIA GeForce RTX 5070 (subgroup 32), driver 621.24, Windows 11 Pro (26300), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (built with scripts/build_llvm_mc.ps1), scripts/run_gpu_tests.py:

  • native: 71/98 passed, 27 skipped (main 8df277f here: 64/91 passed, 27 skipped, all wave64 tests needing a 64-wide subgroup)
  • LEONIDA_W64_EMULATE=1: 98/98 passed (main here: 91/91)
  • python -m unittest discover -s tests/semantic: Ran 980 tests in 192.604s OK

@ItsNotRexed
ItsNotRexed merged commit 38baf0c into ItsNotRexed:main Nov 22, 2026
9 checks passed
@esteban-dcp

Copy link
Copy Markdown

Tested aae7b07 on two GPUs, Linux 7.3.5 (CachyOS): pass.

  • NVIDIA RTX 4050 Laptop (Ada), driver 620.73.04, subgroup 32: 100 shaders: 100 translated, 100 pass spirv-val; 71/98 passed, 27 wave64 skipped; with LEONIDA_W64_EMULATE=1: 98/98 passed
  • AMD Radeon 740M (RDNA3, RADV, Mesa 26.3.1), subgroup 32..64: 98/98 passed
  • This PR adds no GPU test of its own, so this checks that it breaks nothing in the existing suite on either vendor (the test programs were built from this branch, which is 92 commits behind main).
  • CPU: unittest discover -s tests/semantic 980 OK

python -I scripts/run_gpu_tests.py --build runtime/build/linux on the PR head, VK_LOADER_DRIVERS_SELECT pinning each GPU (device line checked), VK_LOADER_LAYERS_DISABLE=~implicit~. 0 failures. (An earlier run of mine was on the previous head and I discarded it.)

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.

4 participants