Skip to content

gpu test: cs_mul_legacy_denorm pins the default-MODE legacy multiply flush - #5355

Open
gertify wants to merge 1 commit into
ItsNotRexed:mainfrom
gertify:fix-contract-v-mul-legacy-f32-default-mode-f32-denorm
Open

gertify wants to merge 1 commit into
ItsNotRexed:mainfrom
gertify:fix-contract-v-mul-legacy-f32-default-mode-f32-denorm

Conversation

@gertify

@gertify gertify commented Nov 23, 2026

Copy link
Copy Markdown

The translator contract row "v_mul_legacy_f32 default-mode f32 denormal flushing" (docs/design.md) says the legacy multiply flushes f32 denormal operands and products in the inferred game MODE: a subnormal operand reads as a signed zero, then the DX9 zero-operand override gives +0 even when an operand was negative or the other is infinity or NaN, and a nonzero subnormal product flushes to a zero that keeps its sign before the VOP3 mul:2/mul:4/div:2 modifiers, so with IEEE off an output multiplier turns the resulting -0 into +0. Only pixel-shader fixtures covered it, four pixels each.

runtime/test/shaders/cs_mul_legacy_denorm.asm pins the same rules in eight words, one case each: 2^-149 * 2^24, -2^-149 * 2^24, -2^-149 * -NaN and +0 * +inf for the operand flush and the zero override; FLT_MIN * 0.5 and -FLT_MIN * 0.5 for the product flush and the sign it keeps; FLT_MIN * 0.5 mul:2 for the flush coming before the modifier, where the product is 2^-127 and mul:2 would make it the normal 2^-126 if the flush came after; and -FLT_MIN * 0.5 div:2 for the modifier turning the flushed -0 into +0. Every expected word has its derivation in the fixture header and is listed in check.py and scripts/run_gpu_tests.py.

Tested with no translator change, on main 3faac55, on an AMD RADV RAPHAEL_MENDOCINO (Ryzen 9 9950X3D iGPU, Mesa 26.2.6-arch3.1) and an NVIDIA GeForce RTX 5080 (620.70.06): PASS cs_mul_legacy_denorm 0 0 0 0 0 2147483648 0 0, the eight words exact on both. Dropping the translator's flush between the product and the output modifier fails the mul:2 word, which then reads 8388608 instead of 0, so the fixture tells the order apart.

The row records the GPU check.

AI-assisted.

@Flyander

Copy link
Copy Markdown
Contributor

Tested 7e44daf on NVIDIA GeForce RTX 5070 Ti (driver 621.14, Windows 11): pass.

Built the synthetic fixture with python -I runtime/test/shaders/build.py <tmp> cs_mul_legacy_denorm (1 translated, spirv-val passed), then ran vk_compute_test.exe <spv> 1 dump; it reported 0 mismatches.

@nullmarsh

Copy link
Copy Markdown

Tested 7e44daf on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.11.2 (32.0.32029.2010), Windows 11 Pro 26200: pass

  • python -I scripts/run_gpu_tests.py --filter cs_mul_legacy_denorm --require-pass: PASS cs_mul_legacy_denorm 0 0 0 0 0 2147483648 0 0, 1/1.
  • Full scripts/run_gpu_tests.py: 203/218 passed, 15 skipped, 0 failed (main 3faac55 on the same machine: 202/217, 15 skipped).
  • Test programs built from 3faac55, the PR's base (the PR changes no C++), with MSVC 14.44, Windows SDK 10.0.26100 and Vulkan SDK 1.4.363.0; llvm-mc 23.1.6 (conda-forge).
  • I read the diff but did not re-derive the expected words. No game files used. AI-assisted (Claude Code).

@SirKingg

Copy link
Copy Markdown
Contributor

