Skip to content

test(semantic): add comprehensive semantic tests and reference oracle for v_interp_p2_f16 - #2825

Merged
ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-interp-p2-f16
Nov 22, 2026
Merged

ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-interp-p2-f16

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Adds comprehensive semantic interpreter tests and reference mathematical oracle for v_interp_p2_f16 (half-precision parameter interpolation phase 2) in tests/semantic/test_interp_p2_f16.py.

Coverage includes:

  • Reference Mathematical Oracle & Architectural Model: IEEE 754-2008 binary16 half-precision arithmetic, attribute buffer caching (LDS parameter cache), low/high half attribute selection, accumulator addition with single rounding to f16, and untouched 16-bit destination half preservation (per SHADER-430 / gfx1036).
  • Symbolic AST Opcode & Typed Expressions: ASTInstruction AST node, ASTOperand, AttributeRef, source modifiers (abs, neg, high), destination half selection, and clamp.
  • Deterministic Scalar Interpreter: Register file state modeling (InterpolationRegisterFile, AttributeBuffer, SGPRs) and deterministic scalar step execution with textual assembly parsing.
  • SIMD Multi-Lane Divergence & EXEC Masking: Wave32 and Wave64 execution with arbitrary 32-bit and 64-bit EXEC masks, ensuring inactive lanes preserve destination contents untouched.
  • Register Aliasing & In-Place Preservation: Handling dst == src_j, high/low f16 interleaving into the same 32-bit register, and untouched half preservation across masked wavefront lanes.
  • Condition Codes & Status Flags: IEEE 754 exception flags (invalid_op, overflow, underflow, inexact) and condition codes (zero, negative, nan), alongside VCC / SCC preservation and condition mask generation.
  • IEEE 754 Boundary Extremes: Exhaustive subnormal arithmetic, signed zero rules, infinities, quiet/signaling NaN quieting, and clamp mapping of NaNs to +0.0.
  • Negative Controls & Mutation Detection: Syntax rejection for illegal opcodes, malformed register tokens, destination modifiers, and detection of 5 distinct computational/architectural mutants.

Tested

  • Pre-flight test suite execution in worktree:
    • python -m compileall -q tests (clean)
    • python -I tests/semantic/test_interp_p2_f16.py (32/32 tests passing)
    • python -m unittest discover -s tests/semantic -p "test_interp_p2_f16.py" (32/32 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. (N/A: Test-only PR for semantic verification).

@Yourrespawn

Copy link
Copy Markdown
Contributor

Structural review (same family as the #2824 finding): v_interp_p2_f16 is a real RDNA2 opcode (llvm-mc gfx1030 recognizes it), and the repo already translates and pins it — tools/rdna2spirv.py handles it, with docs/design.md rows 276 (operand guards, SHADER-177), 353 (f16 narrowing rule) and 354 (clamp before narrowing) covering exactly the semantics a new oracle would restate. The suite imports no repo code, so it checks only its own oracle/interpreter pair; the differential hook (per the #2824 comment) is what would make it contribute.

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

@klarnet2009

Copy link
Copy Markdown
Contributor

Reviewed PR #2825 (fd3c7712).

Files read

  • tests/semantic/test_interp_p2_f16.py (lines 1-45, 1275-1337)

Checks run

  • py -3.12 -I tests/semantic/test_interp_p2_f16.py -v: Ran 32 tests in 0.002s — OK (exit code 0)
  • py -3.12 -I -m compileall -q tests/semantic/test_interp_p2_f16.py: exit code 0

Findings

  • All 32 tests in tests/semantic/test_interp_p2_f16.py pass and compile cleanly.
  • Note on coverage scope: test_interp_p2_f16.py only exercises its own in-file Python oracle, AST, and interpreter — it does not import or run tools/rdna2spirv.py, tests/semantic/support.py, or tests/semantic/spirv_mini_interp.py.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Measured on gfx1036 (RDNA2, AMD Radeon iGPU, driver 26.10.1, game MODE: ieee 0, dx10_clamp 1, denorm32 0, denorm16_64 3): not measured. v_interp_p2_f16 is a real RDNA2 instruction (it assembles for gfx1013, gfx1030 and gfx1036), but it reads the p20 parameter from the pixel-shader attribute memory (LDS parameter data), which only a graphics draw provides; hw_oracle runs compute dispatches, so the oracle's expected words could not be run on the Radeon here. The vertex-parameter plumbing would need a native pixel-shader harness (the runtime's vk_harness on the translated shader checks the translator, not the hardware instruction).

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.

5 participants