Skip to content

rdna2spirv: reject gds modifier on all ds_* instructions - #7995

Open
DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:fix/rdna2-ds-reject-gds
Open

DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:fix/rdna2-ds-reject-gds

Conversation

@DenRakEiw

Copy link
Copy Markdown
Contributor

Claim: #7804 (comment)

Summary

Reject the gds (Global Data Share) modifier on all ds_* instructions in tools/rdna2spirv.py so GDS operations are never silently miscompiled to workgroup-local %lds:

  • Reject "gds" in mods with Unsupported(op + " gds") in Gen._insn (also covering ds_nop gds) and defensively at the top of every ds_* lowering path: lds_op, ds_permute, ds_bpermute_b32, swizzle, and gs_ds.
  • Simplify the existing gds check inside ds_read_addtid_b32 / ds_write_addtid_b32 now that lds_op rejects gds upfront.
  • Add tests/semantic/test_ds_gds_rejection.py covering:
    • gds rejection across DS reads, writes, atomics, cross-lane ops (ds_swizzle_b32, ds_permute_b32, ds_bpermute_b32), ds_nop, and GS gs_ds;
    • direct handler checks on lds_op, ds_permute, swizzle, and gs_ds;
    • raw binary llvm-mc -triple=amdgcn -mcpu=gfx1030 -> rdna2_decode -> rdna2spirv round-trips with DS bit 17 (GDS) set;
    • positive controls verifying non-gds DS ops still translate, pass spirv-val --target-env vulkan1.2, and execute identically in spirv_mini_interp.

Verification

  • python -I -m unittest discover -s tests/semantic -p test_ds_gds_rejection.py -v (with llvm-mc and spirv-val 1.4.363.0): 9/9 passed.
  • python -I -m unittest discover -s tests/semantic -p "test_ds*.py" -v: all passed.
  • python -I -m unittest discover -s tests/semantic -p "test_lds*.py": 376 tests (OK, skipped=3).
  • python -I -m compileall -q tools tests and git diff --check origin/main..HEAD: clean.

AI-assisted (Gemini 4 Neon).

@ihymonte ihymonte left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested b2f0de2 merged with main dde82f2 on macOS (Apple Silicon arm64), Python 3.12.16 (CPU only, no llvm-mc, no SPIRV-Tools, no GPU, no game files): pass

  • python3.12 -I tests/semantic/test_ds_gds_rejection.py: 9 run, 7 passed, 2 skipped (needs llvm-mc), 0 failed.
  • Related suites: test_ds*.py (40 run, 38 passed, 2 skipped) and test_lds*.py (376 run, 372 passed, 4 skipped).
  • Negative control (reverted tools/rdna2spirv.py only): test_ds_gds_rejection.py fails as expected (34 failures across test_cs_ds_gds_rejected, test_gs_ds_gds_rejected, and test_direct_handlers_reject_gds, 2 skipped).
  • python3.12 -m py_compile and scripts/check_no_game_data.py on both touched files: clean.
  • Code read: _insn rejects ds_* + gds ahead of NOOPS (catching ds_nop gds) and stage dispatch, with matching defensive guards in swizzle, lds_op, ds_permute, ds_bpermute_b32, and gs_ds.

AI-assisted (Antigravity).

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested b2f0de2 on Windows 11 (26200.9974), Python 3.12.0, llvm-mc AOMP 16.0-45 (gfx1030), spirv-as/spirv-val 1.4.341.0: pass.

  • python -I -m unittest discover -s tests/semantic -p test_ds_gds_rejection.py -v: 9/9 OK.
  • ... -p 'test_ds*.py': 40/40 OK. ... -p 'test_lds*.py': 376/376 OK.
  • Negative control (merge-base dde82f27e, old tools/rdna2spirv.py, the head's test file): 9 tests, 55 subtest failures, all Unsupported not raised — the old translator really did accept every GDS form and lower it to local LDS, including ds_nop gds and the GS path.
  • Host note, not a defect: this shell sets LLVM_MC to a path that no longer exists, so the first run errored in subprocess.run. The class is correctly guarded with skipUnless(_llvm_mc_cmd() is not None), and a set-but-stale LLVM_MC is treated as configured exactly like test_image_cube_store_glc.py; unsetting it gives the 9/9 above.
  • Code read: _insn rejects every ds_* with gds before dispatch, so ds_nop and future DS ops are covered; lds_op, swizzle, ds_permute, ds_bpermute_b32 and gs_ds keep their own guard for direct calls and the GS path. The addtid branch's removed duplicate check is now unreachable.
  • compileall, check_no_game_data.py, git diff --check: pass.

Synthetic instruction sequences only; no game data, no GPU.

AI-assisted.

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.

3 participants