Skip to content

test(semantic): add comprehensive semantic tests and reference oracle for ds_min_rtn_u32 - #2895

Merged
ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-min-rtn-u32
Nov 22, 2026
Merged

ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-min-rtn-u32

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Add comprehensive semantic tests and reference mathematical oracle for RDNA2 Local Data Share (LDS) atomic unsigned 32-bit minimum with return (ds_min_rtn_u32) in tests/semantic/test_lds_min_rtn_u32.py.

The 8-commit suite covers:

  1. Reference mathematical oracle (oracle_min_u32, ref_ds_min_rtn_u32) and architectural model (LDSMemory) with 64 KiB capacity, 32-bank layout, dword alignment (bottom 2 bits dropped), and 16-bit unsigned offset handling.
  2. Symbolic AST opcode definitions and typed expressions (DSOpcode.DS_MIN_RTN_U32, Register, VGPR, OffsetImmediate, DSMinRtnU32Instruction, Program).
  3. Deterministic scalar instruction interpreter (ScalarThreadState, ScalarDSInterpreter) with register file, memory state, and program chain execution.
  4. SIMD multi-lane divergence and 32/64-bit EXEC masking across Wave32 and Wave64 execution with concurrent atomic collision serialization and inactive lane preservation.
  5. Register aliasing and in-place operand preservation (vdst == vaddr, vdst == vdata0, vaddr == vdata0, vdst == vaddr == vdata0, and canary VGPR isolation).
  6. Condition codes, status flags (mem_updated, mem_unchanged, zero_flag, sign_flag), bank conflict analysis (stride 1 vs stride 32), and scalar/vector VCC isolation.
  7. IEEE 754 boundary extremes (float +/-0.0 ordering, infinities, sNaN/qNaN bit preservation without quieting, subnormals without flush-to-zero) and integer boundary extremes (0, 1, 0x7FFFFFFF, 0x80000000, 0xFFFFFFFF).
  8. Negative controls, syntax rejection (out-of-range registers, invalid immediate offsets, invalid wave sizes, missing destination), and mutation detection (signed comparison, max instead of min, new-val return, dropped offset, inactive lane leak, omitted memory writeback).

Tested

  • Pre-flight test suite execution:
    • python -m compileall -q tests
    • python -I tests/semantic/test_lds_min_rtn_u32.py (46/46 tests passing)
    • python -m unittest -v tests/semantic/test_lds_min_rtn_u32.py (46/46 tests passing)
  • Environment: AI-assisted development on Windows 11.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@Yourrespawn

Copy link
Copy Markdown
Contributor

Same structural note as #2819: ds_min_rtn_u32 is a real RDNA2 opcode (llvm-mc gfx1030 assembles it), but the suite imports no repo code — it checks its in-file oracle against its in-file interpreter, so it can neither regress nor verify the translator. The repo CPU-checks the LDS atomics and has hardware-verified rows for the family in docs/design.md. Differential wiring against tools/rdna2spirv.py + tests/semantic/spirv_mini_interp.py is what would make it contribute.

AI-assisted (ZCode agent): the verification was executed by a coding agent on this machine.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE; integer op), through raw hw_oracle kernels, one lane, LDS dword seeded, then ds_min_rtn_u32 v4, v1, v3 and a ds_read_b32: every (memory M, data D) pair of {0, 1, 2, 5, 0x7fffffff, 0x80000000, 0xfffffffe, 0xffffffff, 0x12345678}, 81 cases. The returned register is the old word and the word afterwards is the unsigned minimum in all 81. I compared the instruction's behaviour with the formula in this PR's header; the PR's test file and any translation were not part of this run. The script is local, not pushed. 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.

4 participants