tests: GPU readback for the binary64 vector compares, v_cmp_*_f64 and v_cmpx_*_f64 (GPU-CMP-F64) #1012

Merged
milk4sale merged 2 commits from upstream-pr/1012 into main 2026-11-24 23:02:27 +00:00
milk4sale commented 2026-11-24 16:49:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by milk4sale on 2026-11-24T16:49:21Z.


Claimed in the coordination issue as: GPU-CMP-F64 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137637578)

What and why

The v_cmp_*_f64, v_cmpx_*_f64 row of docs/design.md is CPU-checked and measured on native gfx1100, and said Not GPU-verified: no fixture in runtime/test/shaders used a binary64 compare, so the SPIR-V those 32 ops translate to (an ordering built from 32-bit integer ops, no Float64) had not run on a driver.

This adds cs_w32_cmp_f64, a memory-fed fixture in the style of cs_w32_shift64 (#590):

  • check.py seeds 256 operand pairs through VKC_HEAP_INIT: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword, a negative quiet NaN). Each of 128 threads loads two pairs at run time, so neither the translator nor the driver can fold a compare.
  • Per pair a thread stores a v_cmp_ word (through VCC) and a v_cmpx_ word (through EXEC): bits 0..15 are the 16 predicates in opcode order, bit 16 is tru run with the odd threads turned off (an inactive lane gets VCC 0 from v_cmp_ and stays off through v_cmpx_), bits 17 and 18 are lt and nge with VOP3 abs/neg.
  • The expected words come from Python floats (cmp_f64_words). Both GPU runners compare all 1536 heap words, the 1024 unchanged input words included.
  • tests/test_gpu_cmp_f64.py needs no GPU: it checks the oracle against an independent restatement of the 16 predicates, a few words worked out by hand, that the assembly gives every predicate the oracle's bit, and the readback and runner verdicts against a fake harness. tests/test_shader_checks.py counts and fakes the new case.
  • docs/testing.md describes the fixture and the contract row names it.

No translator or runtime change. The SGPR-pair and constant operand forms are not in the fixture; they stay CPU-checked by tests/semantic/test_cmp_f64.py.

Tested

At this head (50407827c on main 82a2aabcc), test programs rebuilt at this head, llvm-mc 23.1.4, SPIRV-Tools v2026.4:

  • python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass on the RTX 4070 Ti: PASS natively and with LEONIDA_W64_EMULATE=1 ("1536 words exact").
  • The same on llvmpipe (subgroup 8..8): PASS. The runner asks for 32-wide subgroups, the device says "not available", and the words are exact, so no step of the fixture depends on the subgroup width.
  • python -I tests/test_gpu_cmp_f64.py (9 tests), tests/test_shader_checks.py (87), tests/test_run_gpu_tests.py (64), tests/test_gpu_shift64.py, tests/test_docs_design_rows.py, tests/test_docs_links.py, tests/test_docs_repo_paths.py, tests/test_text_write_line_endings.py, tests/test_regen_fixtures.py: OK. python -m compileall -q make_game.py tools tests and scripts/check_no_game_data.py on the changed files: OK.