Independent Windows GPU check of head 7e44daf8b590898c1e18ef50e305cd7106d21ab7: PASS on NVIDIA GeForce RTX 4070 Ti, driver 610.88, Windows 11 Pro build 26300.

  • Built the Vulkan test programs from this PR with MSVC 14.44, Windows SDK 10.0.26100 and Vulkan SDK 1.4.363.0. With LLVM llvm-mc 23.1.6 and LEONIDA_VK_DEVICE=4070 Ti, ran python -I scripts/run_gpu_tests.py --llvm-mc <llvm-mc.exe> --build runtime\build --work <scratch> --filter cs_mul_legacy_denorm --require-pass: 1 assembled and translated, spirv-val passed, 1/1 GPU test passed. The eight readback words were 00000000 00000000 00000000 00000000 00000000 80000000 00000000 00000000 (hex), matching the fixture's subnormal operand, NaN/infinity zero override, signed product flush and modifier cases.
  • Negative control: locally removed only flush_f32(m) before the output modifier in the legacy multiply translator; the same test failed as expected, word 6 (zero-based) becoming 00800000 instead of 00000000. Restored the source and reran: 1/1 passed with the original eight words; source diff clean.
  • Targeted CPU tests python -m unittest discover -s tests\semantic -p test_valu_mul_legacy_denorm.py -v and python -m unittest discover -s tests\semantic -p test_alu_vop3_mods_hw.py -v: 4/4 and 2/2 passed.

Synthetic fixture only; no game files. This checks translated SPIR-V on NVIDIA, not native RDNA2 hardware behavior. AI-assisted.

@Razuri0

Razuri0 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 7e44daf8 on AMD Radeon RX 9070 (RDNA4, RADV GFX1201), Mesa 26.2.6, Vulkan 1.4.354, Arch Linux (kernel 7.2.5), LLVM 23.1.5 llvm-mc: pass

PASS  cs_mul_legacy_denorm  0 0 0 0 0 2147483648 0 0

