rdna2spirv: translate FLAT loads and stores as global accesses #65
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/65"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:11:25Z.
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Resubmission of
#8823, unchanged (headfbe718a46).#8823was closed at 22:39 UTC during the move to ProjectLeonida, with no comment and notriage:line, and the API refuses to reopen it. It had about ten independent passes (CPU and GPU on Linux, Windows and macOS; see#8823's comments). On today'smain2d53a8055the branch merges without conflicts, and its 12test_flat_memtests pass. Originally claimed in#8683: https://github.com/ProjectLeonida/Leonida/issues/8683#issuecomment-7111644742What
flat_load_*andflat_store_*used to reach the translator's finalUnsupported(op).tools/isa_coverage.pylisted all 54 FLAT opcodes as unknown, and no open PR translates them.Gen.flat_memnow emits the same code as the GLOBAL access withoff, throughGen.global_mem/Gen.global_sub. That covers:dword,x2,x3,x4);Inactive lanes don't access memory, as with
global_*.Why global
off.src_shared_base/src_private_base. The translator refuses those operands, so a program that builds an aperture address from them is refused as a whole. A test covers this.docs/design.mdrow says so.Refused (
Unsupported)FeatureFlatSegmentOffsetBug("inst_offset is ignored when flat instructions access global memory") and folds no offset into a FLAT access there.flat_atomic_*.Also changed
read_before_write_vgprs): it counts thevdstof a FLAT d16 load as read, the same as forglobal_load_*_d16.flat_storelike the other stores.tools/ab_control_flow.py: it listsflat_storeamong the memory writes the harness can't set up, next toglobal_store.docs/design.md.Tests
tests/semantic/test_flat_mem.pyis new. Each program is translated, run withspirv_mini_interp, checked against words worked out by hand, and checked to leave the same memory as itsglobal_* ..., offspelling. It covers:v_cmpx;What I ran, on macOS 26 with an Apple M4 (CPU only) and Python 3.12.13:
python -I scripts/run_semantic_tests.py -j 4 tests/semantic: 448 files, 5,969 tests; 446 files pass. The two that fail,test_image_atomics_guard(47) andtest_image_store_d16(1), fail the same way onmain867d922f.tests/test_isa_coverage.py,tests/test_semantic_translator_use.py,tests/test_ab_control_flow.py,tests/test_design_contract_rows.py,tests/test_docs_repo_paths.py: all pass.tests/test_docs_design_rows.pyandtests/test_docs_links.pyfail the same way onmain(ondocs/README.mdanddocs/dev-tools.md, which this PR doesn't touch).scripts/check_no_game_data.pypasses on the changed files.Not GPU-verified. No game files were used.
AI-assisted (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-24T02:19:20Z.
macOS arm64 verification (Apple M3 Pro) — the FLAT→GLOBAL mapping is right, the new test bites, and the merged tree is identical to
mainrow for row on both driversHead
fbe718a46, branch point867d922f0; I merged it onto currentmain(9ec34cdff) asd238c4e80with no conflicts, and everything below is that merged tree. 4 files +214/−3. Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2, llvm-mc 23.1.5 (AMDGPU), Apple clang 21.0.0, MoltenVK 1.4.0 and KosmicKrisp (Mesa 26.3.0).d238c4e80main9ec34cdfftests/semantic/test_flat_mem.pyscripts/run_semantic_tests.py tests/semantictest_exec_computed,test_image_atomics_guardrun_gpu_tests.py(all 248 cases), MoltenVKrun_gpu_tests.py(all 248), KosmicKrisptest_isa_coverage,test_semantic_translator_use,test_ab_control_flow,test_design_contract_rows,test_docs_repo_paths,test_docs_design_rows,test_docs_linksThe GPU rows are identical line for line on both drivers after normalising the temporary work paths: no fixture changed verdict, value or skip reason. No fixture uses FLAT yet (0
.asmfiles matchflat_), so that is a regression check on everything else, not a hardware test of this rule — which is why the design row's "Not GPU-verified" is the honest label.The negative control is the base translator: 36 of the 12 tests' subtests raise
Unsupportedthere and 2 assert failures remain, against 0 at this head. And the new test is not only "it translates": every program is also run as itsglobal_* ..., offspelling and the memory must match, so the assertion is equivalence between the two forms, not a golden number.The reuse is the right shape.
flat_memmapsflat_<x>toglobal_<x>and hands{"k":"special","t":"off"}as the SADDR (tools/rdna2spirv.py:3558-3595), which lands inglobal_address'soffbranch — the 64-bit VGPR pair path (:3365-3368) that the GPU fixtures already exercise forglobal_*. So the heap-base translation, the inactive-lane gate and the sub-dword byte merging are the same code, not a parallel implementation. Three things I checked by translating, beyond the test file:flat_load_dword v5, v[3:4]) translates — the code usesvaddr["r"]andr + 1, and every test case usesv[2:3];glc slcon a load andglconflat_store_dwordx4translate, i.e. the cache modifiers reach the GLOBAL path instead of being refused;ldscannot appear through the assembler at all (llvm-mc rejects it as an operand forflat_load_dword), andglobal_memrefuses the modifier anyway (:3475), so the one FLAT bit that would make an access LDS-relative is unreachable.The d16 forms go through
GLOBAL_SUB, the first-read analysis counts the destination half (:15871-15873), andflat_atomic_*and a 32-bit address fall through toUnsupported— all covered by the test.Two small suggestions, neither blocking.
v[3:4]) and one withglc/slc, since both translate and neither is pinned; the current test file only ever spellsv[2:3]and no cache modifier.cs_global_*pattern, because the CPU test proves FLAT ≡ GLOBAL in the translator — not that the console GPU's global path is what the console's FLAT does. The design row already says this; a fixture would turn it into a GPU-checked row.Also worth saying for the carried-over context: the original PR's macOS pass was CPU-only, so this is the first time the rule has been run against a merged tree on an Apple GPU here, and it costs nothing: both suites are unchanged.
No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T17:01:43Z.
@tiagonogueiraa-bit this carried-over PR (your old PR 9790) now conflicts with
main(tools/rdna2spirv.py,docs/design.md). Could you mergemaininto it, by pushing to its branch or in your own PR from it (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/65#issuecomment-7120017403. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:40:20Z.
Carried as #2728 because of the conflict with main after #2566; @tiagonogueiraa-bit, if you come back, say so and the carry is dropped.