Skip to content

test(semantic): add translator tests for v_xor3_b32 - #5444

Open
slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-xor3-b32
Open

slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-xor3-b32

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What

Adds reference oracle and hardware translator semantic tests for v_xor3_b32 in tests/semantic/test_valu_xor3_b32_hw.py.

Covers:

  • Reference mathematical oracle matching RDNA2 hardware semantics
  • Symbolic translation to SPIR-V via tools/rdna2spirv.py verifying chained OpBitwiseXor instructions
  • Bitwise truth table validation across varied bit patterns
  • Full symmetry and 6-way permutation invariance
  • Pair cancellation identity (xor3(A, A, B) == B)
  • Triple self-identity (xor3(A, A, A) == A)
  • Bitwise inversion with all-ones mask (xor3(A, ~0, 0) == ~A)
  • Uniform SGPR and inline constant mixed operand combinations
  • Distinction from OR3, ADD3, and standard 2-way XOR
  • Pseudorandomized vector verification against the reference oracle

Tested

  • Tested with Python 3.10+ (python -I)
  • python -m compileall -q tests (Clean, 0 errors)
  • python -I tests/semantic/test_valu_xor3_b32_hw.py (All tests passed, OK)
  • python -I tests/test_semantic_translator_use.py (Passed, OK)
  • Standard library Python only (unittest, struct, random)
  • Strictly zero game data, binaries, or proprietary keys

@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.

Merging main (3faac557b) into this head and running the semantic guard fails:

python -I -m pytest tests/test_semantic_translator_use.py -q -> 1 failed, 2 passed, test_every_semantic_test_reaches_the_translator: tests/semantic/test_valu_xor3_b32.py imports no rdna2spirv and no helper that does.

Fix, following #3448/#3457/#3472: keep the operand tables and expected words, replace the private interpreter with support.translate_lines plus the mini interpreter, and pin Unsupported where the translator has no lowering yet (as #4397 does). Python only, no game files, no GPU.

Also raised in #5361 by @JakubRasken, who found the same nine files across the batch.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 1e5dece merged with main 561b65a on Linux (WSL2) Python 3.12.16: fail

tests/semantic/test_valu_xor3_b32.py (new, test-only): 44 run, 44 passed, 0 failed (0.002 s), but the file never calls the translator: it imports neither rdna2spirv nor support, it only checks its own Python model of v_xor3_b32.
Repo check: python -I tests/test_semantic_translator_use.py on the merged tree runs 3 and fails 1: "tests/semantic/test_valu_xor3_b32.py:1: imports no rdna2spirv and no helper that does" (tests/semantic/README.md: "Every file here must call tools/rdna2spirv.py ... A test that reimplements the instruction in Python passes whatever the translator does, so it is not a regression test"). CI runs that check, so this PR as it stands would break it.
Negative control: mutating tools/rdna2spirv.py so v_xor3_b32 emits OpBitwiseOr instead of OpBitwiseXor leaves the file at 44 run, 0 failures, which confirms it does not observe the translator. Mutation reverted. The title says "translator tests"; adding a support.translate_lines/mrt0_words case per operand pattern would fix both.

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.

3 participants