Skip to content

GPU test cs_w32_cmp_f64: the binary64 compares on a GPU - #4543

Open
kingzzim7-create wants to merge 3 commits into
ItsNotRexed:mainfrom
kingzzim7-create:test-cmp-f64
Open

kingzzim7-create wants to merge 3 commits into
ItsNotRexed:mainfrom
kingzzim7-create:test-cmp-f64

Conversation

@kingzzim7-create

@kingzzim7-create kingzzim7-create commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: new TEST item, first GPU fixture for v_cmp_*_f64 / v_cmpx_*_f64 (claim in #4421)

What and why

The docs/design.md row for the 16 binary64 compares v_cmp_*_f64 / v_cmpx_*_f64 was CPU-checked only. This adds a wave32 compute fixture, runtime/test/shaders/cs_w32_cmp_f64.asm, registered in check.py and scripts/run_gpu_tests.py like cs_w32_new_ops. Six words, each derived in the file header:

  • out[0..2]: every predicate (f lt eq le gt lg ge o u nge nlg ngt nle neq nlt tru), one bit each, on six pairs: 1 vs 2, 2 vs 2, -0 vs +0, 1 vs NaN, -inf vs +inf, 2 vs 1 (one wrong predicate shows as one wrong bit)
  • out[3]: source forms, one bit each: -x, |x|, -|x|, an SGPR pair, inline 1.0, inline 0.5 vs -0 (false), -NaN still unordered, -1 > -2
  • out[4..5]: v_cmpx_lt_f64 false clears EXEC (the following v_mov doesn't run), v_cmpx_gt_f64 true keeps it; EXEC restored after each

Expected words: 0xCCCCAAAA, 0xFF00CCCC, 0xF0F0AAAA, 0xDF, 0x55, 0x2. The docs row gets a GPU-checked sentence (NVIDIA only; not measured on AMD hardware, so the Not GPU-verified marker stays). #3430 pins this row to measured gfx1100 predicates; 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_cmp_f64: 1 translated, 1 pass spirv-val; PASS 3435965098 4278242508 4042304170 223 85 2
  • the same with LEONIDA_W64_EMULATE=1: PASS, the same words
  • vk_compute_test cs_w32_cmp_f64.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).

@MKmajster

Copy link
Copy Markdown

Tested cb2b039 on NVIDIA GeForce RTX 3070 (Ampere, shaderFloat64, wave32), driver 617.42, Windows 11 24H2. run_gpu_tests.py --filter cs_w32_cmp_f64: PASS, twice, same words:

PASS  cs_w32_cmp_f64        3435965098 4278242508 4042304170 223 85 2

So all 16 f64 predicates, including the unordered ones on NaN and -0 vs +0, give the derived bits on NVIDIA's fp64 path too. llvm-mc 23.1.6, runtime built from main aa2988c. No game files. AI-assisted (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.

Built the runner and ran the new fixture at cb2b0399 on Windows 11, RTX 5070 Ti: run_gpu_tests.py --filter cmp_f64 -> 1/1 passed, cs_w32_cmp_f64 returned 3435965098 4278242508 4042304170 223 85 2; translator 1/1 spirv-val.

The binary64 compare fixture runs on the GPU, so the opcode is checked against hardware rather than only the interpreter. No blocking issue.

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 data point for the new binary64-compare fixture (macOS 26.4, MoltenVK 1.4.2 direct, subgroup 4..32, llvm-mc 23.1.6, clean full build on AppleClang 17). Tested head cb2b039.

python -I scripts/run_gpu_tests.py --filter cs_w32_cmp_f64 --build runtime/build/linux: 1 shader translated, 1 pass spirv-val; 1/1 passed — words 3435965098 4278242508 4042304170 223 85 2, identical to the NVIDIA values in the PR body, 0 mismatches. MoltenVK has no shaderFloat64, so this exercises the f64-soft translation path; it is a real Apple GPU result for the fixture. Head fetched read-only, no rebase/edit/push. Synthetic shader and counts only; no game files.

AI-assisted.

@mrbean56

Copy link
Copy Markdown

Tested cb2b0399 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 cmp_f64 --require-pass:
    • 1 shaders: 1 translated, 1 pass spirv-val
    • PASS cs_w32_cmp_f64 3435965098 4278242508 4042304170 223 85 2
    • 1/1 passed
  • The words include the NaN/edge lanes (223 85 2 are the ordered/unordered result masks), so this is not only the "obvious" compares: v_cmp_*_f64 produce the expected all-ones/zero patterns on a different AMD family from wherever they were measured.
  • This is the first binary64 compare coverage in the GPU suite as far as I can tell; the spirv-val pass on the translated module also means the Float64 capability and the pair-register loads are well-formed.

No game data. AI-assisted.

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

[P2] Avoid racing stores in this 32-lane fixture

This shader dispatches 32 invocations, and every lane reaches six non-atomic buffer stores to the same offsets 0 through 20. Those overlapping writes have no ordering or synchronization. The Vulkan memory model defines this as a data race and requires applications to avoid data races: https://docs.vulkan.org/spec/latest/appendices/memorymodel.html#data-race. The NVIDIA pass therefore does not make the expected words portable. Please restrict the stores to one lane, as cs_w32_new_ops does before its shared operations, or give each lane a distinct output range and have the harness check it.

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Automated test: cb2b0399 merged onto main d0835dd9 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_cmp_f64: pass (3435965098 4278242508 4042304170 223 85 2)

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

@kingzzim7-create

Copy link
Copy Markdown
Author

Thanks @Flyander, you're right: the 32 lanes stored to the same six offsets, which is a data race under the Vulkan memory model even with identical values. Fixed in the new commit: v_cmpx_eq_u32_e32 0, v0 before the stores, as cs_w32_new_ops does, so only lane 0 writes. The computation still runs in every lane. Re-run on the RTX 4060 Ti (driver 621.01): PASS with the same words 3435965098 4278242508 4042304170 223 85 2, natively and with LEONIDA_W64_EMULATE=1.

#4491 (cs_w32_fmamk_f16) had the same pattern, so it got the same one-line fix.

Thanks also @CaravelaLabs for the Radeon 8060S run.

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 f6b8a2e9 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 6/6 words with zero Khronos validation diagnostics. The corrected single-writer fixture supersedes incidental matching readbacks from the earlier shared-write fixture. Details in #166. AI-assisted.

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Follow-up at f6b8a2e9 (only lane 0 stores): cs_w32_cmp_f64 still pass on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5), Mesa 25.2.8, Ubuntu 24.04 (3435965098 4278242508 4042304170 223 85 2); rest of the suite unchanged vs cb2b0399. AI-assisted (Claude Code).

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested f6b8a2e 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_cmp_f64 PASS.

