Skip to content

test(semantic): add translator tests for s_nand_b64 - #5628

Open
slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-salu-nand-b64
Open

slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-salu-nand-b64

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What

Adds translator-backed regression tests and reference oracle for s_nand_b64 in tests/semantic/test_salu_nand_b64.py.

Covers:

  • Reference mathematical model matching RDNA2 hardware specification (D.u64 = ~(S0.u64 & S1.u64))
  • Structural AST operand typing and register allocation validation
  • Deterministic scalar and multi-lane SIMD divergence under Wave32 / Wave64 EXEC masking
  • Register aliasing and in-place operand preservation (s[0:1] = s[0:1] NAND s[2:3], partial window overlaps)
  • Condition code generation (SCC status bit set when result is non-zero, cleared on all-ones conjunction)
  • IEEE 754 extreme boundary checks: signed zeros, subnormals, infinities, quiet NaNs, and packed float pairs
  • End-to-end SPIR-V assembly translation through tools/rdna2spirv.py via support.translate_lines
  • Fragment execution and MRT0 export verification with spirv_mini_interp

Tested

  • Tested with Python 3.9+ (python -I)
  • python -I tests/test_semantic_translator_use.py (Passes translator reachability check)
  • python -I tests/semantic/test_salu_nand_b64.py (All test suites OK)
  • Standard library Python only (unittest, struct, math)
  • Clean merge against upstream/main
  • Strictly zero game data, binaries, or proprietary keys

@mrbean56

Copy link
Copy Markdown

Tested 38a51c7b15 on Linux (Debian 13), Python 3.13.5: pass, mutation caught.

  • pytest tests/semantic/test_salu_nand_b64.py -q: 38 passed, 376 subtests.
  • Mutation: "nand": "OpBitwiseAnd" → OpBitwiseOr makes 6 tests fail, including 3 subTests of test_translator_mrt0_execution_against_oracle; one of them is the 0x5555…/0xaaaa… pair, which is exactly the case where a dword-wise ~ and a 64-bit ~ agree, so the other cases are doing the discriminating work.
  • The oracle execution through the mini interpreter is what makes this more than a table check.

No GPU, no game data. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 38a51c7 merged with main 561b65a on Ubuntu (WSL2) / Python 3.12.16: pass

tests/semantic/test_salu_nand_b64.py: 38 run, 38 passed, 0 failed (test-only PR, one file). Negative control: the tests pass on unmodified main code as expected (no source change); with a mutation in tools/rdna2spirv.py removing s_nand_b64 from the set that gets the final OpNot, 10 of 38 fail. Overlap note: open PR #5646 adds tests/semantic/test_salu_nand_b64_hw.py for the same instruction (18 tests), and #5849 adds a SALU 64-bit logic bundle covering s_nand_b64 as well.

@memorypressure

Copy link
Copy Markdown

Verified against current main 1cc6e3c (re-merge-tested green; suite re-run here): 38 tests OK via unittest discover, translator-use guard green, neighbouring test_salu_nand_nor_saveexec_b64.py green. Every mnemonic exists in tools/rdna2_isa_tables.py, five tests drive the real translator via translate_lines, classes sit above unittest.main(), and the IEEE bit-pattern reading of NAND is the sound one. No filename or opcode collision with existing suites. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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