Skip to content

test(semantic): add Bundle 5 LDS swizzle and sub-dword memory suite - #5866

Open
slopgobblercobbler wants to merge 29 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-memory-swizzle-bundle
Open

slopgobblercobbler wants to merge 29 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-memory-swizzle-bundle

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

Description

This pull request implements Bundle 5: LDS Swizzle & Sub-Dword Memory Suite in tests/semantic/test_lds_memory_swizzle_bundle.py.

The test bundle provides 28 atomic commits (4 granular commits per opcode) covering 7 LDS swizzle and sub-dword memory instructions:

  1. ds_swizzle_b32: cross-lane quad permute (QUAD_PERM) and bitmask permute (BITMASK_PERM)
  2. ds_permute_b32: forward (scatter) cross-lane permute
  3. ds_bpermute_b32: backward (gather) cross-lane permute
  4. ds_read_u16: 16-bit unsigned sub-dword load with zero extension
  5. ds_read_i16: 16-bit signed sub-dword load with sign extension
  6. ds_write_b16: 16-bit halfword store with byte preservation
  7. ds_write_b32: 32-bit dword store into LDS

For each opcode, the four commit stages cover:

  • Reference mathematical oracle and architectural model
  • Symbolic AST opcode definitions and typed execution expressions
  • SIMD multi-lane divergence and EXEC masking validation
  • Translator integration and SPIR-V code generation verification

Verification

  • Standard library Python only (python -I, unittest, struct, math)
  • Zero game data, keys, or proprietary binaries
  • Pre-flight tests verified:
    • python -m compileall -q tests
    • python -I tests/semantic/test_lds_memory_swizzle_bundle.py (40 tests passing)
    • python -I tests/test_semantic_translator_use.py (all tests passing)
  • AI-assisted: Yes

@kapitche

Copy link
Copy Markdown
Contributor

Tested 578dcc0 merged with main 561b65a on Linux (WSL2), Python 3.12.16 -I: pass

tests/semantic/test_lds_memory_swizzle_bundle.py: 40 run, 40 passed, 0 failed. Negative control: the PR is test-only, so the new tests also pass on main as coverage; I mutated tools/rdna2spirv.py so ds_read_i16 zero-extends instead of sign-extending, and 1 of the 40 failed (file restored afterwards).

@BeegSchmooze

Copy link
Copy Markdown

Mutation check of the current head with a generic run (tools/semantic_mutants.py, #6548), per op: --op ds_read_u16, --op ds_write_b16, --function swizzle, --function ds_permute. The file passes as submitted. Windows 11, Python 3.13.

Survivors that matter:

  • The halfword write across a dword boundary (ds_write_b16 at an address ≡ 3 mod 4, lines ~4455–4478): the whole path survives, including the "byte 3" test, the in-bounds/drop logic and the high byte's write into the next dword. No case writes a halfword at byte 3. A translated ds_write_b16 to address 3, followed by ds_read_b32 of dwords 0 and 1, would pin it.
  • offset: (addr + off → addr - off in both ds_read_u16 and ds_write_b16): every case uses offset 0. One case with offset:2 would catch it.
  • ds_permute_b32 from an inactive lane (line ~5169): if an inactive lane published target lane 0 instead of "no target", nothing would fail. Every translated case runs with full EXEC (the same gap as test(semantic): add comprehensive semantic tests and reference oracle for ds_permute_b32 #5813).

Not worth a case: & 31 → & 30 on the bit offset (always a multiple of 8, so equivalent); swizzle BITMASK_PERM OR → XOR (the pattern's OR and AND bits never overlap); the SWAP/REVERSE/BROADCAST lines of swizzle(), which this file doesn't claim; and ds_permute's wave64-emulation path, which a wave32 test can't reach.

AI-assisted (Claude Code). No game files.

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