Skip to content

test(semantic): add comprehensive semantic tests and reference oracle for buffer_atomic_umax - #2877

Merged
ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-buffer-atomic-umax
Nov 22, 2026
Merged

ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-buffer-atomic-umax

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

Summary

Add comprehensive semantic interpreter tests and reference mathematical oracle for RDNA2 buffer_atomic_umax (Untyped buffer memory unsigned atomic maximum) in tests/semantic/test_buffer_atomic_umax.py.

Implemented across 8 atomic commits following Conventional Commits:

  1. test(semantic): add reference mathematical oracle and architectural model for buffer_atomic_umax
  2. test(semantic): add symbolic AST opcode definitions and typed expressions for buffer_atomic_umax
  3. test(semantic): add deterministic scalar instruction interpreter for buffer_atomic_umax
  4. test(semantic): add SIMD multi-lane divergence and 32/64-bit EXEC masking for buffer_atomic_umax
  5. test(semantic): add register aliasing and in-place operand preservation for buffer_atomic_umax
  6. test(semantic): add condition codes, status flags, and carry/borrow generation for buffer_atomic_umax
  7. test(semantic): add IEEE 754 boundary extremes, subnormals, and NaN handling for buffer_atomic_umax
  8. test(semantic): add negative controls, syntax rejection, and mutation detection for buffer_atomic_umax

Key Architectural Semantics Tested

  • MUBUF buffer_atomic_umax addressing & bounds check: Computes effective_offset = soffset + inst_offset + (vaddr if offen else 0). Validates hardware suppression when effective_offset + 4 > NUM_RECORDS and zero-return under glc.
  • Unsigned comparison: Tests unsigned integer maximum max(old_val, comp_val) over [0, 2^32 - 1], confirming that 0x80000000 > 0x7FFFFFFF and 0xFFFFFFFF is the unsigned maximum.
  • GLC pre-operation return: Validates returning old_val to vdata when glc is active, and preserving vdata untouched when glc is omitted.
  • Wave32 & Wave64 SIMD execution: Validates multi-lane divergence and inactive lane preservation under partial / zero EXEC masks.
  • Register file isolation & aliasing: Tests in-place aliasing (vdata == vaddr) and preservation of unmodified VGPRs and SGPR resource descriptors.
  • Negative controls & mutation testing: Verifies rejection of invalid register indices, illegal operand types, wave sizes, and catches intentional mutations (OOB omission, post-op leak, signed comparison flip, min/max flip, exec leak).

Verification

  • Standard Library Python only (python -I, unittest, struct, dataclasses, enum)
  • Python 3.9+ compatible (from __future__ import annotations)
  • Zero game data or external binaries
  • Pre-flight test suite: 41 unit tests executed and passed (100% OK)

@Yourrespawn

Copy link
Copy Markdown
Contributor

Same structural note as the family comments (#2824, #2819): unlike the five PRs in this batch that test nonexistent opcodes, buffer_atomic_or is real — but the suite imports no repo code (only stdlib), so it checks its in-file oracle against its in-file interpreter and can neither regress nor verify the translator. Same: the repo CPU-checks these ops today and #2821 adds the GPU fixture pass for them. Wiring it differentially against tools/rdna2spirv.py + tests/semantic/spirv_mini_interp.py is what would turn it into a check.

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

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE; integer op), through raw hw_oracle kernels, one lane, a raw V# over the output buffer, the dword seeded with a global store, then buffer_atomic_umax v1, off, s[4:7], 0 offset:16 glc and a coherent read-back: every (M, 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 maximum 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