mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1320] [CLOSED] wave64_halves: a waterfall proof needs equality of the whole word (SHADER-WATERFALL-FULL-WORD) #1350
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1350
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1320
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/shader-waterfall-full-word📝 Commits (1)
2e13336wave64_halves: a waterfall proof needs equality of the whole word (SHADER-WATERFALL-FULL-WORD)📊 Changes
3 files changed (+36 additions, -2 deletions)
View changed files
📝
docs/design.md(+1 -0)📝
tests/semantic/test_wave64_halves.py(+33 -0)📝
tools/wave64_halves.py(+2 -2)📄 Description
Rebased onto
bfef489cat2e133360. Main already has the classifier from #984. This diff adds the expanded whole-word comparison tests and clarifies the contract. The focused suite passed 128 tests. Earlier GPU results refer to the earlier head.Claimed in the coordination issue as: SHADER-WATERFALL-FULL-WORD (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. #1257 (open,
TEST-WATERFALL-DESCRIPTOR) adds a CPU test that each lane fetches from its own descriptor-table entry in a waterfall loop; the integration's own table-execution test, its fixture and the interpreter support it needs are therefore not in this pull request, which keeps only the proof fix and its regression test. #805, #1091, #187 and #508 (open) also edittools/wave64_halves.py; none of them changes the waterfall compare incmp_tag(#1091 adds a method just above it).What and why
tools/wave64_halves.pydecides whether a wave64 vertex, pixel or geometry shader gives the same results when its wave is cut into two 32-lane halves, and the translator records the answer aswave64_graphicsA/B/C. Tier B includes the waterfall loop: read a word from the first active lane, select the lanes that hold the same word, run the body with that scalar, retire them, repeat. The proof is that every selected lane holds the word that was read.cmp_tagaccepted anyv_cmp_eq_*of the scalar against the VGPR it was read from as that proof. That is only true for an equality of the whole unmodified 32-bit word:v_cmp_eq_f32takes +0.0 and −0.0 as equal. With lanes 0..31 at +0.0 and lanes 32..63 at −0.0, the wave runs all 64 lanes with the bits of lane 0, while the second half reads −0.0 from its own first lane.v_cmp_eq_u16/_i16and an SDWA compare of the low halves ignore the high half in the same way.In each case the two runs differ, and the shader was still recorded as tier B, the tier the module describes as invariant by construction.
The change takes only
v_cmp_eq_u32andv_cmp_eq_i32(and theirv_cmpxforms,_e32or_e64), with no SDWA or DPP, no modifier and noabs/negon a source. Any other compare tags no waterfall, so the loop is tier C with the reasonscross-laneandtainted-exec. A 64-bit equality is no longer taken either; that is conservative, since it does imply the low word.The restriction follows Marvisak/VIctory's waterfall check (GPL-3.0, commit
b1c8306), which takes an unmodifiedu32ori32equality and also a 64-bit one; it is credited in the source and in the contract row.What this does not do
wave64_graphics), a warning by default and an error only with--wave64-graphics error.docs/design.md(35 waterfall idioms) were not re-run.v_readfirstlane,v_cmp_eq_u32,s_and_saveexec_b64, a body, EXEC restored) is recorded as tier B with the idiomwaterfallalthough the lanes outside the first lane's group are handled by a half and not by the wave (64 lanes against two waves of 32 differ). That is the same on the base commit and needs its own change.Tested
Linux (CachyOS, kernel 7.3.5), Python 3.14, SPIRV-Tools v2026.4. Based on
6293c1c4f.python3 -I tests/semantic/test_wave64_halves.py: 127 tests pass. The newtest_waterfall_needs_whole_word_integer_equalityruns the loop on the wave interpreter with 64 lanes and with two waves of 32, lanes 0..31 holding one word and lanes 32..63 another. Forv_cmp_eq_f32andv_cmpx_eq_f32(words 0 / 0x80000000) and forv_cmp_eq_u16,v_cmp_eq_i16,v_cmpx_eq_u16andv_cmp_eq_u32_sdwawithWORD_0selects (words 0 / 0x10000) the wave writes 0 to all 64 lanes, the halves write the second word to lanes 32..63, and the tier is C. Forv_cmp_eq_u32_e32,v_cmp_eq_i32_e32,v_cmp_eq_u32_e64,v_cmpx_eq_u32_e32andv_cmpx_eq_i32_e32on the same words both runs give each lane its own word and the tier is B. Thev_cmpxloops narrow EXEC from a copy saved at the head of the loop.LEONIDA_TOOLS_DIR=<export of 6293c1c4f>/tools): 6 failing subtests, the six partial compares, each'B' != 'C'after the two runs were seen to differ. The five integer controls pass there too.python3 -I scripts/run_semantic_tests.py tests/semantic -p 'test_wave64_halves*.py' -j 1: 175 tests, OK.python3 -I -m pytest -q tests/test_wave64_halves_fixtures.py: 10 passed (the*_w64_*GPU fixtures keep their tiers; their three waterfalls compare withv_cmp_eq_u32_e32).tests/test_*.pyoutsidetests/semanticwithpython3 -I <file>, or pytest where it has no__main__;python3 -I scripts/run_semantic_tests.py tests/semantic -j 2; the tracked-file guard) on the committed tree: one failing file,tests/test_imhex_patterns.py, which fails on the base commit too (the same 6 of its 9 tests). Semantic suite: 470 files, 6,169 tests, 0 files failed (base: 470 files, 6,168 tests, 0 failed).python3 -I scripts/check_no_game_data.py: passes.Not run: a GPU (
runtime/test/shaders/w64_graphics.py), the corpus census, native Windows or macOS, the runtime build (no C++ or build file changes).GPUs tested: none (wave interpreter on the CPU only).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.docs/design.md("Wave64 graphics: the waterfall compare"), with how it was checked and what is not measured.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.