mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:10:53 +01:00
[PR #2102] [MERGED] wave64_emulate_opt: a guarded s_barrier keeps only the tail in the round scheduler (SHADER-W64-STRUCTURED-SBARRIER-TAIL) #2107
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#2107
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/2102
Author: @DadaCap
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142
Base:
main← Head:mesh-epilogue-tail📝 Commits (1)
8481605wave64_emulate_opt: a guarded s_barrier keeps only the tail in the round scheduler (SHADER-W64-STRUCTURED-SBARRIER-TAIL)📊 Changes
4 files changed (+52 additions, -18 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
tests/semantic/test_loop_ballot_barrier.py(+2 -2)📝
tests/semantic/test_wave64_emulate_opt.py(+45 -7)📝
tools/wave64_emulate_opt.py(+4 -8)📄 Description
Claimed in the coordination issue as: SHADER-W64-STRUCTURED-SBARRIER-TAIL (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7174042486)
Depends on: nothing
What and why
Under
--wave64-emulate,plan_structured_emulationgives no plan for a multi-wave program (more than 64 threads) as soon as ones_barriersits under a guard or in a loop. The NGG mesh epilogue has one (s_cbranch_vccnzover ans_barrier), so every mesh program of 1.0.2.1 runs whole in the round scheduler.The planner already has a step for a tail that must stay in rounds (
tail_scheduler, used from an earlys_endpgmon). This change uses it from the first guardeds_barrieron as well, and emits what comes before in the structured form.Why it is sound:
s_barrierand runs to the end of the program, so every suchs_barrier, and every one after it, stays in the rounds. Waves on different paths still meet at different sites there (cs_barrier_divergent).s_barriers in top-level blocks, which the whole workgroup reaches, and nos_endpgm.Counts over 1.0.2.1 (translator only)
spirv-valfailuresAll of them translate before and after. The compute programs were run through main's translator again for the "before" column (none is structured). For mesh, main's translator gives the same bytes as the old folder for three programs I checked. Other stages cannot reach this code.
Measured in the game
Two runs of the same executable (a local tree of
db1a22d29with other open work, GPU timer on), the only difference being the mesh modules. Median GPU time of the sampled indirect draws, for the 17 mesh programs sampled at the same group count in both; the sample counts are small for some:MS_VS_TransformD_c5fd36bbMS_VS_OctaSLOD_5fd19871MSNC_VS_TransformSkinD_9e3a1555MS_VS_TransformD_c5fd36bb~153MSNC_VS_PropFoliageSkinDeferred_4352f5e1~8MSNC_VS_TransformSkinD_9e3a1555~50The other 11 are between 0.13 and 0.64.
Not shown by these runs:
Tested
tests/semantic/test_wave64_emulate_opt.py:test_multiwave_divergent_sbarrier_falls_back_to_roundsasserted the old fallback; it now asserts that boths_barrierarms are in the tail, and the same memory result in both invocation orders. New: a mesh-epilogue shape (guardeds_barrier, skipped and taken, 128 threads, both orders).tests/semantic/test_loop_ballot_barrier.py: two tests asserted the rounds form for ans_barrierin a loop; they now expect the structured form, and their memory results (including the wave that ends early) are unchanged.tests/test_translate.py: 706 pass, 2 fail (cs_dpp_cmp.asm: my olderllvm-mcrefuses the DPP form ofv_cmp); both fail the same way on plainmainhere.python -I -m compileall -q tools tests,tests/test_docs_*.py,scripts/check_no_game_data.pyon the changed files.GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (the game runs above; the hand-written GPU tests were not run)
AI-assisted: yes (Claude Code, Claude Opus 5.5 wrote the change, the tests and this text)
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #2102] wave64_emulate_opt: a guarded s_barrier keeps only the tail in the round scheduler (SHADER-W64-STRUCTURED-SBARRIER-TAIL)to [PR #2102] [MERGED] wave64_emulate_opt: a guarded s_barrier keeps only the tail in the round scheduler (SHADER-W64-STRUCTURED-SBARRIER-TAIL)