Repository navigation
rdna2spirv: --mesh-serial-waves, an emulated mesh program's waves one after the other (SHADER-W64-MESH-SERIAL-WAVES) - #2435
Conversation
… other in 64 invocations (work in progress) Under --wave64-emulate a mesh program of more than 64 threads (a multiple of 64, no LDS instruction, not --mesh-compute) declares 64 invocations and runs one pass per wave: the invocation's index is the built-in plus 64 x pass, every initialised Function variable is set again per pass, the exports of a pass are copied to per-pass twins, and the epilogue sets the counts once and writes each pass's outputs. Each pass is one wave, so the plan is the single-wave one and the exchange buffer is one wave's. Off by default; with the flag off the output is unchanged. Work in progress for SHADER-W64-MESH-SERIAL-WAVES: no test or docs row yet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ory writes in a serial program (work in progress) ms_w64x_wave_votes: two waves take different branches, each with its own ballot count (and a v_readfirstlane in the second), and the triangle's vertices come from threads 0 and 1 of the first wave and thread 64 of the second, so ms_tri's picture needs both waves to have run their own branch with their own votes. It passes in the side-by-side form and with --mesh-serial-waves on an RTX 4080 (NVIDIA 621.24). A program with a store or an atomic to memory keeps the side-by-side form, as one with LDS does: its waves could pass each other something. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tests/test_mesh_serial_waves.py: the module shape of a program that qualifies (64 invocations, the pass loop, the index from the built-in, the exchange's own place, per-pass copies of the exports, one OpSetMeshOutputsEXT), that every initialised Function variable is set again per pass, and that ms_wave_info_s3 (LDS), a 32-thread program, native wave64 and --mesh-compute are unchanged by the flag. LEONIDA_MESH_SERIAL_WAVES=1 is read by scripts/run_gpu_tests.py, like the other translation switches, and no longer by rdna2spirv.py itself. docs/design.md and docs/testing.md say what the flag does and how it is tested; conftest gives ms_w64x_wave_votes its 128-vertex PSV0. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Added coverage, not mine: @tiguan26 ran this branch (fbceecf) on llvmpipe under Wine (Mesa, 8-wide subgroups, emulated path) and reports the 7 mesh GPU fixtures pass with |
|
I tested the negative control requested in the PR description at I kept the fixture unchanged and varied only the addition that combines the two 32-bit population counts for each
Each error picked out a different wave. I checked the full image independently: for normalized pixel-center height Taken early exit on All six 64×64 RTX 4090 draws matched their expected RGBA at every pixel. Ending wave 0 yielded blue Partial final wave on In each fixture, threads 0 and 1 exported two triangle vertices. The last thread in the workgroup exported the third vertex with blue 0.5. This made the pixel result depend on the last active lane of the final wave. Across all eight 64×64 draws, every pixel matched the expected RGBA |
tiguan26
left a comment
There was a problem hiding this comment.
Approving. Checked on fbceecf, which fast-forwards onto main (d1dff79).
Translator suite: same as main (only the known test_fspx_dot4_op_sel_disasm and test_int32_to_f64 failures). tests/test_mesh_serial_waves.py plus tests/test_translate.py: 740 passed, the one failure is main's ps_sdwa_f16_const.asm. GPU fixtures on llvmpipe under Wine with LEONIDA_W64_EMULATE=1: all 7 ms_ fixtures pass with and without LEONIDA_MESH_SERIAL_WAVES=1, and the switch really changes the module (LocalSize 128 vs 64).
Read the diff. Things I checked rather than took on trust: %ms_counts is a Workgroup variable, so the allocation count survives the per-pass re-initialisation even when only wave 0 sends GS_ALLOC_REQ (your fixture covers that case); %done and the other initialised Function variables are stored again at the top of each pass; the exchange's %x_buf index comes from the real index. I also tried a variant of ms_w64x_wave_votes with an s_endpgm reachable mid-program (a branch on wave id 7, so never taken): it still qualifies, passes spirv-val, and main keeps one OpReturn after the pass loop and the output writes, so an early-ending wave cannot skip later passes. If you want, that variant would make a cheap extra case in the unit tests, but it is not a blocker.
One small note, not a blocker: the qualifying check matches store and atomic as substrings of the opcode, which is conservative (it also catches s_store/s_buffer_store), so it errs on the side of keeping the side-by-side form. Fine as it is.
|
Thank you both. @ecox982745: that is the negative control I listed as missing, so it comes off the "not checked" list: with the fixture unchanged, a wrong count in either wave fails the runner's check in both forms, and each error shows in a different wave. @tiguan26: agreed on both notes. The substring match on Still not checked: AMD and Intel hardware, and whether the in-game picture is correct. |
A variant of ms_w64x_wave_votes with an s_endpgm behind a branch in the middle of the program: the module still qualifies, validates, and main keeps one return, after the loop over the passes and the output writes. Suggested in review by tiguan26. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Second game run with the mesh programs in the serial form (same RTX 4080, NVIDIA 621.24, Windows 11; the unit case suggested above is pushed as cd25a5c, 20 passed): the 3D world ran to the run's time cap without a device loss or a fault. The GPU profile agrees with the first run: 32,768 profiled mesh draws at 0.074 ms each, and 0.75 frames/s on average between 330 s and 480 s (0.45 before, side by side). In the profiled windows compute is now most of the GPU time (about 31 s of 48 s, against 2.4 s for mesh draws). One thing I have not explained: frames stopped being presented at about 726 s while submissions went on at the same rate until the cap; that is when the run's scripted pad presses end, and I have not checked whether the two are related or whether it also happens side by side. Picture correctness is still not checked. |
|
CI note: |
|
CI on cd25a5c has finished. Passed:
None of these is in a file this pull request changes, and the pull request has no runtime (C++) change. I have not checked whether each of them also fails on main's own latest run, so I am only saying what the logs show, not that main is red. If a maintainer wants the branch re-run after those are fixed, an empty merge of main will do it. |
|
Added coverage, not mine: @HasiKe ran this branch (cd25a5c) on an RTX 2070 SUPER (NVIDIA 616.56, Windows 11), the card on which the world lost the device at mesh draws: #1608 (comment). Their report: the whole main corpus (26,503 programs) translates with |
|
Open problem, please do not merge yet. @HasiKe's second series on the RTX 2070 SUPER (NVIDIA 616.56) with this branch: #1608 (comment). Across their six boots with the serial form: no mesh draw at a loss site and one device loss, but three stalls in which GPU work never completes and the device is not reset (at 209 s, 407 s and 419 s), plus one CPU fault at 90 s. Their stock shader set had no failure before the world in 11 boots on that card. Whatever the cause, 3 stalls in 6 against 0 in 11 is a signal against this change on that card, and it outweighs my four clean runs on the RTX 4080. What I have checked so far is only by reading the emitted module of |
…nt length ms_w64x_wave_loops: each wave loops while a wave-wide count is not 0, 5 iterations in wave 0 and 9 in wave 1, so under --wave64-emulate the waves reach different numbers of workgroup barriers. Written after stalls were reported with the serial form on an RTX 2070 SUPER (issue 1608). On an RTX 4080 (NVIDIA 621.24) it draws 4096/4096 pixels exact side by side and in series; that does not explain the stalls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The loop fixture is pushed as dbdef2e: On the RTX 4080 (NVIDIA 621.24, Windows 11) it terminates and draws 4096/4096 pixels exact in both forms; the other seven mesh fixtures still pass in both forms (8/8 and 8/8). This does not explain the stalls @HasiKe reported on the RTX 2070 SUPER, and it does not clear the change: it only shows that this shape (loops of different length per pass, barriers in the loop) is not by itself the fault on this card and driver. Not checked: the same fixture on their card and driver (616.56), which is the test that would count; and whether their stalls have the GPU busy or idle. The "do not merge yet" above stands. |
|
For the record beside the open problem above, a third card, not mine: @MoonEyes on an RTX 4060 8 GB (NVIDIA 610.88, Windows 11, GPU timeout at the Windows default of 2 s): #1608 (comment). Before: 9 of 13 runs lost the device, 7 of those with one mesh draw started and not finished. With the mesh programs retranslated from this branch (cd25a5c; 9,235 of 9,282 change form, So the cards stand like this, serial form: RTX 4080 four runs of 630 to 872 s without loss or stall; RTX 4060 one run without loss; RTX 2070 SUPER six boots with no mesh draw at a loss site but three stalls. The stalls are unexplained and the "do not merge yet" stands. |
|
Update on the open problem (the stalls on the RTX 2070 SUPER). Two measurements since my "do not merge yet":
What this settles: the hypothesis that the serial form hangs a workgroup is not supported; the stalls are not GPU work. What it does not settle: on HasiKe's card the stock set had no failure before the world in 11 boots on So I withdraw "do not merge yet" as a statement that this change is known to be wrong, and leave the above as the known risk for whoever reviews it. The switch is off by default either way. |
|
On fixed-wave64 gfx906 (RADV 26.0.8) at For both hand-written fixtures, This confirms the non-mesh path is unchanged; it does not test serial-path performance, hangs, or the outstanding merge concern. AI-assisted. |
|
Correction to the evidence listed above: the RTX 4060 entry does not hold. @MoonEyes has corrected their report (#1608 (comment)): in the run I cited as "reached its 910 s limit with no device loss", the game stopped presenting before the foliage mesh pipeline was built, so that pipeline was never drawn while frames were shown; four more runs with the same shaders stopped presenting at 299 to 380 s. Their runs without this change stop presenting at the same point and then lose the device. Their reading: the common event is the game ceasing to present on that 8 GB card, possibly from memory; whether this change removes the long mesh draws there is still open. So the cards now stand: RTX 4080, measured mesh draw time 1.04 ms to 0.074 ms and five runs without loss; RTX 2070 SUPER, no mesh draw at a loss site in nine boots, with the other failures described above; RTX 4090, synthetic fixtures only; RTX 4060, no evidence either way. Please disregard my earlier line that counted the RTX 4060 as a clean run. |
|
Reviewed the translation work at dbdef2e (pure Python on Windows, no llvm-mc/spirv-as on PATH, so the repo's own new tests skip locally; CI already shows them green). Verified locally:
Nothing here speaks to the open problem above — the RTX 2070 SUPER stalls are a runtime-side investigation still in flight, and my findings say nothing about it. |
docs/design.md: keep the new row and take main's text of the row below it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Merged main (3d6050b) into the branch as ad1789d to clear a conflict in CI on ad1789d: |
|
In-game A/B on an 8 GB laptop (profile M) for this PR. Both arms use the same executable, recipe, caches and input script; only the mesh programs differ, retranslated with this PR's Not fixed by this PR, in either arm: the display drops to ~0.2 frames/s right after world entry. Without the PR the GPU sits at 100 % during that stop; with it, the long submissions are gone and the stop stays, so the stop has another cause. Another 8 GB machine (RTX 4060, 610.88) with this PR sees the same stop with an idle GPU. n=1 per arm. |
|
RTX 2070 SUPER (8 GB), NVIDIA 616.56, TdrDelay 30 s, n=3 each, same exe, Enter at 55 s: stock shaders ran 1 of 3 to the 600 s limit; this PR's retranslation 0 of 3. One lost the device at ~540 s, two stopped presenting at ~290/320 s. The stop looks like the 8 GB one on the 4060/4070 Laptop (CPU submit cost, GPU mostly idle), not something this PR causes or fixes. Details and memory numbers: #1608 (comment). AI-assisted (Claude Code, Claude Opus 5.5). |
|
Addendum to the RUN above (7223228320), for the merge test: this PR's own tests at the current head ad1789d pass locally on Windows 11 ( |
tiguan26
left a comment
There was a problem hiding this comment.
Approving again at the current head, ad1789d, merged onto current main (43a9d56) with no conflicts. Thanks for adding the early-ending wave test.
tests/test_mesh_serial_waves.py: 23 passed, including cd25a5c95's wave that ends early. GPU fixtures on llvmpipe under Wine (8-wide subgroups, so the emulated path) with LEONIDA_W64_EMULATE=1: all 8 ms_ fixtures pass side by side, and with LEONIDA_MESH_SERIAL_WAVES=1 the three ms_w64x_ ones (ballot, the new wave_loops, wave_votes) pass at 4096/4096 exact. The new loops fixture is a good addition: two waves running loops of different length is the case where a mistake in the per-pass re-initialisation would show.
I'm only approving the code and the tests here. The merge decision belongs with the open question about the RTX 2070 SUPER stalls you listed.
|
Code read of
One scope note, not a finding: the switch is off with AI-assisted (Claude Code). |
|
@qhukz13 thanks for the read; both points match how I understand the pass loop. On |
Claimed in the coordination issue as: SHADER-W64-MESH-SERIAL-WAVES (#1608 (comment))
What and why
Under
--wave64-emulatea mesh program of 128 threads is two waves of 64 lanes run side by side, and the planner gives it mini-schedulers: each exchange between lanes becomes rounds over the whole workgroup. On an RTX 4080 that form measured 11 to 15 times the GPU time of the same programs' native form, and mesh draws were about 60 % of a frame in the 3D world (measurements in #1608).--mesh-serial-waves(off by default, no environment variable) changes the shape for a mesh program thatds_instruction, no store and no atomic instruction,--mesh-compute.Such a program declares LocalSize 64 and runs its body once per wave: pass
wseeslocal_index = real index + 64*w, every initialised function variable is stored again at the start of a pass, and the values the epilogue needs are copied to a per-pass twin at the end of the pass. The epilogue keeps one barrier, one count and oneOpSetMeshOutputsEXT, then writes each pass's vertices and primitives. Each pass is a single wave, so the planner gives it the existinginline_allplan. Nothing in the planner changes.A program outside those conditions, and every program when the switch is off, is translated as before. The index records
mesh_serial_waves(the number of passes);local_sizestays the program's own.New fixture
ms_w64x_wave_votes: the two waves take different branches and vote differently (ballot count 8 in wave 0, 3 plusv_readfirstlanein wave 1), and the triangle's vertices come from threads 0, 1 and 64, so a pass that saw the wrong wave's lanes or the wrong index draws something else.Tested
All on Windows 11, RTX 4080, NVIDIA 621.24, branch on main d1dff79.
scripts/run_gpu_tests.py: the 7 mesh fixtures pass in the side-by-side form and withLEONIDA_MESH_SERIAL_WAVES=1(which adds the switch).pytest tests/test_mesh_serial_waves.py: 19 passed.pytest tests/test_translate.py: 722 passed.pytest testswithtests/test_run_game_wine.py(importsfcntl, not on Windows) andtests/test_run_semantic_tests.py(its tests send an interrupt that ends the whole run here) left out: 10,069 passed, 288 skipped, 7 failed. The 7 are intest_bink_names,test_opus_tags,test_world_names(unreadable-directory cases),test_translate_pipeline_compute(Windows job limits) andtest_run_wine_tests(two--jobscases). Run alone on main d1dff79 on this machine the same 7 fail; on this branch 5 of them failed and the two--jobscases passed in that rerun.Not checked: whether the in-game picture is correct (frames on this machine alternate with white-outs in both forms); AMD, Intel, llvmpipe; a second game run; a negative control that shows the new fixture failing on a deliberately wrong translation; thread counts that are not a multiple of 64 (they keep the old form). Thanks to @HasiKe and @tiguan26 for offering runs on their setups.
GPUs tested: NVIDIA RTX 4080, driver 621.24, Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code