Before the rebase (the same change on main 42d705c85):

  • Negative controls on the RTX 4070 Ti, one translator rule broken at a time and the fixture rebuilt; each failed at the word the oracle predicts: no -0 canonicalization (word 206), a NaN test that ignores the low dword (28), an ordering key without the low dword (70), the raw result written to an inactive lane's VCC (2), v_cmpx_ replacing EXEC instead of narrowing it (3), abs ignored (0), nlt lowered as the negation of le (0).
  • Full run_gpu_tests.py on the RTX 4070 Ti: 260 shaders, 260 translated, 260 pass spirv-val; native 200/251 passed, 49 skipped, 2 failed; LEONIDA_W64_EMULATE=1 232/251 passed, 17 skipped, 2 failed. The two failures are cs_imgload_tfe and cs_imgload_d16_tfe, already recorded for this GPU in gpu-test-results/RTX4070Ti.txt.
  • Every standalone standard-library test file (490): all pass except tests/test_tool_stdout_encoding.py, which fails the same way without this change (tools/native_pso_hashes.py; #883 and #948 are open for it).

Not run: llvm-mc 19, which the linux-gpu-tools job assembles with (not installed here); the translator suite (nothing under tools/ or tests/semantic/ changes); Windows; AMD hardware. The 4070 Ti run checks the translated SPIR-V on a driver against IEEE-754. What ties the predicates to RDNA2 is the row's native gfx1100 measurement, which this does not repeat.

GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); Mesa llvmpipe 26.2.6 (LLVM 23.1.4), same machine

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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. (No new rule; the existing row now names the fixture.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5476502534 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1012). Originally posted by [milk4sale](https://github.com/milk4sale) on 2026-11-24T16:49:21Z. --- Claimed in the coordination issue as: GPU-CMP-F64 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137637578) ### What and why The `v_cmp_*_f64`, `v_cmpx_*_f64` row of `docs/design.md` is CPU-checked and measured on native gfx1100, and said **Not GPU-verified**: no fixture in `runtime/test/shaders` used a binary64 compare, so the SPIR-V those 32 ops translate to (an ordering built from 32-bit integer ops, no `Float64`) had not run on a driver. This adds `cs_w32_cmp_f64`, a memory-fed fixture in the style of `cs_w32_shift64` (#590): - `check.py` seeds 256 operand pairs through `VKC_HEAP_INIT`: the product of 16 values (±inf, ±max, the 1-ULP neighbours of ±1, the smallest subnormals, ±0, the smallest normal, a NaN whose payload is only in the low dword, a negative quiet NaN). Each of 128 threads loads two pairs at run time, so neither the translator nor the driver can fold a compare. - Per pair a thread stores a `v_cmp_` word (through VCC) and a `v_cmpx_` word (through EXEC): bits 0..15 are the 16 predicates in opcode order, bit 16 is `tru` run with the odd threads turned off (an inactive lane gets VCC 0 from `v_cmp_` and stays off through `v_cmpx_`), bits 17 and 18 are `lt` and `nge` with VOP3 `abs`/`neg`. - The expected words come from Python floats (`cmp_f64_words`). Both GPU runners compare all 1536 heap words, the 1024 unchanged input words included. - `tests/test_gpu_cmp_f64.py` needs no GPU: it checks the oracle against an independent restatement of the 16 predicates, a few words worked out by hand, that the assembly gives every predicate the oracle's bit, and the readback and runner verdicts against a fake harness. `tests/test_shader_checks.py` counts and fakes the new case. - `docs/testing.md` describes the fixture and the contract row names it. No translator or runtime change. The SGPR-pair and constant operand forms are not in the fixture; they stay CPU-checked by `tests/semantic/test_cmp_f64.py`. ### Tested At this head (`50407827c` on `main` `82a2aabcc`), test programs rebuilt at this head, llvm-mc 23.1.4, SPIRV-Tools v2026.4: - `python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_cmp_f64 --require-pass` on the RTX 4070 Ti: PASS natively and with `LEONIDA_W64_EMULATE=1` ("1536 words exact"). - The same on llvmpipe (subgroup 8..8): PASS. The runner asks for 32-wide subgroups, the device says "not available", and the words are exact, so no step of the fixture depends on the subgroup width. - `python -I tests/test_gpu_cmp_f64.py` (9 tests), `tests/test_shader_checks.py` (87), `tests/test_run_gpu_tests.py` (64), `tests/test_gpu_shift64.py`, `tests/test_docs_design_rows.py`, `tests/test_docs_links.py`, `tests/test_docs_repo_paths.py`, `tests/test_text_write_line_endings.py`, `tests/test_regen_fixtures.py`: OK. `python -m compileall -q make_game.py tools tests` and `scripts/check_no_game_data.py` on the changed files: OK. Before the rebase (the same change on `main` `42d705c85`): - Negative controls on the RTX 4070 Ti, one translator rule broken at a time and the fixture rebuilt; each failed at the word the oracle predicts: no `-0` canonicalization (word 206), a NaN test that ignores the low dword (28), an ordering key without the low dword (70), the raw result written to an inactive lane's VCC (2), `v_cmpx_` replacing EXEC instead of narrowing it (3), `abs` ignored (0), `nlt` lowered as the negation of `le` (0). - Full `run_gpu_tests.py` on the RTX 4070 Ti: 260 shaders, 260 translated, 260 pass `spirv-val`; native 200/251 passed, 49 skipped, 2 failed; `LEONIDA_W64_EMULATE=1` 232/251 passed, 17 skipped, 2 failed. The two failures are `cs_imgload_tfe` and `cs_imgload_d16_tfe`, already recorded for this GPU in `gpu-test-results/RTX4070Ti.txt`. - Every standalone standard-library test file (490): all pass except `tests/test_tool_stdout_encoding.py`, which fails the same way without this change (`tools/native_pso_hashes.py`; #883 and #948 are open for it). Not run: llvm-mc 19, which the `linux-gpu-tools` job assembles with (not installed here); the translator suite (nothing under `tools/` or `tests/semantic/` changes); Windows; AMD hardware. The 4070 Ti run checks the translated SPIR-V on a driver against IEEE-754. What ties the predicates to RDNA2 is the row's native gfx1100 measurement, which this does not repeat. GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS, kernel 7.3.3); Mesa llvmpipe 26.2.6 (LLVM 23.1.4), same machine AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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. (No new rule; the existing row now names the fixture.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KernelSmoker commented 2026-11-24 17:02:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T17:02:21Z.

Review: APPROVED


Verified on exact head 50407827cd. The focused CPU suites pass: f64 compare oracle 9/9, shader checks 87/87, GPU runner 64/64, design contract rows 5/5, docs links 16/16. Changed-file no-game-data and git diff --check pass. The independent runtime GPU execution reported in the PR is on an RTX 4070 Ti and llvmpipe; I did not independently reproduce a GPU run here. The host RTX 3090 is present, but no fixture harness is built locally and only 72 MB disk space was free, so an honest 3090 run was not feasible. No game data used.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6043782609 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1012#pullrequestreview-6043782609). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T17:02:21Z. **Review:** APPROVED --- Verified on exact head 50407827cd2cb73313c585cdf3d3d40ed7918bae. The focused CPU suites pass: f64 compare oracle 9/9, shader checks 87/87, GPU runner 64/64, design contract rows 5/5, docs links 16/16. Changed-file no-game-data and `git diff --check` pass. The independent runtime GPU execution reported in the PR is on an RTX 4070 Ti and llvmpipe; I did not independently reproduce a GPU run here. The host RTX 3090 is present, but no fixture harness is built locally and only 72 MB disk space was free, so an honest 3090 run was not feasible. No game data used.
veqzo commented 2026-11-24 17:23:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by veqzo on 2026-11-24T17:23:47Z.


Tested PR head 50407827cd2cb73313c585cdf3d3d40ed7918bae on Windows with an NVIDIA GeForce GTX 1080 and driver 582.78.

  • cs_w32_cmp_f64: PASS, 1,536 words matched.
  • The same test with LEONIDA_W64_EMULATE=1: PASS, 1,536 words matched.
  • The generated SPIR-V passed spirv-val in both runs.
  • tests/test_gpu_cmp_f64.py: 9 tests passed.

Tools: LLVM 23.1.6 and SPIR-V Tools 2026.4. The GPU test programs were built from the same PR revision.

AI-assisted testing.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7139130008 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1012#issuecomment-7139130008). Originally posted by [veqzo](https://github.com/veqzo) on 2026-11-24T17:23:47Z. --- Tested PR head `50407827cd2cb73313c585cdf3d3d40ed7918bae` on Windows with an NVIDIA GeForce GTX 1080 and driver 582.78. - `cs_w32_cmp_f64`: **PASS**, 1,536 words matched. - The same test with `LEONIDA_W64_EMULATE=1`: **PASS**, 1,536 words matched. - The generated SPIR-V passed `spirv-val` in both runs. - `tests/test_gpu_cmp_f64.py`: **9 tests passed**. Tools: LLVM 23.1.6 and SPIR-V Tools 2026.4. The GPU test programs were built from the same PR revision. AI-assisted testing.
iFeyz commented 2026-11-24 19:40:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by iFeyz on 2026-11-24T19:40:43Z.


AMD run (the "AMD hardware" gap): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11. Head 50407827c, scripts/run_gpu_tests.py --filter cs_w32_cmp_f64 with the test programs of a current main build.

  • cs_w32_cmp_f64: PASS, 1536 words exact (256 operand pairs and unchanged inputs), native (subgroup 64) and with LEONIDA_W64_EMULATE=1.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142435403 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1012#issuecomment-7142435403). Originally posted by [iFeyz](https://github.com/iFeyz) on 2026-11-24T19:40:43Z. --- AMD run (the "AMD hardware" gap): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11. Head `50407827c`, `scripts/run_gpu_tests.py --filter cs_w32_cmp_f64` with the test programs of a current `main` build. - `cs_w32_cmp_f64`: **PASS, 1536 words exact** (256 operand pairs and unchanged inputs), native (subgroup 64) and with `LEONIDA_W64_EMULATE=1`.
milk4sale commented 2026-11-24 22:30:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by milk4sale on 2026-11-24T22:30:48Z.


The two red checks on this pull request come from the base it was tested against, not from the change. The run tested head 50407827c merged into main at 82a2aabcc, which was itself red on both jobs:

  • windows: gta6rt.exe failed to link, with WaitOnAddress, WakeByAddressSingle and WakeByAddressAll unresolved from leonida_xma2_decoder.lib. Fixed on main by #877.
  • linux-gpu-tools: cs_imgload_tfe and cs_imgload_d16_tfe failed (r32 sint (sint view): 64 bad). This pull request does not touch them; their expectation was fixed on main by #892.

In the same llvmpipe run this pull request's own fixture passed: cs_w32_cmp_f64 1536 words exact, and the job ended at 171/253 passed, 80 skipped, with only those two failures.

I have not pushed to re-run CI: the Runtime queue is several hours behind, and #1034 and #1047 are stacked on this branch. (Comment written with AI assistance from the job logs.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7146318591 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1012#issuecomment-7146318591). Originally posted by [milk4sale](https://github.com/milk4sale) on 2026-11-24T22:30:48Z. --- The two red checks on this pull request come from the base it was tested against, not from the change. The run tested head `50407827c` merged into `main` at `82a2aabcc`, which was itself red on both jobs: - **windows**: `gta6rt.exe` failed to link, with `WaitOnAddress`, `WakeByAddressSingle` and `WakeByAddressAll` unresolved from `leonida_xma2_decoder.lib`. Fixed on `main` by #877. - **linux-gpu-tools**: `cs_imgload_tfe` and `cs_imgload_d16_tfe` failed (`r32 sint (sint view): 64 bad`). This pull request does not touch them; their expectation was fixed on `main` by #892. In the same llvmpipe run this pull request's own fixture passed: `cs_w32_cmp_f64 1536 words exact`, and the job ended at 171/253 passed, 80 skipped, with only those two failures. I have not pushed to re-run CI: the Runtime queue is several hours behind, and #1034 and #1047 are stacked on this branch. (Comment written with AI assistance from the job logs.)
aslan2142 commented 2026-11-24 23:02:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T23:02:30Z.


Merged. Checked locally on main 28a32e190 + d366ee248:

  • Claim: valid. GPU-CMP-F64 was posted at 16:25 UTC, before this PR, and is unedited.
  • The expected values hold up: cmp_f64_words agrees with a separate model that orders by integer keys, with 0 mismatches in 512 result words. By hand: −0 against +0 is eq, the smallest subnormal is gt +0, and both NaNs are unordered on every predicate.
  • GPU, with main's translator: cs_w32_cmp_f64 passes with all 1,536 words exact on llvmpipe (Mesa 26.3.1) and on an RDNA2 iGPU (RADV). The neighbouring cs_w32_ cases: 13 passed and 8 skipped for subgroup width on llvmpipe, 21 of 21 on the iGPU.
  • On the merge: the semantic suite passes (474 files, 6,194 tests, 0 files failed); test_gpu_cmp_f64, test_run_gpu_tests, test_shader_checks pass; the 13 docs and writer tests pass; check_no_game_data.py is clean on the 7 changed files.
  • CI had not finished on this head, so the merge rests on the runs above and on the reports here (a GTX 1080 and an RX 9070 XT, both passing).

#1039's cs_w32_vcmp_f64 covers the same row; as that PR says itself, it can drop the row now. #1034, #1047 and #1063 build on this one and follow.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7146943173 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1012#issuecomment-7146943173). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T23:02:30Z. --- Merged. Checked locally on `main` `28a32e190` + `d366ee248`: - **Claim:** valid. `GPU-CMP-F64` was posted at 16:25 UTC, before this PR, and is unedited. - **The expected values hold up:** `cmp_f64_words` agrees with a separate model that orders by integer keys, with 0 mismatches in 512 result words. By hand: −0 against +0 is `eq`, the smallest subnormal is `gt` +0, and both NaNs are unordered on every predicate. - **GPU, with `main`'s translator:** `cs_w32_cmp_f64` passes with all 1,536 words exact on llvmpipe (Mesa 26.3.1) and on an RDNA2 iGPU (RADV). The neighbouring `cs_w32_` cases: 13 passed and 8 skipped for subgroup width on llvmpipe, 21 of 21 on the iGPU. - **On the merge:** the semantic suite passes (474 files, 6,194 tests, 0 files failed); `test_gpu_cmp_f64`, `test_run_gpu_tests`, `test_shader_checks` pass; the 13 docs and writer tests pass; `check_no_game_data.py` is clean on the 7 changed files. - **CI had not finished on this head,** so the merge rests on the runs above and on the reports here (a GTX 1080 and an RX 9070 XT, both passing). #1039's `cs_w32_vcmp_f64` covers the same row; as that PR says itself, it can drop the row now. #1034, #1047 and #1063 build on this one and follow. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1012
No description provided.