Files
metal2vulkan/docs
Anees Iqbal 35ac917d6f RUNTIME 2466: GPU start: written before the batch's first work, and at the top of the pipe on every driver
What: a timed command buffer's first batch with first work (new resources'
first moves and zero fills, Managed copies in, staged copies) writes its start
timestamp in that work's command buffer, after an execution barrier from every
command before and before the work; and every start is written at the top of
the pipe, where batches ordered by their ends wrote it at the bottom.

Why: GPUStartTime must say when the GPU began the command buffer's work. In a
traced Geekbench-like compute pass on an RX 7900 XTX (RADV, Mesa 26.2.6), the
gfx ring's drm_sched jobs placed on the trace's clock (the job trace drifts
39.8 ppm against it, fitted per pass) showed command buffers whose start lay
in the last tenth of their own job: spans of 1 us on jobs of 4.5 to 36.5 ms.
Two causes. (a) The first work is inserted ahead of the start, and the start,
at the bottom of the pipe under by-ends ordering, waited for it: managed copies
in of the guest's did_modify_range ranges were 0.25 to 6.98 GB per workload.
(b) With no first work too (prefixed starts, 237 first-work batches of 7486),
about 1700 command buffers read their bottom-of-pipe start late; a Radeon 780M
showed the same. That GPU time counted as "submitted, GPU not started" in the
consumer's split: 4.06 s of its 5.90 s on the XTX.

Ordering (every driver path): the first work's start follows an execution
barrier ALL_COMMANDS -> ALL_COMMANDS, whose "first synchronization scope
includes all commands that occur earlier in submission order" and "second
synchronization scope includes all commands that occur later in submission
order" (vkCmdPipelineBarrier), the timestamp write among them. A start at the
top of the pipe where batches are ordered by their ends is held by the earlier
batch's end barrier, Barrier::to_all (src ALL_COMMANDS, dst ALL_COMMANDS and
HOST), by the same clause. Where batches are not ordered by their ends the
starts were at the top already and are unchanged; a start after a barrier
planned before the first encoder stays at the bottom, after that barrier.

Whether Metal's span holds a Managed copy in on a Mac with a discrete GPU is
not measured (the 5300M oracle can say).

Verified: compile and device runs pending (tests/start_stamp.rs).

Also folded: the test of a command buffer's GPU start against its own long work and its batch's
first work (e86e9d356e).
2026-11-16 10:17:56 -08:00
..