[PR #1238] bench_wave64: exercise partial ballots and check the stock shader output #1272

Open
opened 2026-11-26 20:20:40 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1238
Author: @titoreinaldo
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: contrib/r2-ballot


📝 Commits (1)

  • 5a1e17f bench_wave64: exercise partial ballots and check the stock shader readback

📊 Changes

4 files changed (+66 additions, -3 deletions)

View changed files

📝 runtime/test/shaders/cs_bench_mix.asm (+3 -2)
📝 runtime/test/vk_compute_test.cpp (+35 -0)
📝 scripts/bench_wave64.py (+7 -1)
📝 tests/test_bench_wave64.py (+21 -0)

📄 Description

Claimed in the coordination issue as: SHADER-BENCH-MIX-BALLOT
Claim in #14

What and why

The stock benchmark used the bottom two bits of (index * 0x9e3779b1) ^ index for its ballot. Those bits always cancel, so no lane was selected. A broken prefix count in the upper half of the wave could still give identical output across runs and GPUs.

Using bits 8–9 selects 16,896 of the first 65,536 inputs. Each 32-lane half has 7–9 participants, and the halves have different counts in every one of those 1,024 workgroups. The harness now checks the stock shader’s output against a CPU implementation after timing, including its whole-wave prefix, neighbor reads and branches. Custom benchmark shaders retain the existing dump mode.

Tested

  • Built the original and revised synthetic shaders separately with LLVM and SPIR-V Tools. Both translated and validated. On the RTX 3070 the original shader failed the new check at all 65,536 words. A separate control that zeroed only the upper-half prefix mask failed at 29,440 words, starting at lane 34.
  • With the fix, both GPUs passed vk_compute_test cs_bench_mix.spv 65535 bench_mix: 4,194,240 words checked per GPU, zero mismatches, output hash 7d38f475 (with VKC_BENCH=1).
  • python -I scripts/bench_wave64.py --emulated-only --build <build> --groups 1024 --procs 2 --reps 2 returned the same hash c80c78fb on each GPU. python -I tests/test_bench_wave64.py passed all 15 tests.
  • The shared base 58be9cdf ran 6,168 translator tests in 470 files with zero failing files. Verified a clean merge with main at 705ea091 and with #1054.

GPUs tested: Windows 11 Pro 26H2 build 26300.9974. NVIDIA GeForce RTX 3070 eGPU, driver 610.88, reported subgroup 32..32. Intel(R) Arc(TM) Graphics, driver 32.0.101.8132, reported subgroup 8..32. Both runs used wave64 emulation, and each harness log identified its selected device. Native wave64 hardware coverage is still open.

AI-assisted: yes, OpenAI Codex. Synthetic shader and buffers.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1238 **Author:** [@titoreinaldo](https://github.com/titoreinaldo) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `contrib/r2-ballot` --- ### 📝 Commits (1) - [`5a1e17f`](https://github.com/ubiquitarianism/leonida/commit/5a1e17f9728b3393e5e216c99ac018bfaf34f4b7) bench_wave64: exercise partial ballots and check the stock shader readback ### 📊 Changes **4 files changed** (+66 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `runtime/test/shaders/cs_bench_mix.asm` (+3 -2) 📝 `runtime/test/vk_compute_test.cpp` (+35 -0) 📝 `scripts/bench_wave64.py` (+7 -1) 📝 `tests/test_bench_wave64.py` (+21 -0) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-BENCH-MIX-BALLOT [Claim in #14](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143476751) ### What and why The stock benchmark used the bottom two bits of `(index * 0x9e3779b1) ^ index` for its ballot. Those bits always cancel, so no lane was selected. A broken prefix count in the upper half of the wave could still give identical output across runs and GPUs. Using bits 8–9 selects 16,896 of the first 65,536 inputs. Each 32-lane half has 7–9 participants, and the halves have different counts in every one of those 1,024 workgroups. The harness now checks the stock shader’s output against a CPU implementation after timing, including its whole-wave prefix, neighbor reads and branches. Custom benchmark shaders retain the existing dump mode. ### Tested - Built the original and revised synthetic shaders separately with LLVM and SPIR-V Tools. Both translated and validated. On the RTX 3070 the original shader failed the new check at all 65,536 words. A separate control that zeroed only the upper-half prefix mask failed at 29,440 words, starting at lane 34. - With the fix, both GPUs passed `vk_compute_test cs_bench_mix.spv 65535 bench_mix`: 4,194,240 words checked per GPU, zero mismatches, output hash `7d38f475` (with `VKC_BENCH=1`). - `python -I scripts/bench_wave64.py --emulated-only --build <build> --groups 1024 --procs 2 --reps 2` returned the same hash `c80c78fb` on each GPU. `python -I tests/test_bench_wave64.py` passed all 15 tests. - The shared base `58be9cdf` ran 6,168 translator tests in 470 files with zero failing files. Verified a clean merge with `main` at `705ea091` and with #1054. GPUs tested: Windows 11 Pro 26H2 build 26300.9974. NVIDIA GeForce RTX 3070 eGPU, driver 610.88, reported subgroup 32..32. Intel(R) Arc(TM) Graphics, driver 32.0.101.8132, reported subgroup 8..32. Both runs used wave64 emulation, and each harness log identified its selected device. Native wave64 hardware coverage is still open. AI-assisted: yes, OpenAI Codex. Synthetic shader and buffers. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1272
No description provided.