Skip to content

test(semantic): add semantic interpreter tests for s_or_b32 - #5752

Open
slopgobblercobbler wants to merge 10 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-salu-or-b32-suite
Open

slopgobblercobbler wants to merge 10 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-salu-or-b32-suite

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

Summary

  • Adds reference mathematical model, symbolic AST definitions, deterministic scalar interpreter, SIMD multi-lane divergence and 32/64-bit EXEC masking, register aliasing and in-place operand preservation, condition codes and status flags (SCC), IEEE 754 boundary extremes/subnormals, and negative controls/syntax rejection for s_or_b32.
  • Validates translator output via tests/semantic/test_salu_or_b32_hw.py directly exercising support.translate_lines and support.mrt0_words.

Verification

  • python -m compileall -q tests
  • python -I tests/semantic/test_salu_or_b32_hw.py
  • python -I tests/test_semantic_translator_use.py

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 93692aea on Windows Server 2022, CPython 3.13.12: pass

  • python -I -m unittest discover -s tests/semantic -p "test_salu_or_b32_hw.py" -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@memorypressure

Copy link
Copy Markdown

Verified on your head at main 561b65a: merges clean, 33/33 pass, guard green — but the guard is green only because the file imports the translator: a few smoke tests (~:159/:316/:485/:542) use translate_lines/mrt0_words, while the bulk of the 33 assert the file's own ScalarRegisterState/execute_s_or_b32 model against its own oracle, with no spirv_mini_interp execution anywhere — so most cases pass whatever rdna2spirv.py emits. That is the pattern the conversion PRs #3519/#3537 exist to replace, and the _hw suffix is misleading since nothing here touches hardware. Note main already covers s_or_b32 through the translator in tests/semantic/test_alu_bitop_folding.py among others. Re-aiming the grid at translated listings through support.translate_lines + spirv_mini_interp would make the negative controls bite for real. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 93692ae merged with main 561b65a on Linux (WSL2) / Python 3.12.16: pass

tests/semantic/test_salu_or_b32_hw.py (new, test-only PR): 33 run, 33 passed, 0 failed. The tests also pass on plain main (the translator already supports s_or_b32). Negative control by mutation: making s_or_b32 a bitwise AND in the constant-fold branch and in the S2 table of tools/rdna2spirv.py gives 33 run, 12 failures (translator smoke, equivalence, aliasing, SCC branching, float-pattern and AST-emission tests); mutation reverted afterwards. Note for scope: only 8 of the 33 tests call translate_lines; the rest (truth table, algebraic laws, De Morgan, AST classes, ScalarRegisterState interpreter) check Python reference code defined in the test file itself, so they cannot catch a translator bug. The PR does not touch tools/rdna2spirv.py, so I did not run the full semantic suite.

@slopgobblercobbler

Copy link
Copy Markdown
Contributor Author

Updated test_salu_or_b32_hw.py to re-aim the test suite at translator-backed execution across all test classes, addressing feedback from @memorypressure and @kapitche:

  • Replaced internal Python interpreter/mock assertions with run_salu_or_b32 / support.translate_lines and support.mrt0_words execution.
  • Truth tables, algebraic identities (idempotence, commutativity, associativity, absorption), De Morgan duality, single-bit walking patterns, and SCC zero/non-zero mappings now generate real shader listings, lower them through rdna2spirv.py, and execute them via spirv_mini_interp.
  • Multi-lane divergence, register aliasing (s0 in-place, adjacent register isolation), floating-point bit patterns (NaNs, subnormals, infinities, signed zeroes), and SCC branch propagation tests now all lower and execute through the translator.
  • Verified test suite passes: 33 of 33 tests passed with python -I.
  • Verified test_semantic_translator_use.py passes (3/3).
  • Clean git diff --check, syntax verified with python -m compileall -q. No game files, no GPU required. AI-assisted.

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