Ran LEONIDA_VK_DEVICE=9070 python3 -I scripts/run_gpu_tests.py --build runtime/build/linux (runtime built from main 3faac557, the PR's base, with no runtime C++ changes in the PR). Full suite: 203/218 passed, 15 skipped, 0 failed. main at 3faac557 on the same machine gives 202/217, 15 skipped, so the only difference is the new fixture.

AI-assisted (Claude Code). Synthetic fixtures only, no game files.

@sovljanskii

Copy link
Copy Markdown
Contributor

Apple M4 run of 7e44daf8 (on main 3faac557): pass. Setup: macOS 27.2.1, MoltenVK 1.4.2, AppleClang 21.0.0, Homebrew LLVM 23.1.6, Python 3.15.2. The test programs are built from main.

  • Full run_gpu_tests.py: 153/218 passed, 58 skipped. The only difference from main (152/217) is the new row: PASS cs_mul_legacy_denorm 0 0 0 0 0 2147483648 0 0, the same eight words as on RADV and NVIDIA. tests/test_run_gpu_tests.py passes on 3.15 and 3.12.
  • With rdna2spirv: the f32 denormal flush tests the exponent bits, not |x| < FLT_MIN on the float (-2.9% SPIR-V) #5347 merged (the integer flush): still 0 0 0 0 0 2147483648 0 0.
  • Limitation on Apple: the fixture can't catch a missing translator flush here. With flush_f32 returning its input, the module has no flush left (FAbs 32 → 0), and the M4 still returns the same eight words. MoltenVK 1.4.2 reports shaderDenormFlushToZeroFloat32 = false, shaderDenormPreserveFloat32 = false and denormBehaviorIndependence = NONE, and the GPU flushes these f32 denormals itself. So a PASS is genuine on Apple, but your negative control (mul:2 reading 8388608) only shows on GPUs that keep denormals. If you want, the contract row could say so. Not a blocker.

AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested PR head 7e44daf8 (based on current main 3faac557, so no merge was needed) on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • The tree tested is the PR head itself. The PR changes no C++, so the first run used test programs built from an older main (d0835dd9), and that commit is also the baseline below.
  • python -I scripts/run_gpu_tests.py --build runtime/build/linux, once with LEONIDA_W64_EMULATE unset and once with it set to 1: 199/218 passed, 15 skipped in both modes, and the two modes match test for test. PASS cs_mul_legacy_denorm 0 0 0 0 0 2147483648 0 0: all eight words exact in both modes.
  • Per test against d0835dd without the PR (196/210, 14 skipped), the same differences in both modes:
    • New tests that pass: cs_mul_legacy_denorm, plus cs_smem_sconst_off, ps_far_branch, ps_texture_cl and ps_texture_b_cl from main.
    • New test that is skipped: ps_m2_literal.
    • New tests that fail: ps_sample_c and ps_sample_c_b. The d0835dd vk_texture_test is too old for them and only prints its usage text.
    • Passed on d0835dd, fail here: cs_bvh and cs_bvh32.
    • All four failures come from the old test programs, not from this PR: see the next bullet.
  • The same suite with test programs built from a tree whose runtime/ matches 3faac55 (the PR's base): 203/218 passed, 15 skipped in both modes. Against 3faac55 without the PR on those same programs (202/217), the only difference is the new cs_mul_legacy_denorm PASS. cs_bvh, cs_bvh32, ps_sample_c and ps_sample_c_b all pass with these programs.
  • Negative control, in a scratch copy: I removed only the flush_f32(m) before the output modifier in the v_mul_legacy_f32 translation and ran --filter cs_mul_legacy_denorm. It fails in both modes with 0 0 0 0 0 2147483648 8388608 0: word 6 becomes 0x00800000 and the other seven words don't change. So on RADV too, the fixture tells apart flushing before the modifier from flushing after it.
  • CPU tests:
    • python -m unittest discover -s tests/semantic, run separately with -p test_valu_mul_legacy_denorm.py (4/4 OK), test_alu_vop3_mods_hw.py (2/2 OK), test_wave64_subgroup_ops.py (6/6 OK) and test_value_semantics.py (39/39 OK).
    • python -I tests/test_shader_checks.py: 79/79 OK.
  • I did not re-derive the expected words by hand. Synthetic fixture only, no game files.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

CPU-side checks pass against main 3faac55: compileall clean, the semantic regression test_valu_mul_legacy_denorm.py is 4/4 including the flush-before-omod mul:2 discriminator (0x00800000 x 0x3F000000 -> 0), runtime paths and the design/table/list docs guards green. I cross-read the new .asm header, check.py and the run_gpu_tests judge branch — all three agree on the same eight words, so the CPU-verified half is consistent; the GPU execution (your Raphael + RTX 5080 runs) is not reproducible on this CPU-only host. Note: the branch reports no CI checks at all — worth a push to trigger them. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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

Reviewed head 7e44daf8b590898c1e18ef50e305cd7106d21ab7 (base 3faac557b).

Ran on an RTX 5070 Ti (build from main, LLVM_MC='wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc', LEONIDA_VK_DEVICE='RTX 5070 Ti'):

  • python -I scripts/run_gpu_tests.py --build build-gpu-base --filter cs_mul_legacy_denorm -> 1/1 passed, 0 0 0 0 0 2147483648 0 0, 8/8 words exact.
  • python -I tests/test_shader_checks.py, tests/semantic/test_rule_gpu_fixtures.py, tests/test_docs_design_rows.py -> OK.
  • git diff --check clean.

Registration is complete and consistent: WAVE32_DUMPS (one thread), the CS_DUMPS words, and a dedicated run_suite branch. The eight derivations check out by hand, and word 6 does pin "flush before omod" (2^-127 x mul:2 would be normal otherwise).

Verdict: good to merge.

One merge-order note, not a defect on this PR: #5363 also edits docs/design.md on the adjacent table row, and git merge-tree pr/5355 pr/5363 conflicts in that file. Whichever lands second needs a one-line rebase.

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.

9 participants