AI-assisted (Claude Code).

@kingzzim7-create

Copy link
Copy Markdown
Author

Merged main to resolve the docs/design.md conflict. The v_cmp_*_f64 row now keeps main's gfx1100 measurement and adds this PR's GPU-checked sentence (dropped "Not measured on AMD hardware", since the row now has an AMD measurement and it also passed on a Radeon 8060S above). No other rows changed.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 82dd216732646ae5e2e2f6082e9552c19581e05b on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

The wave32 binary64 compare fixture cs_w32_cmp_f64 passed with the compute harness built from this head. All six output words matched.

For a precision check I changed the final register pair v[12:13] from 1.0 to the next representable binary64 value above 1.0 by setting its low word to 1. The comparison with the inline 1.0 literal then cleared exactly bit 4 of out[3] (223 → 207). The other five words matched, and the runner correctly rejected the modified fixture against the stock expectations. Both shaders passed spirv-val.

AI-assisted verification.

@jimokulou2-ops

Copy link
Copy Markdown

Tested 82dd216 merged onto main 98fa503 (clean merge) on AMD Radeon RX 9070 XT (RDNA4), AMD 26.11.2 (32.0.32029.2010, LLPC, Vulkan 1.4.359), Windows 11 Pro 26300: pass.

  • Test programs built from main with llvm-mingw (the PR doesn't touch the runtime C++), llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363.0, LEONIDA_VK_DEVICE=9070.
  • scripts/run_gpu_tests.py, full suite: 203/218 passed, 15 skipped, 0 failed; 222 shaders translated, 222 pass spirv-val. main 98fa503 on the same machine: 202/217, the same 15 skipped. The only difference is the new test:
    • cs_w32_cmp_f64: PASS 3435965098 4278242508 4042304170 223 85 2
  • tests/semantic/regen_fixtures.py --check: clean.

No game files. 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.