Skip to content

test(semantic): add SALU 64-bit logic bundle suite - #5849

Closed
slopgobblercobbler wants to merge 33 commits into
ProjectLeonida:mainfrom
slopgobblercobbler:test/semantic-salu-logic-b64-bundle
Closed

slopgobblercobbler wants to merge 33 commits into
ProjectLeonida:mainfrom
slopgobblercobbler:test/semantic-salu-logic-b64-bundle

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Collaborator

Summary

Implement Bundle 4 (SALU 64-bit Logic Suite, 32 commits) in tests/semantic/test_salu_logic_b64_bundle.py.

Coverage

Comprehensive test suite covering all 8 RDNA2 64-bit scalar ALU bitwise logic operations:

  • s_and_b64: D = S0 & S1, SCC = (D != 0)
  • s_or_b64: D = S0 | S1, SCC = (D != 0)
  • s_xor_b64: D = S0 ^ S1, SCC = (D != 0)
  • s_andn2_b64: D = S0 & ~S1, SCC = (D != 0)
  • s_orn2_b64: D = S0 | ~S1, SCC = (D != 0)
  • s_nand_b64: D = ~(S0 & S1), SCC = (D != 0)
  • s_nor_b64: D = ~(S0 | S1), SCC = (D != 0)
  • s_xnor_b64: D = ~(S0 ^ S1), SCC = (D != 0)

Staging Structure (4 granular commits per opcode, 32 commits total)

For each opcode:

  1. Reference mathematical oracle and bitwise truth table modeling.
  2. Symbolic AST instruction representation, operand typing, and scalar register state machine step evaluation.
  3. 64-bit mask divergence patterns, all-zeros / all-ones boundary conditions, alternating bit patterns, and lo/hi dword independence.
  4. SPIR-V translator integration via rdna2spirv, shader execution verification through spirv_mini_interp, SCC status flag verification (zero and nonzero), and syntax rejection controls.

Verification

  • py -3.10 -I tests/semantic/test_salu_logic_b64_bundle.py
  • py -3.10 -I tests/test_semantic_translator_use.py
  • py -3.10 -m compileall -q tests

@kapitche

Copy link
Copy Markdown
Collaborator

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

tests/semantic/test_salu_logic_b64_bundle.py: 96 run, 96 passed, 0 failed (test-only PR, one file). Negative control: the new tests pass on unmodified main code as expected (nothing to revert); with a mutation in tools/rdna2spirv.py making s_nand/s_nor/s_xnor_b64 skip the final OpNot (inv = False), 6 of 96 fail. I did not check the "hardware-verified" claim in the docstring (no hardware run).

@BeegSchmooze

Copy link
Copy Markdown
Contributor

Mutation check of the current head with a generic run (tools/semantic_mutants.py --op s_and_b64, #6548; the branch handles all eight ops). The file passes as submitted. 13 of 17 mutants caught. Windows 11, Python 3.13.

Survivors:

  • SCC from the 64-bit result (SCC = (lo | hi) != 0, ~line 10043): | → &, | → ^, and "low half only" all survive. SCC is checked through s_cselect_b32, but every case's result has both halves zero or both non-zero, and those are exactly the results where the variants agree. Two cases would pin it: a result with only the low half set (e.g. s_and_b64 of 0x00000000_FFFFFFFF and 0x00000000_0000000F: SCC 1, the & variant gives 0) and one with only the high half set (e.g. 0xF0000000_00000000: the low-half-only variant gives 0).
  • The lane-mask path (EXEC/VCC destination or a mask source, ~line 10016) ignoring S1 survives, as in test(semantic): add hardware translator tests for s_and_b64 #5810: no case reaches that path.

AI-assisted (Claude Code). No game files.

@YordiLorenzo

Copy link
Copy Markdown

Tested 8e33222 on Linux, Python 3.14.4: pass

  • python -I tests/semantic/test_salu_logic_b64_bundle.py: 96 tests OK, and test_semantic_translator_use is OK
  • The three SCC survivors from the earlier mutation check are caught on this head: SCC from lo AND hi (2 failures), lo XOR hi (16), low half only (2). Control, high half ignoring S1: 52 failures

Still surviving: the mask path ignoring S1, since no case writes EXEC or VCC. A vcc destination fails in the single-invocation runner (OpGroupNonUniformAny), so it needs a workgroup run like lds_run. Fine to leave for a follow-up, the docstring just shouldn't claim mask coverage.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 8e332229 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_logic_b64_bundle.py: OK.
  • Mutation: tools/rdna2spirv.py:10437 changed to k = {"and": "OpBitwiseOr", "or": "OpBitwiseOr", "xor": "OpBitwiseXor", "andn2": "OpBitwiseAnd",. Same command: FAILED (failures=9) .

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.

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