Repository navigation
Conversation
A game title on an RTX 3060 Ti: a wave64 compute program split in halves
took 50.4 ms for ONE 1x1x1 group, 2 calls a frame, the same every call.
A fixed latency per group, not work that scales with groups.
recomp::dispatch_loop_budget shares 2^28 loop passes among a dispatch's
threads (a throughput model, calibrated on a 262 144-thread dispatch). A
dispatch of one group gets clamp(2^28 / threads, 1024, 65536) = 65 536
passes a loop entry, the most there is. Its groups run side by side, so a
loop that never ends costs passes x one pass's latency whatever the thread
count: 65 536 passes at ~0.77 us (a split-form pass with a few exchanges)
is 50 ms. Both translators take the cap from IO_LOOP_BUDGET, written here.
XCL_LOOP_PASSES_MAX=<n> (default 4096, four times DISPATCH_LOOP_PASSES_MIN,
which the largest dispatches already get; 0 = the share alone, as before)
writes min(share, n x threads) so each lane's loop entry gets at most n
passes. Large dispatches keep their smaller share (80x45 groups of 64:
1165 an entry, unchanged). Indirect dispatches (IO_LOOP_BUDGET 0) keep
65 536. No translated code changes: the shader cache stays warm. The
thread product and n x threads saturate, so extreme values fall back to
the dispatch's share instead of overflowing.
Log: one line naming the switch, and the first 64 programs whose loops
get fewer passes ("XCL_LOOP_PASSES_MAX: cs ... a loop entry gets 4096
passes, not 65536").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review (head a9670ad, diff read, not a merge-check; checks red):
Fine: indirect dispatches (no group counts) and AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: AI-written and posted by Foniass without a human check of each point. |
|
On the open question in the description (a bounded wait or real work): on our RTX 5070 Ti the 1x1x1 split program is The 0 comes from the title's GPU heaps being outside the coherent window: with the Series S window at 512 MB, its three heaps (1162 + 1277 + 258 MB) do not fit, become plain memory, and translated shaders read zeros from them (throny's follow-up on #3568). With So the cap here shortens that case, and the program needs only a few passes once its data is reachable. With real data its block walk is a data-dependent loop, so it may be worth checking that 4096 passes still cover it.
|
bmjask
left a comment
There was a problem hiding this comment.
Review of a9670ad4: 1 finding(s) (1 high), most severe first.
- High
crates/xcl/src/hle/d3d12x/bind.rs:5093: The new default of 4096 silently cuts short real loops in every small direct compute dispatch, which used to get up to 65 536 passes per loop entry, while the same program keeps 65 536 when dispatched indirectly. (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
|
|
||
| /// Default of `XCL_LOOP_PASSES_MAX`: four times `recomp::DISPATCH_LOOP_PASSES_MIN`, the passes a | ||
| /// loop entry of the largest dispatches already gets. | ||
| const LOOP_PASSES_MAX_DEFAULT: u32 = 4096; |
There was a problem hiding this comment.
High: The new default of 4096 silently cuts short real loops in every small direct compute dispatch, which used to get up to 65 536 passes per loop entry, while the same program keeps 65 536 when dispatched indirectly. A 1x1x1 dispatch of a [64,1,1] or [1,1,1] program with a legitimate serial loop (a single-group scan or compaction over more than 4096 items, a long list walk, a spin on a flag another group sets) now leaves the loop after 4096 passes and runs to the end with partial results: wrong or corrupt output with only one info line per program. The PR says the 50 ms may instead come from the exchange waits #3652 bounds, so the cap may not even fix the motivating case. Keeping the default at the old budget and limiting the cap to the split-wave64 form (or to the identified program) would avoid changing correct programs.
Requested by Prime
A compute dispatch of only a few groups got the largest loop budget there is:
recomp::dispatch_loop_budgetshares 2^28 passes among a dispatch's threads, so one group of 64 threads got 65 536 passes a loop entry. That share model fits a dispatch that fills the GPU. A small dispatch runs its groups side by side, so a loop that never ends costs the full 65 536 passes of latency whatever the thread count. On an RTX 3060 Ti, in a game title, a split wave64 compute program took 50.4 ms for one 1x1x1 group, twice a frame, every frame. This change caps each lane's loop entry at 4096 passes (four timesDISPATCH_LOOP_PASSES_MIN) for compute dispatches with known group counts. Large dispatches already get less than that and are unchanged. No translated code changes, so the shader cache stays valid.Related: #3652 (open) lowers the split-wave64 exchange and barrier waits of the direct DXIL translator from 2^20 polls (an exit bit for a departed half, then 2^12 and 2^16 polls). That is the other bounded wait that can hold a small dispatch this long. The two do not touch the same code.
What is in it
crates/xcl/src/hle/d3d12x/bind.rs:loop_passes_max()readsXCL_LOOP_PASSES_MAX.capped_loop_budget()computes theIO_LOOP_BUDGETvalue, min(share, max x threads per group), with a saturating product so extreme values fall back to the share.loop_budget_for()applies it to a compute pipeline and logs the first 64 programs whose loops get fewer passes. The direct bind path writes it for compute dispatches with known group counts. Unit testsmall_dispatches_get_at_most_the_max_loop_passes.crates/xcl/src/hle/d3d12x/console_list.rs: translated console command lists take the same capped budget.Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnupasses. The test suite was not run on this exact branch.Regression run
Not tested
scripts/smoke.ps1on this branch; AMD.XCL_LOOP_PASSES_MAX=0restores the old budget if one shows up.Switches
XCL_LOOP_PASSES_MAX=<n>: default 4096, the most passes one loop entry of a lane gets in a compute dispatch with known group counts.=0keeps the dispatch's share alone, as before (up to 65 536). Indirect dispatches are not affected.AI use
🤖 Generated with Claude Code