mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:30:52 +01:00
[PR #1381] tests: wave reductions and lane-spilled masks under --wave64-emulate, and the emulated CPU model runs the LDS min/max/sub atomics (TEST-W64-EMU-WAVE-REDUCE) #1410
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#1410
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/1381
Author: @milk4sale
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:test/w64-emulate-wave-reduce📝 Commits (1)
aad0d61tests: wave reductions and lane-spilled masks under --wave64-emulate (TEST-W64-EMU-WAVE-REDUCE)📊 Changes
2 files changed (+309 additions, -0 deletions)
View changed files
📝
tests/semantic/test_wave64_emulate_opt.py(+22 -0)➕
tests/semantic/test_wave64_emulate_wave_reduce.py(+287 -0)📄 Description
Claimed in the coordination issue as: TEST-W64-EMU-WAVE-REDUCE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146823788)
What and why
run_emulated_workgroupintests/semantic/test_wave64_emulate_opt.pyis the CPU model that runs--wave64-emulateoutput on all 64 lanes of a workgroup. It executed only the OR, add, AND, XOR and exchange atomics. A wave64 program withds_min_u32stopped atNotImplementedError: unsupported op OpAtomicUMin, so nothing that uses the LDS min, max or subtract instructions could be checked under emulation on the CPU. It now also runsOpAtomicUMin,UMax,SMin,SMaxandISub. The new branch sits below the existing one, so it does not touch the lines that the open pull requests on this function change (#1110 and #850).tests/semantic/test_wave64_emulate_wave_reduce.py(new, hand-written, made-up values) uses it for two sequences a compiler emits for a wave64, which under emulation only come out right when the two 32-lane halves agree on every scalar:s_or_saveexec_b64 ..., -1, lanes that were off get the identity throughv_cndmask_b32, four DPP steps reduce each 16-lane row (quad_perm[1,0,3,2] and [2,3,0,1],row_half_mirror,row_mirror),v_permlanex16_b32joins the two rows of each half,v_readlane_b32of lane 0 is folded into every lane andv_readlane_b32of lane 63 is then the wave's result. EXEC is narrowed to the first lane that was on (s_ff1_i32_b64,s_lshl_b64 ..., 1, sN,s_and_b64 execors_and_saveexec_b64) and that lane doesds_or_b32for an OR andds_min_u32for an unsigned MIN. A counter raised byds_add_u32beside each commit shows that exactly one lane ran it, which an idempotent OR or MIN would hide. Seven EXEC ranges: both halves, the whole wave, each half alone, one lane in the high half, lane 0 alone, and the two lanes either side of the half boundary.v_writelane_b32of each half of the pair, the SGPRs reused for another mask and for numbers,v_readlane_b32back, thens_mov_b64 execandv_cndmask_b32on the reloaded pair. Six cases.ds_min_u32,ds_max_u32,ds_min_i32,ds_max_i32andds_sub_u32, from all 64 lanes of one wave, with lane values that tell signed from unsigned.Each program is translated twice, without and with
--wave64-emulate, and run on 64 lanes: natively byspirv_mini_interp.run_workgroupas one 64-wide subgroup, emulated byrun_emulated_workgroup. Both must give every lane the words of a plain-Python reference.The translator turns out to be right for both sequences and for the five atomics, natively and emulated: this pull request is coverage, not a fix.
Tested
python -I tests/semantic/test_wave64_emulate_wave_reduce.py: 5 tests pass (Python 3.14, Linux), onmain28a32e190plus this commit.NotImplementedError: unsupported op OpAtomicUMinin the emulated run.x_memory_order(and its mirror inwave64_emulate_opt.py), so no order barrier before a later LDS read: 14 subtests fail, in the reduction test and the atomics test;v_readlane_b32selecting lane & 31 in a wave64: 20 subtests of the reduction test fail;v_permlanex16_b32reading its own row half: 20 subtests of the reduction test fail;python -I scripts/run_semantic_tests.py tests/semantic: 475 files, 6,199 tests, 0 files failed.test_wave64_emulate_opt.py(#1110 and #850 with a line offset, #1272, #793 and #106 without), and the five new tests also pass on the head of #1043 (68b964e42), which changes how a lane mask is read as a number.python -m compileall -q make_game.py tools tests,python -I make_game.py --help,python -I scripts/check_no_game_data.pyon both files,python -I tests/test_text_write_line_endings.py,git diff --check.python -I tests/test_ci_registration.pyfails here as it does onmainwithout this commit, ontests/semantic/test_sub_co_same_operand.py(#1365 has the fix).translator-testsis red onmainfor another reason that #1375 addresses. Neither comes from this change.Not run: Python 3.12 (the version CI installs), Windows and macOS. No GPU run: the programs run in the two CPU interpreters only, and no GPU fixture is added.
GPUs tested: n/a (two Python test files; no shader, fixture or runtime code)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.