Files
metal2vulkan/docs
Anees Iqbal 7b1725eb34 RUNTIME 2336: Lay no more of a predicated loop's copies than keep its waiting host steps within 16
On RADV, runtime_lane::predication::every_dispatch_form_runs_in_each_pass_past_the_copies ran
40-77 s alone and passed its 60 s wait for one command buffer under the suite. The cost is the
runtime's, not the test's breadth: each piece of work a host step records after the GPU's work
before it (an indirect dispatch of a kernel that observes its partition, an indirect command
buffer's execution inside a block) is its own batch, a round trip to the host (submit, wait for
the GPU, record, submit) in every run of a loop's laying, whether its copy's pass runs or skips.
A loop was laid down as 64 copies (16 inside another), bounded only by its commands
(LAID_BUDGET), so the test's inner DoWhile of 20 + 1 passes inside a DoWhile of two laid 1024
copies of its body: measured on lavapipe at the base (msi job m3-max-31287, a timing probe), its
command buffer's first run recorded 4097 host steps and made 8195 submissions (6145 and 12291 on
the device without device addresses, whose step form records six such pieces a pass), where its
21 passes ran 84 (126); the DoWhile of 100 passes 257 (385). That command buffer was 94% of the
test's 21,772 submissions, and each costs a GPU round trip, a few milliseconds on RADV.

copies_of now bounds a loop's copies by a second budget too: the work apart whose host step waits
for the GPU (Deferred::gpu_written) that its copies lay down, at most WAITED_BUDGET (16), counted
as LAID_BUDGET counts commands, from the first copy's, inner loops' copies included
(Predication::waited, Looping::waited_at). A loop of no such work keeps its 64 or 16 copies. A
loop that ends before its copies pays at most 16 round trips for the copies it skips, and one that
runs past them one more round trip, its check, per 16. The run-again path, unchanged, takes any
count of copies down to one.

Tests: every_dispatch_form_runs_in_each_pass and the failing test assert each loop's first run
records at most 16 host steps and the check (257 and 4097 at the base: the negative control);
the 100 passes no longer run again exactly once. docs/API.md and docs/RUNTIME-PORTING.md name the
new bound.

With abd0662e9f: the budget trades nothing for accuracy, so it has no FAST-PATHS row.
2026-11-14 21:39:26 -08:00
..