Skip to content

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

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

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

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Collaborator

What

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

Covers:

  • Reference mathematical model matching RDNA2 hardware specification: sdst = ~(ssrc0 & ssrc1) and SCC = (sdst != 0)
  • Structural AST operand typing and SGPR pair alignment validation
  • Deterministic scalar and multi-lane SIMD divergence under Wave32 / Wave64 EXEC masking
  • Register aliasing and in-place operand preservation
  • Condition code generation (SCC flag propagation)
  • IEEE 754 extreme boundary checks: signed zeros, subnormals, infinities, quiet NaNs
  • 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_hw.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 441002a22c on Linux (Debian 13), Python 3.13.5: pass, mutation caught.

  • pytest tests/semantic/test_salu_nand_b64_hw.py -q: 18 passed.
  • Mutation: "nand": "OpBitwiseAnd" → OpBitwiseOr makes 2 tests fail, so the inverted result one half at a time is pinned.
  • This is the _hw sibling of test(semantic): add translator tests for s_nand_b64 #5628 (which tests the same op through the interpreter with 376 subtests); the two overlap but neither is redundant — this one keeps the SCC rule in a separate executable row.

No GPU, no game data. AI-assisted.

@kapitche

Copy link
Copy Markdown
Collaborator

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

tests/semantic/test_salu_nand_b64_hw.py: 18 run, 18 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, 2 of 18 fail. Overlap note: open PR #5628 adds tests/semantic/test_salu_nand_b64.py for the same instruction, and #5849 adds a SALU 64-bit logic bundle that also covers s_nand_b64, so the three overlap in coverage.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 441002a2 on Linux, CPython 3.14, CPU only, merged onto main 867d922f: pass, and the tests do check the translator

  • python -m unittest discover -s tests/semantic -p test_salu_nand_b64_hw.py: OK.
  • Mutation: tools/rdna2spirv.py:10441 changed to inv = op in ("s_nor_b64", "s_xnor_b64"). Same command: FAILED (failures=2) .

So a wrong lowering of the instruction this file names turns it red. Mutation checks are spot checks, not full coverage.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

@o-psi o-psi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Recommend keeping #5628 at 38a51c7 and closing #5646 at 441002a as superseded. Repeated the complete comparison against each PR's own merge base and checked both live discussions and dependencies. #5628 retains the useful NAND coverage, including translated result and SCC assertions; both suites reject an SCC-only mutation. The remaining source-private helpers add no independent shared behavior, and no dependent PR was found. Verification used Linux/CPython 3.14.10, CPU only. AI-assisted QA (Codex via T3).

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.

6 participants