Skip to content

test(semantic): add comprehensive semantic tests and reference oracle for ds_max_src2_f32 - #3761

Closed
slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-max-src2-f32
Closed

slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-max-src2-f32

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Add comprehensive semantic tests and reference mathematical oracle for RDNA2 Local Data Share (LDS) dual-source atomic single-precision floating-point maximum (ds_max_src2_f32) in tests/semantic/test_lds_max_src2_f32.py.

The 8-commit suite covers:

  1. Reference mathematical oracle (oracle_max_f32, ref_ds_max_src2_f32) following IEEE 754-2008 / IEEE 754-2019 maxNum semantics (NaN suppression, signed zero ordering max(+0.0, -0.0) == +0.0, subnormals preserved without flush-to-zero) and architectural dual-address model (LDSMemory, calc_lds_src2_addresses) with 64 KiB capacity, 32-bank layout, dword alignment, and dual 8-bit dword offsets (offset0 and offset1).
  2. Symbolic AST opcode definitions and typed expressions (DSOpcode.DS_MAX_SRC2_F32, RegisterOperand, LDSAddressExpression, DSSrc2Instruction, Program).
  3. Deterministic scalar instruction interpreter (ScalarMachineState, ScalarInterpreter) 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 on shared location A and inactive lane preservation.
  5. Register aliasing and in-place operand preservation (base VGPR preservation, canary register isolation, and memory offset aliasing offset0 == offset1).
  6. Condition codes, status flags (mem_updated, mem_unchanged, zero, negative, nan, infinity, subnormal), bank conflict analysis (stride 1 vs stride 32), and scalar/vector VCC isolation.
  7. IEEE 754 boundary extremes (signed zeros, infinities, sNaN/qNaN bit preservation, subnormals without flush-to-zero) and capacity wrapping across 64 KiB LDS.
  8. Negative controls, syntax rejection (out-of-range registers, invalid immediate offsets, invalid memory sizes), and mutation detection (min instead of max, integer comparison, destructive write to location B, dropped offset1, aggressive NaN propagation).

Tested

  • Pre-flight test suite execution:
    • python -m compileall -q tests
    • python -I tests/semantic/test_lds_max_src2_f32.py (37/37 tests passing)
    • python -m unittest -v tests/semantic/test_lds_max_src2_f32.py (37/37 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.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same issue as #3759: ds_max_src2_f32 has no handling in tools/rdna2spirv.py on f847748c, and the new file imports neither rdna2spirv nor spirv_mini_interp. It tests a local model, not the translator. A real test needs a synthetic listing translated and executed; see #3759 for the pattern.

@tupacfan04

Copy link
Copy Markdown
Contributor

Same pattern as the sibling: this file does not run the translator, and ds_max_src2_f32 is not implemented there.

  • Zero occurrences of rdna2spirv, support, subprocess or open(. ref_ds_max_src2_f32 is return oracle_max_f32(...) (:203-205) and LDSMemory.atomic_max_src2_f32 calls the same oracle (:236), so the model is graded by itself.
  • support.translate_lines(..., ['ds_max_src2_f32 ...']) raises Unsupported: ds_max_src2_f32; docs/design.md:324 covers only ds_{inc,dec,rsub}_u32 and ds_{min,max}_f32.
  • Mutation: baseline 37 tests OK. A wrong-constant branch for ds_max_src2_f32 still passes 37; disabling translate() still passes 37.
  • The five *Mutant classes subclass the file's own ScalarInterpreter (:957-1054) and are compared to that model.
  • PR tests: a semantic test must reach tools/rdna2spirv.py #2992's guard flags it at line 1.

Suggested shape: implement the opcode with a contract row, then translate a hand-written listing through support and assert with spirv_mini_interp.

AI-assisted review, no game files, no GPU.

@ItsNotRexed

Copy link
Copy Markdown
Owner

Closing: the tests never exercise the translator (they model the instruction in Python without calling tools/rdna2spirv.py), so tests/test_semantic_translator_use.py rejects them. Please translate a listing through support.translate_* and check its result instead.

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