Skip to content

GPU test cs_w32_fmamk_f16: v_fmamk_f16 and v_fmaak_f16 on a GPU - #4491

Open
kingzzim7-create wants to merge 2 commits into
ItsNotRexed:mainfrom
kingzzim7-create:test-fmamk-f16
Open

kingzzim7-create wants to merge 2 commits into
ItsNotRexed:mainfrom
kingzzim7-create:test-fmamk-f16

Conversation

@kingzzim7-create

Copy link
Copy Markdown

Claimed in the coordination issue as: new TEST item, first GPU fixture for v_fmamk_f16 / v_fmaak_f16 (claim in #4421)

What and why

The docs/design.md row for v_fmamk_f16 / v_fmaak_f16 (translator support from #1989) was CPU-checked only. This adds a wave32 compute fixture, runtime/test/shaders/cs_w32_fmamk_f16.asm, registered in check.py and scripts/run_gpu_tests.py like cs_w32_new_ops. Eight words, derived in the file header from the ISA rule (fmamk: D = S0 * K + S1, fmaak: D = S0 * S1 + K, one rounding to f16, the high half of D kept):

  • both forms over a non-zero high half (0xDEAD4700, 0xBEEF4680; the swapped operand order gives a different word)
  • one rounding: 0x3C01 * 0x3C01 + 0x1000 is exactly 1 + 2^-9 + 2^-11 + 2^-20 and rounds to 0x3C03; rounding the product first gives a tie that goes to 0x3C02 (both forms)
  • a float literal K (0.1 → f16 0x2E66, times 2 = 0x3266)
  • fmaak with a negative operand (3 * -2 + 10 = 4.0; S0 * K + S1 would give 28.0)
  • an SGPR src0
  • overflow: 256 * 256 rounds to +inf (0x7C00)

The docs row gets a GPU-checked sentence (NVIDIA only; not measured on AMD hardware, so the Not GPU-verified marker stays, as in the cs_buf_load_sub and cs_w32_new_ops rows). #4141 measures this row on gfx1100; its words can be cross-checked against these.

Tested

NVIDIA GeForce RTX 4060 Ti, driver 621.01, Windows 11, MSVC 14.52 (Visual Studio 2026), llvm-mc 23.1.6, Vulkan SDK 1.4.350.0, at 03b09a0:

  • python -I scripts/run_gpu_tests.py --filter cs_w32_fmamk_f16: 1 translated, 1 pass spirv-val; PASS 3735897856 3203352192 15363 15363 12902 17408 18176 31744
  • the same with LEONIDA_W64_EMULATE=1: PASS, the same words
  • vk_compute_test cs_w32_fmamk_f16.spv 1 dump: 0 mismatches, the same words
  • python -m unittest tests.test_shader_checks: 79 tests OK

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: a test for an existing rule; the row gets its GPU result.)

AI-assisted: yes (Claude).

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

Ran this at 7d3b24bb on Windows 11:

  • tests/semantic/test_valu_fmamk_fmaak_f16.py -> 4 tests, OK.
  • Built vk_compute_test/vk_store_test/vk_harness, then run_gpu_tests.py --filter fmamk -> 1/1 passed: cs_w32_fmamk_f16 returned 3735897856 3203352192 15363 15363 12902 17408 18176 31744; translator 1/1 spirv-val.
  • git diff --check clean.

The new GPU fixture pins v_fmamk_f16/v_fmaak_f16 against real hardware. No blocking issue.

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 data point for the new f16 FMA-mask fixture. Tested head 7d3b24b on Apple M2 (Mac14,3), macOS 26.4, MoltenVK 1.4.2 (direct), subgroup 4..32, llvm-mc 23.1.6, clean full build on AppleClang 17.

python -I scripts/run_gpu_tests.py --filter cs_w32_fmamk_f16 --build runtime/build/linux: 1 shader translated, 1 pass spirv-val; 1/1 passed — words 3735897856 3203352192 15363 15363 12902 17408 18176 31744, identical to the NVIDIA words in the PR body, 0 mismatches. Head fetched read-only, no rebase/edit/push. Synthetic shader and counts only; no game files.

AI-assisted.

@kingzzim7-create

Copy link
Copy Markdown
Author

Thanks @Kam471 for reproducing it, glad the words match on a second machine.

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

Tested 7d3b24bb on Radeon iGPU (9800X3D), AMD 25.10.30.02, Windows 11. The stock fixture matched 8/8 words at native subgroup 32 with zero validation diagnostics. Both flag settings produced the same native module. Radeon verification in #166. AI-assisted.

@kingzzim7-create

Copy link
Copy Markdown
Author

Thanks @bobcatchris s, good to see the same words on the M2. Since you measured this row on gfx1100 in #4141: do any of your measured words cover these cases (the 0x3C01 * 0x3C01 + 0x1000 single-rounding case or the +inf overflow)? If they match, I can add a note to the row that the fixture's words agree with the gfx1100 measurement.

@kingzzim7-create

Copy link
Copy Markdown
Author

Thanks @whattheflop, an AMD result on the same words is great to have.

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Automated test: 7d3b24bb merged onto main 03b09a08 on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5), Mesa 25.2.8, Ubuntu 24.04, runtime rebuilt from this branch in a clean sandbox. Result: pass.

  • scripts/run_gpu_tests.py: 193/210 passed, 15 skipped (plain main: 192/209 passed, 15 skipped).
    • new test cs_w32_fmamk_f16: pass (3735897856 3203352192 15363 15363 12902 17408 18176 31744)

