Repository navigation
Conversation
|
Verified on main a73a57e (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly into main. With this PR: test_buffer_load_lds 10 OK and test_buffer_load_sub 10 OK (unittest discover in tests/semantic). test_buffer_load_lds.py against main's translator: 19 errors, so it fails on main and passes with the change. compileall clean. Not run: the whole semantic suite and the translated / spirv-val counts over a corpus (no game data here). Note for review: it conflicts with #2164 (tools/rdna2spirv.py and tests/semantic/test_buffer_load_sub.py), so whichever lands later needs a rebase. AI-assisted: yes (Claude Code) |
|
Tested
The new AI-assisted (Claude Code). No game data. |
wavehs
left a comment
There was a problem hiding this comment.
macOS arm64 / GPU check of #2168 (SHADER-MUBUF-LDS-DMA). A translator rule plus a GPU fixture; both run here on two drivers.
Tested head 462137455 merged onto main bdbc7e923 as merge cf10651bf (clean, no conflicts).
Environment: Apple M3 Pro, arm64, macOS 27.2.1, Apple clang 21.0.0, CMake 4.5.0, CPython 3.15.2, llvm-mc 23.1.5, SPIRV-Tools v2026.4, MoltenVK 1.4.0, KosmicKrisp = Mesa 26.3.0.
The fixture runs and the controls bite
cs_buf_ldson the merge, MoltenVK and KosmicKrisp, identical output on both:0x5eed0000 0x80 0xffffff80 0x5eed0001 0x5eed0001 0x81 0xffffff81 0x5eed0000- dword/ubyte/sbyte at M0 64/192/320 in their own lanes, and lane 0 reading lane 1's dword slot and back. PASS1/1both times, which is the per-lane address and theM0[15:0] + TIDinWave*4term both being exercised.- Full suite on the merge, MoltenVK:
279 shaders: 278 translated, 278 pass spirv-val,196 / 3 / 70of 269, the same three failures as main's baseline on this driver (cs_fma_fused,cs_imgatomic_ext,ps_ssharp). The single added pass over the baseline (195 / 3 / 70of 268) is the new fixture;ps_ij_computedis still the expected refusal under the f16 fallback in this tree (#2239). - Semantic:
tests/semantic/test_buffer_load_lds.py10 tests OK; whole suite501 files, 6377 tests, 0 files failed(main 500 / 6367, so the new file and its 10 cases, nothing else changed). - NC 1 (translator only, fixture and tests kept):
FAILED (errors=19)in the new semantic file, GPUFAIL cs_buf_lds missing .spv (translation failed)- the oldbuffer_load ... lds formrefusal. - NC 2 (drop the
TIDinWave*4scale, a plausible address bug): semantic file 3 failures; GPUFAIL ... 0x5eed0000 0x80 0xffffff80 0x5eed0004 0x5eed0004 0x84 0xffffff84 0x5eed0000, i.e. the lanes collide and lane 1 reads lane 4's slot. - NC 3 (drop the
offset:Nterm from the LDS address only): semantic file 1 failure, so theinst_offsethalf of the formula is pinned by a test too.
Finding: ms is allowed but gets no LDS bound, unlike cs
buffer_load_lds passes self.lds_declared if self.stage == "cs" else None as the lds_access bound (tools/rdna2spirv.py:2756). For a mesh shader, lds_declared is never set (:18704 is inside the cs block), lds_bound stays None, so lds_access emits the bare OpAccessChain with no range check (:5259-5260). The Workgroup array is sized from ms's own metadata (:18659-18672: PSV0 shared bytes rounded up to a power of two, and only ds_* constant offsets grow it), so a buffer_load_dword ... lds whose M0 points past the declared shared size becomes an out-of-bounds access chain - undefined in SPIR-V - where the console drops the write, which is exactly what the cs path models by bounding to the RSRC2 allocation. M0 is a runtime register, so no constant scan can prove it in range. Either bound the ms write by the array size the translator itself chose (self.lds_dwords, available before translation) or keep lds refused on ms until it is measured; the row says "CS/MS only" and the GPU fixture and all ten semantic cases are compute, so mesh is currently an untested promise. Related docs point: the row quotes LDS_BASE in the address formula but the code uses 0 (:2751-2768); if LDS_BASE is a stage-dependent base and not always 0 (the mesh path is the one to suspect), that should be stated rather than left implicit.
Finding (test gap, not a defect): the out-of-range path is CPU-only
The row's "an out-of-range read supplies 0, which the lane writes to LDS" is tested by tests/semantic/test_buffer_load_lds.py through the interpreter, but cs_buf_lds.asm has no out-of-range lane, and no device can tell us whether RDNA2 writes that 0 to LDS or skips the write. I believe the 0-write reading is right (the MUBUF bounds check zeroes the data before it reaches the LDS path), but it is an assumption like the tfe status one in #2164, and it silently clobbers a neighbour's LDS slot if wrong. A one-lane OOB variant of the fixture (or a tools/hw_oracle probe on gfx1036) would close it.
Nit: for the three-operand listing the translator prepends None only in its local argument list (tools/rdna2spirv.py:2740-2742); ins["args"] still holds [vaddr, srsrc, soffset], so vgpr_dest_registers and read_before_write_vgprs see the vaddr as the destination (vaddr gets marked written and is never counted as a read). No current analysis runs on cs/ms instructions, so nothing is miscompiled today - but if one ever does, this is the same class of operand-model slip as the tfe off-by-one I reported on #2164. Normalising the stored args once, at decode, would make both go away.
Not run: the full corpus (needs a game copy), native RDNA2 hardware, and a mesh-shader draw (no MS fixture and no mesh support in this harness on Metal). The change is translator-only, so no C++ test is affected.
python -I scripts/check_no_game_data.py on all seven changed files: clean.
No game files. AI-assisted.
…,sshort} ... lds (SHADER-MUBUF-LDS-DMA) The translator refused the lds modifier on buffer loads. RDNA2 ISA 8.1.9 (Memory Buffer Load to LDS): the fetched value goes to LDS, not a VGPR, at LDS_BASE + M0[15:0] + inst_offset + TIDinWave*4. The read is buffer_address's, bounds-checked like the VGPR forms (out of range supplies 0), sub-dword values are zero/sign-extended, and the LDS write runs in active lanes only, dropped outside the wave's LDS allocation. dwordxN, format, tfe with lds and stages other than CS/MS stay refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
4621374 to
5e7ab21
Compare
|
Rebased onto current Generated by Claude Code |
Claimed in the coordination issue as: SHADER-MUBUF-LDS-DMA (#1608)
What and why
The translator refused the
ldsmodifier on MUBUF loads (raise Unsupported(op + " form")). With it, RDNA2 loads gostraight to LDS ("Memory Buffer Load to LDS", RDNA2 ISA 8.1.9), the way compilers stage data into shared memory.
buffer_load_dword,buffer_load_ubyte,buffer_load_sbyte,buffer_load_ushort,buffer_load_sshortwith
lds, in compute and mesh shaders.LDS_BASE + M0[15:0] + inst_offset + TIDinWave*4(the ISA figure; TIDinWaveis added on the LDS path whatever the V#'s ADD_TID_ENABLE says). The VDATA field names the M# and is ignored; the
llvm-mc spelling omits it, so a three-operand listing is accepted too.
buffer_address's, bounds-checked exactly like the VGPR forms; an out-of-range read supplies 0,which is what the lane writes. Sub-dword values are zero- or sign-extended to the stored dword (the byte/short read
is shared with
buffer_load_subthrough a newbuffer_sub_valuehelper).lds_access, so it is dropped outside the wave's LDSallocation (RSRC2 LDS_SIZE for compute), like the
ds_*stores.buffer_load_dwordxN ... lds(not in the ISA's lds subset),buffer_load_format_* ... lds,tfewithlds, and other stages.Tested
runtime/test/shaders/cs_buf_lds.asm(registered incheck.pyandrun_gpu_tests.py): 32 lanesload a dword, a ubyte and an sbyte into three M0-based LDS regions,
s_waitcnt+s_barrier, then read backtheir own and their neighbour's (
t^1) slots.run_gpu_tests.py --filter cs_buf_lds: PASS on an RTX 5090(NVIDIA 595.99.02, Ubuntu 26.04) and on the Ryzen 9 9950X's Radeon iGPU (RADV, Mesa 26.0.8).
tests/semantic/test_buffer_load_lds.py(10 tests throughspirv_mini_interp): per-lane slots,offset:andM0[15:0], the three-operand form, u/s byte/short extension, out of range -> 0, inactive lanes write nothing, theout-of-allocation drop, the refused forms.
python -I scripts/run_semantic_tests.py tests/semantic: 496 files, 6,343 tests, 0 failed.pytest tests/test_translate.py: 714 passed; the 2 failures arecs_dpp_cmp.asmwith LLVM 21, failing on main too(tests: the pytest helper takes a text-only sample's lines as its listing, as run_gpu_tests.py does (TEST-TRANSLATE-TEXT-ONLY) #1375).
python -m compileall,tests/test_ci_registration.py: clean.tools/hw_oracle) — the only RDNA2 GPU here drives a display.GPUs tested: NVIDIA GeForce RTX 5090 (595.99.02, Ubuntu 26.04.1); AMD Radeon iGPU of the Ryzen 9 9950X (RADV, Mesa 26.0.8)
AI-assisted: yes (Claude Code, with a Devin draft reviewed against the ISA, rebased and GPU-tested)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP