Skip to content

test(semantic): add translator tests for v_mul_f64 - #5490

Open
slopgobblercobbler wants to merge 2 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-mul-f64-suite
Open

slopgobblercobbler wants to merge 2 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-mul-f64-suite

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Adds support and regression tests for v_mul_f64 (double-precision floating-point multiply) in tools/rdna2spirv.py and tests/semantic/test_valu_mul_f64_hw.py.

  • tools/rdna2spirv.py: Lower v_mul_f64 to OpFMul %double with 64-bit pair operand checks and modifier support (neg, abs, clamp).
  • tests/semantic/test_valu_mul_f64_hw.py: Exercises tools/rdna2spirv.py via support.translate_lines(...) and validates execution results with support.mrt0_words(...).
  • Passes tests/test_semantic_translator_use.py.

Tested

  • python -m compileall -q tests tools
  • python -I tests/semantic/test_valu_mul_f64_hw.py (10/10 passed)
  • python -I tests/test_semantic_translator_use.py (Passed)
  • Standard library Python only (unittest, struct, math)
  • Zero game data, keys, or decryption

@sovljanskii

Copy link
Copy Markdown
Contributor

Independent test on Apple M4 at head 83c84106, merged onto main 3faac557. Setup: macOS 27.2.1, MoltenVK 1.4.2, Python 3.15.2 and 3.12.16, SPIRV-Tools v2026.4. The runtime is main's build, since the PR has no C++.

  • test_valu_mul_f64_hw.py (10/10) and test_semantic_translator_use.py pass on both Python versions, and compileall is clean. The M4 has no shaderFloat64, so OpFMul %double runs only in the CPU interpreter here, not on the GPU.

  • Duplicate: this is the same change as test(semantic): add translator tests for v_mul_f64 #5433, from the same author with the same title, opened 11 minutes earlier. The translator hunks differ only in where the v_mul_f64 branch sits and in the destination n == 2 check. One of the two should probably be closed.

  • The f64 rounding mode is ignored. In the same block, v_add_f64 applies MODE FP_ROUND[3:2] through f64_add_mode (rdna2spirv.py:6667), and docs/design.md says s_round_mode accepts FP16/64 toward zero. v_mul_f64 doesn't apply it:

    • Program: s_round_mode 0xc followed by v_mul_f64 of 3.0 × fl(1/3); the exact product is 1 − 2^-54.
    • Translated result: 0x3ff0000000000000, the round-to-nearest-even result.
    • Toward zero would give 0x3fefffffffffffff.

    Either raise Unsupported when self.round_mode is set, or round the product the way f64_add_mode rounds the sum.

  • The new d.get("n") != 2 destination check also covers v_add/rcp/rsq/sqrt_f64 now. v_cvt_f32_f64 returns before it, so that is fine.

  • v_mul_f64 occurs in 0 of the corpus's 25,734 listings. Corpus shard 0/64 gives 415/415 translated and valid, byte-identical to main.

  • GPU suite: 152/217 passed, 58 skipped, the same results as main (ps_f64_* are skipped because of Float64).

  • Semantic suite: 6,255 tests (10 new, all pass), the same 32 failures and 2 errors as main on arm64 (the NaN rows spirv_mini_interp: pin the sign of a NaN made from non-NaN operands (semantic suite on arm64) #5208 fixes, plus test_loop_ballot_barrier); no new failure.

Verdict: no regression on Apple M4. It duplicates #5433 and has one rounding-mode gap.

AI-assisted.

@cynbun

cynbun commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

GPU data point at 83c84106 (RTX 5080, NVIDIA 615.78.08, Linux; built against main 3faac557, before the current conflict with main): a hand-written compute fixture gives the exact expected words for rounding, -|x|, a subnormal product and clamp (main refuses v_mul_f64), and run_gpu_tests.py --filter f64 passes 3/3.

Gap, confirmed on the GPU: after s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 3 (FP_ROUND[3:2] = round toward zero), v_mul_f64 of 3.0 × 0.1 returns 0x3fd3333333333334 (the round-to-nearest result); toward zero is 0x3fd3333333333333. v_add_f64 in the same program does round toward zero, so the mode write itself works. This matches the CPU-side observation sovljanskii posted; this is the first hardware confirmation. AI-assisted (Claude Code).

@caltr98

caltr98 commented Nov 23, 2026

Copy link
Copy Markdown

This looks like a duplicate of #5433 (same author, opened 10 minutes earlier): both add v_mul_f64 to the same f64 branch of tools/rdna2spirv.py and both add tests/semantic/test_valu_mul_f64_hw.py. The rules differ only in placement and this one also requires d["n"] == 2. #5433 is mergeable and passes its tests here; this one conflicts with main. Suggest closing one, or folding the n == 2 check into #5433. AI-assisted.

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested 83c84106 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), Vulkan SDK 1.4.363, llvm-mc 23.1.6, test programs from main 3faac557: pass.

  • tests/semantic: 6255 tests (10 more than main), with the same 3 failures and 2 errors main has on this machine; none new.
  • run_gpu_tests.py: 170/217 passed, 47 skipped, 0 failed, same as main 3faac557; no suite shader's SPIR-V changes.

AI-assisted (Claude Code).

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.

5 participants