RUNTIME 2384: a fence update keeps its encoder group; the group orders after it by the narrowest barrier

A guest compute benchmark's encoders each update one fence and wait for one (reims, 780M,
c471372f87: fence updates = waits = encoders in every workload; 63 encoders a command buffer in one
workload), and an encoder that updated a fence ended its fold group, so every encoder began its own
VkCommandBuffer: 47.5 a submission, encoders_folded 54 of 117591. The driver's per-call work grows
with every VkCommandBuffer, and on the Iris Xe a VkCommandBuffer boundary costs 18.25 us of GPU time
against 0.64 us for the least barrier between dispatches (m3-max-33589).

A fence update no longer ends its group. A later member's commands order after the update by a
barrier recorded per command at the narrowest width that covers it: source, the updating encoders'
writes in the stages the update covers (SHADER_STORAGE_WRITE in shader stages, TRANSFER_WRITE in
transfer stages, attachment writes in a pass); destination, what the command can reach of memory
no use names, in its own stages (SHADER_STORAGE_READ | SHADER_SAMPLED_READ | SHADER_STORAGE_WRITE,
TRANSFER_READ | TRANSFER_WRITE), plus its untracked uses' own reads (indirect-argument or uniform
reads only where an untracked use reads them); tracked resources keep the tracker's rule. Between
two compute encoders that is the least barrier, SHADER_WRITE to SHADER_READ | SHADER_WRITE. The
barrier precedes the member's commands whether or not it waits, since a wait anywhere in an encoder
covers all its commands, which enter the shared VkCommandBuffer as they come; independent encoders
that update fences no one in the group waits on so run one after another (accepted: the guest's
encoders all wait). Across command buffers and queues nothing changes: Metal evaluates a fence at
submission, a wait only orders after updates committed before it ("commit the command buffers with
the producing passes before those with the consuming passes", MTLFence), a waiter on another VkQueue
waits for the updater's batch end, and a group never crosses a batch, so no cycle can form.
WorkCounts gains fold_fence_barriers and six folds_refused_* counts (the reason a join was refused:
kind, tail, batch, state, parts, ends; one relaxed add on a refused join, nothing on a join). Tests
that ended a group by a fence update now end it by a change of dispatch type or an event.

Verified: PHOENIX (RADV 780M, release, interleaved, 600 command buffers of 24 encoders, m3-max-33626):
fenced chain 47 -> 1 VkCommandBuffer a submission, mean call 56-79 -> 18-20 us, GPU start median
142-173 -> 101-105 us, GPU time median 146.7 -> 87.8 us (either wait order); independent fence-updating
encoders 74.7 -> 88.0 us GPU (serialised, as accepted); unfenced control unchanged (49.2 us).
fold_fence_barriers 13800 = 600 x 23; no folds_refused_* moved. Long-call bench, small listed:
539 -> 371 us mean call. Lane tip 8ae906a4fd: clippy plain, m2v_gpu, m2v_cpu_icd 0 (33633); lavapipe
runtime suite 2829 passed at 143a0013f8 and tracker unit tests 85 (33621; 8ae906a4fd deletes only the
dead Summary::has_updates); PHOENIX encoder_fold, render_fold, spares, fences 71 passed (33626).
Iris before/after: m3-max-33627, pending.

Public surface: WorkCounts (for the lanes) gains fold_fence_barriers and folds_refused_*, blessed in
api_signatures.tsv; a struct literal of WorkCounts must name them, Default and readers are unaffected.
This commit is contained in:
Anees Iqbal committed 2026-11-15 14:13:04 -08:00
1 parent 72f5acfec7
commit df0e7ec05e
15 files changed
+947 -112

No files matched your search

+8 -2
View File
@@ -5667,7 +5667,7 @@ each item named states the rule in full.
laid a loop or left work out fails the whole group.** The runtime records a compute or blit
encoder into the `VkCommandBuffer` of the compute, blit or render encoder before it where
nothing needs a boundary between them: a compute encoder's dispatch type that of the group's
compute encoders, the same batch (no event wait or signal between them), no fence update or work
compute encoders, the same batch (no event wait or signal between them), no work
left for later in the earlier one, nor a write into an ASTC texture or a write of a new texture
whole before any read, no command predication yet, the encoder trail off
(`DeviceOptions::encoder_trail`) and protection options 0 (`WorkCounts::encoders_folded` counts
@@ -5681,7 +5681,13 @@ each item named states the rule in full.
3090), a command that uses an image over bytes written before it in its `VkCommandBuffer` goes
on in a new one, a grouped encoder's in its own (`WorkCounts::command_buffers_split_at_aliases`);
a grouped render encoder's pass goes on in a new one before it where the pass or one of its
draws uses such an image. A failure that
draws uses such an image. An encoder that updates a fence stays in its group: every command of
a later member orders after the writes the update covers, whether or not its encoder waits for
the fence, which orders more than Metal does, through the narrowest barrier that covers a
fence: from those writes' stages to the command's own stages' storage, sampled and transfer
accesses and its bound resources' accesses (`WorkCounts::fold_fence_barriers`);
`WorkCounts::folds_refused_kind` and its kin count the encoders that joined no group by reason.
A failure that
fails some of
such a group's encoders and not the others (a `FailedEncoders::From(n)` whose `n` lies inside
it, a `FailedEncoders::Set` that names some of them, a fault or a recording failure at one)