Repository navigation
Recompiler: a lane loop form for small split wave64 compute programs - #3561
Royalflamejlh wants to merge 2 commits into
Conversation
|
Review (head 1216e70, diff read, not a merge-check: the
Fine: the AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
No open PR adds a lane-loop form. #3562 (same author) attacks the same problem, the split wave64 exchange on 32-lane GPUs, by folding two console lanes into one host lane. This PR instead runs a whole console wave per thread for small programs (at most 512 code dwords by default). These are different approaches. If both merge, the lane loop runs first in AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
1216e70 to
659efb7
Compare
|
Edited: Thanks for the review. The lane loop is opt-in now (head On the other points: a lane-loop program gets no dispatch chain, as you say (one thread a wave has nothing to cut); and it does take single-wave programs with LDS when the switch is on. If both this and #3562 merge, the order between them needs one decision point; I would put the choice in
AI use: Claude Code with Claude Fable 5.2 made the change, ran the tests and wrote this. |
One thread runs a whole console wave: a group of N threads is declared as ceil(N / 64) threads, each VGPR is 64 dwords local to the thread, and a vector instruction is a loop over the lanes around its ordinary lowering (Lw::inst_guarded) with the lane's EXEC bit as the guard. Masks are gathered bit by bit and lane reads read the register's array, so nothing waits for another hardware wave. The SSA sees each loop body once: scalars read there are their values before the loop, and scalars written are taken from the last lane, where masks and lane reads are whole. Refused (the caller keeps the split form): s_barrier in a group of several waves, v_movrel, scratch memory, image writes, a lane read of a computed value. XCL_WAVE64_LANE_LOOP tags the translated cache. Not run on a GPU: the test bench has none. The expected values of the three GPU tests were checked by interpreting the DXIL the form emits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rograms the lane loop Off unless asked for: with =1 a split program of at most 512 code dwords (lane_loop::MAX_WORDS) takes the lane loop where the form supports it, with =all every program it supports. The 512 is a first guess; GPU time against the split form is not measured. The switch is part of the translated cache's identity. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
659efb7 to
c15bcb1
Compare
|
A correction to my comment above: head AI use: Claude Code (Claude Opus 5.5). |
|
Follow-up review (head c15bcb1, since 1216e70, diff read, not a merge-check; checks red):
New: none. Fine: the AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
A third form for wave64 compute programs on a GPU with 32-lane waves only: one host thread runs a whole console wave, all 64 lanes, in a loop. Nothing is exchanged and nothing waits, so it cannot spin. It is meant as the exact fallback for small programs that the split form runs badly: on Linux (RTX 4060 Ti) a split program of 64 threads a group stayed 16 s in one dispatch at the title's world start and the run ended in a GPU hang; #3114 measures the same exchange at 2.6x a program's GPU time.
The form is opt-in (
XCL_WAVE64_LANE_LOOP=1): without the switch nothing changes. Tests on other cards (Windows, AMD, other NVIDIA) are wanted. It has not run in a title from this branch.What is in it
crates/xcl/src/gpu/dxil/lane_loop.rs(new, about 430 lines of code and 200 of tests): the form. A vector instruction is a 64-pass loop around the existing per-lane lowering with the lane's EXEC bit as the guard; each VGPR is a 64-dword array; a mask is built lane by lane; lane reads (v_readlane,v_readfirstlane, DPP, swizzle, permlane,ds_bpermute) read the array. numthreads becomes[ceil(N/64), 1, 1]: thread x is console wave x.s_barrierin a group of more than one console wave,v_movrel*, scratch memory, image stores and atomics, a lane read of a computed value, and any instruction that touches per-lane state it does not track.gpu/recomp/pso.rs(direct_compute): one call,lane_loop::choose, before the split translation.lanes.rs: two early returns (ballot,rla).kernel.rs: the cache tag.XCL_WAVE64_LANE_LOOP=1split programs of at most 512 code dwords (lane_loop::MAX_WORDS) take it, with=allevery program the form supports. The 512 is a first guess, and GPU time against the split form is not measured, which is why it is opt-in. The switch is part of the translated cache's identity.docs/wave64-on-wave32.md: a section on the form.673 added lines, 635 of them the new file with its tests; the form is not useful in smaller parts.
Tested
x86_64-pc-windows-gnu, release. Headc15bcb172. (Edited: the earlier head659efb76did not carry the opt-in its commit describes: the edits were left uncommitted, so659efb76ran the form by default on programs of at most 512 code dwords.c15bcb172has them, andXCL_WAVE64_LANE_LOOPis a warm pipeline library setting; the lane-loop andshaders::tests there, under Wine on the CPU: 103 passed, 0 failed.)cargo test -p xcl --release --lib -- gpu::dxil --test-threads=4: 311 passed, 1 failed, 3 ignored. SKIPPED:dispatch_chain_native_wave64_builds_whole(no wave64). The failure isround_tests::directed_reference_basics("Invalid bitcode signature"), which fails the same way here on a tree without this change; not rerun onmainalone.gpu_lane_loop_gives_the_console_waves_values(groups of 48, 64, 96, 256 and 8x8x4 threads; ballot, readlane, readfirstlane, mbcnt, a saveexec loop, LDS write then read; against the console's values and the split form's),gpu_lane_loop_reads_other_lanes_before_any_is_written,gpu_lane_loop_leaves_out_the_lanes_past_a_thread_limit.Regression run
xcl-smokeblocks are still owed.Not tested
AI use