Same machine and setup as my earlier manual reports. AI-assisted (Claude Code).

@theswiss24

Copy link
Copy Markdown

Tested 7d3b24bb (contains main 03b09a08) on NVIDIA GeForce RTX 2060 SUPER (Turing), driver 580.178.04, Ubuntu 24.04.5, llvm-mc 20.1.2, test programs built from main 03b09a08 (this PR changes no C++): pass.

LEONIDA_W64_EMULATE=1 python3 -I scripts/run_gpu_tests.py --build <main build>: 196/211 passed, 15 skipped, 0 failed. That's main's 195/210 plus the new fixture, with every other test unchanged:

PASS  cs_w32_fmamk_f16      3735897856 3203352192 15363 15363 12902 17408 18176 31744

No game files.

Tested and written by Claude (Claude Code), posting from @theswiss24's account.

@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested 7d3b24b on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

  • Full python -I scripts/run_gpu_tests.py (Linux build of this branch's runtime/, LEONIDA_VK_DEVICE per GPU): 197/211 passed, 14 skipped, 0 failed on both GPUs. Compared with the same suite at the merge base 03b09a0 on the same machine, every shared test has the same result, and the test this PR adds (cs_w32_fmamk_f16) passes on both GPUs.

No game files. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 7d3b24b merged with main 03b09a0 (merge is the PR head, nothing to merge) on Windows 11 with two GPUs (MSVC 14.51): built vk_compute_test, vk_store_test and vk_harness; run_gpu_tests.py --filter cs_w32_fmamk gives 1/1 passed on the NVIDIA RTX 4080 SUPER and 1/1 on the Intel UHD 770 (driver 32.0.101.6129), natively and with LEONIDA_W64_EMULATE=1 on both (3735897856 3203352192 15363 15363 12902 17408 18176 31744, the words in check.py).

Negative control: the PR changes no translator or runtime file, so there is nothing to restore from main. Changing the expected first word to 0xDEAD4701 in run_gpu_tests.py makes the same run FAIL, so the comparison is live. Only this fixture was run, not the full suite.

@mrbean56

Copy link
Copy Markdown

Tested 7d3b24bb on AMD Radeon RX 7800 XT (RADV NAVI32, Mesa 26.x, Vulkan 1.4.309), Linux, LLVM 19 llvm-mc: GPU pass.

  • python3 -I scripts/run_gpu_tests.py --llvm-mc /usr/lib/llvm-19/bin/llvm-mc --build <ninja Release> --filter fmamk --require-pass:
    • 1 shaders: 1 translated, 1 pass spirv-val
    • PASS cs_w32_fmamk_f16 3735897856 3203352192 15363 15363 12902 17408 18176 31744
    • 1/1 passed
  • So v_fmamk_f16 and v_fmaak_f16 match the hand-derived words on RDNA3/RADV, independently of the GPU they were measured on, and the inline-constant paths (the 15363/12902/31744 cases that encode f16 immediates in the instruction) are exercised rather than only register operands.
  • The fixture is the only thing the branch adds besides the check.py words and the docs row; it needs no translator change.

No game data. AI-assisted.

@kingzzim7-create

Copy link
Copy Markdown
Author

Update: @Flyander pointed out on #4543 that every lane storing to the same offsets is a data race under the Vulkan memory model. This fixture had the same pattern, so the new commit adds v_cmpx_eq_u32_e32 0, v0 before the stores (as cs_w32_new_ops does): only lane 0 writes. Re-run on the RTX 4060 Ti: PASS with the same words 3735897856 3203352192 15363 15363 12902 17408 18176 31744, natively and with LEONIDA_W64_EMULATE=1. Earlier reviewers' results still hold for the computed values; only the store path changed.

AI-assisted (Claude).

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

Retested corrected head 2d6b74ed on Windows Radeon iGPU (AMD 25.10.30.02), native subgroup 32. After confirming the lane-zero store guard and Vulkan 1.2 SPIR-V validation, the stock harness matched 8/8 words with zero Khronos validation diagnostics. This supersedes my earlier Radeon report at 7d3b24b, where all lanes wrote the same locations. Details in #166. AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 2d6b74e merged onto main d0835dd on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed. main d0835dd gives 164/210, 46 skipped, 0 failed. All 215 test shaders translate and pass spirv-val.
  • New GPU tests: cs_w32_fmamk_f16 PASS.

AI-assisted (Claude Code).

@kingzzim7-create

Copy link
Copy Markdown
Author

@JRamos1993 Thanks for testing on the 5090!

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.

10 participants