A batch held for its pipelines' making gives way to later commits of other queues
What: the scheduler's order across queues (scheduler/order.rs) no longer keeps the place of a batch held unsubmitted for a host step that has not taken its gate: its pipelines being made, or a step that reads nothing the GPU writes (`place_of`: `Place::GivesWay`). A later commit of another queue that conflicts with it on a resource goes first, and the held batch is submitted after it, so the tracker orders the two that way (submission order). The batches after it on its line give way with it. What still holds a head back behind such a batch is a fence the two share (`tracker::fenced`: one updates a fence the other waits for or updates, or a batch whose uses are not known yet against one that names a fence), so no batch is moved after a fence update it waits for. Unchanged: same-queue order, event and binary-semaphore waits (a batch waiting for the program still keeps no place), batches held for their submission checks or for a host step whose gate was taken (they keep their place: a later write going first would land after the step read), and the order among submitted batches. Why: on an Intel Iris Xe a guest process's cold compute pipeline took about 3 s to make; its command buffer kept its place, and the other processes' heads that conflicted with it (the window server's frames among them, over a surface they shared) waited behind it: the guest's display froze for 3.1 s. Metal's order across queues is the order the GPU takes the command buffers, not commit order: probes/cross_queue_surface_order.m's same-buffer control (one tracked buffer, written by queue A's long compute, then read or written by queue B's later commit) ran B before A once in three on a Radeon Pro 5300M and on a UHD 630 (macOS 26.7.1; m3-max-21850, m3-max-21851), and in commit order on an M3 Max (macOS 27.0.1). Where real Macs differ, the cheapest form inside them is taken; no switch, as matching the x86 Macs trades no accuracy. (The previous commit's message miscounted the no-copy buffer case: unordered in 10 of 12 runs, 6 of 6 on the M3, 3 of 3 on the 5300M, 1 of 3 on the 630.) Docs: order.rs's contract (**Tracked order across queues is the order the batches go**, **Held batches give way**, **No deadlock**), the scheduler's tracking and gate docs, WorkCounts::heads_held_for_earlier_commits, pending_dispatch.rs, docs/API.md's and the runtime README's pipeline-wait passages. Tests: tests::scheduler a_later_commit_goes_before_a_batch_held_for_its_making and a_batch_held_for_its_making_holds_back_a_commit_sharing_a_fence (the order's model; its existing a_later_commit_that_conflicts_waits_behind_a_batch_held_for_its_step is the kept-place control); tests::hold_sites a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first (was ..._waits_behind_it: the fill completes while the dispatch is held, and the dispatch's words land over it), a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it (the fence control), and the host-alias leg, which passes again.
This commit is contained in:
1 parent
aa2256b6e7
commit
b46459080d
10 files changed
+390
-144
No files matched your search
@@ -794,7 +794,10 @@ draw) whose pipeline the driver is still making `DevicePolicy::pipeline_commit_w
|
||||
default) after its command buffer's commit runs nothing too (`PipelineWaitPolicy::Bounded`, the
|
||||
default; a render or compute state's creation likewise waits `DevicePolicy::pipeline_creation_wait`,
|
||||
4.5 s by default, at most for the pipeline it hands to the runtime's pool), its command buffer
|
||||
running on, and the command buffers after it draw and dispatch with the pipeline once made. One
|
||||
running on, and the command buffers after it draw and dispatch with the pipeline once made.
|
||||
While it waits, another queue's command buffer committed after it goes first, even over a tracked
|
||||
resource the two share, and the waiting one runs after it, as an x86 Mac's GPU may take a later
|
||||
commit of another queue first; a fence the two share keeps commit order. One
|
||||
call so waits for the driver's makings at most: a state's creation, its creation wait; a `commit`,
|
||||
until its commit plus its commit wait (its commands share that one deadline, and the commit records
|
||||
there only what it can, an execution of render commands the CPU writes among them); neither waits
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
//! - **When it records.** `commit` records it where its pipelines are made by then; otherwise
|
||||
//! the scheduler's host step records it once they are made (`scheduler`), its batch held in
|
||||
//! its queue's order meanwhile, with no wait for the GPU: the batches committed after it on its
|
||||
//! queue complete after it, as Metal's do, and a batch of another queue waits for it only
|
||||
//! where the two share a resource one of them writes (`scheduler/order.rs`).
|
||||
//! queue complete after it, as Metal's do, and a batch of another queue committed after it
|
||||
//! waits for it only where the two share a fence: one that writes a resource it uses, or uses
|
||||
//! one it writes, goes first and it after, as an x86 Mac's GPU may take a later commit of
|
||||
//! another queue first (`scheduler/order.rs`, **Held batches give way**).
|
||||
//! - **A failed making.** A making that failed, or that its state's release stopped
|
||||
//! (`piece_holds.rs`), is made again by the recording, as a caller after a failed making does
|
||||
//! (`making.rs`), on the scheduler's thread; where that fails too, the command buffer completes
|
||||
|
||||
@@ -68,10 +68,13 @@
|
||||
//! semaphores is ready once every signal of it that a command buffer of this device committed
|
||||
//! before is submitted; a signal from the caller was submitted before the commit.
|
||||
//! - **Tracking** ([`Tracker`]). Each batch is planned as it is submitted, against the device's
|
||||
//! hazard state, in this order: the order Metal follows across queues. A batch held for its host
|
||||
//! step or its checks keeps its place among the tracked accesses: a later commit's batch on
|
||||
//! another queue that conflicts with it waits behind it, its own host step and checks too
|
||||
//! ([`Order::is_behind`]).
|
||||
//! hazard state, in this order: the order Metal follows across queues. A batch held for its
|
||||
//! checks, or for a host step whose gate was taken, keeps its place among the tracked accesses:
|
||||
//! a later commit's batch on another queue that conflicts with it waits behind it, its own host
|
||||
//! step and checks too ([`Order::is_behind`]). One held for its pipelines' making, or for a step
|
||||
//! that has not taken its gate, gives way but to a later commit that shares a fence with it:
|
||||
//! that commit goes first and the held batch after it, as an x86 Mac's GPU may take a later
|
||||
//! commit of another queue first (`order.rs`, **Held batches give way**).
|
||||
//! - **Many logical queues on few `VkQueue`s.** A logical queue keeps its `VkQueue` from a
|
||||
//! command buffer's making to its completion, and moves only where it holds no other
|
||||
//! uncompleted one (`queue_share.rs`); each `VkQueue` signals its own timeline semaphore with
|
||||
@@ -221,7 +224,7 @@ use binary::{BinarySignals, Needs};
|
||||
use inbox::Inbox;
|
||||
use left::{work_through, Kind, Left};
|
||||
use metal2vulkan::error::RuntimeDriverDefect;
|
||||
use order::{Behind, Order};
|
||||
use order::{Behind, Order, Place};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::sync::atomic::{fence, AtomicBool, AtomicU64, Ordering};
|
||||
use std::sync::{Arc, Condvar, Mutex, MutexGuard, OnceLock};
|
||||
@@ -307,7 +310,8 @@ pub(crate) enum HeldFor {
|
||||
/// An event value it waits for that neither a submitted signal nor the host reaches.
|
||||
EventValue,
|
||||
/// A batch of an earlier commit on another logical queue that keeps its place and whose
|
||||
/// footprint runs in commit order with its own ([`Order::is_behind`]).
|
||||
/// footprint runs in commit order with its own, or that gives way and shares a fence with it
|
||||
/// ([`Order::is_behind`]).
|
||||
EarlierCommit,
|
||||
/// Other queues' work enough is in flight on its `VkQueue`, which an unshared queue holds
|
||||
/// (`unshared_hold.rs`).
|
||||
@@ -2533,10 +2537,13 @@ fn gate_heads(state: &mut State, behind: &[u64], left: &mut Left<Work>, awaits:
|
||||
/// function wrote them unnamed, an earlier one of the step's own command buffer or one of an
|
||||
/// earlier command buffer of any queue.
|
||||
///
|
||||
/// Every batch that may write what the step reads was submitted by then: an earlier batch of its
|
||||
/// line went before it, a batch of an earlier commit on another line that may write those bytes
|
||||
/// holds it behind until submitted (`is_behind`, whose footprints hold the step's reads,
|
||||
/// `ExecutionRange::host_reads`), and a later commit's that may write them waits behind it.
|
||||
/// Every batch that may write what the step reads was submitted by then, or goes after the step's
|
||||
/// batch: an earlier batch of its line went before it, a batch of an earlier commit on another
|
||||
/// line that may write those bytes and keeps its place holds it behind until submitted
|
||||
/// (`is_behind`, whose footprints hold the step's reads, `ExecutionRange::host_reads`), and one
|
||||
/// that gives way goes after it; a later commit's that may write them waits behind it from the
|
||||
/// gate on, the step's batch keeping its place once its gate is taken (`order.rs`, **Held batches
|
||||
/// give way**), and before it went first, so the gate covers it.
|
||||
fn gate_of(
|
||||
buffer: &Hold<CommandBufferShared>,
|
||||
index: usize,
|
||||
@@ -2559,9 +2566,11 @@ fn gate_of(
|
||||
}
|
||||
|
||||
/// Whether the head of commit sequence number `sequence` waits behind a batch committed before it
|
||||
/// that keeps its place ([`Order::is_behind`]): one whose binary semaphores' signals are submitted
|
||||
/// and whose event values are reached, as is every batch before it on its line, and whose footprint
|
||||
/// and the head's run in commit order ([`tracker::ordered`]). `memo` holds what this pass found.
|
||||
/// ([`Order::is_behind`]) whose binary semaphores' signals are submitted and whose event values
|
||||
/// are reached, as are every batch's before it on its line: one that keeps its place, whose
|
||||
/// footprint and the head's run in commit order ([`tracker::ordered`]), or one that gives way
|
||||
/// ([`place_of`]), whose footprint and the head's share a fence ([`tracker::fenced`]). `memo`
|
||||
/// holds what this pass found.
|
||||
fn is_behind(
|
||||
order: &Order<Held>,
|
||||
binary: &BinarySignals<vk::Semaphore>,
|
||||
@@ -2572,16 +2581,33 @@ fn is_behind(
|
||||
sequence,
|
||||
memo,
|
||||
(
|
||||
&mut |held: &Held| binary.ready(&held.binary_needs) && events_reachable(held),
|
||||
&mut |held: &Held| place_of(held, binary),
|
||||
&mut |held: &Held| held.buffer.footprint(held.index),
|
||||
&|earlier: &Option<Arc<Footprint<ResourceKey>>>,
|
||||
later: &Option<Arc<Footprint<ResourceKey>>>| {
|
||||
tracker::ordered(earlier.as_deref(), later.as_deref())
|
||||
later: &Option<Arc<Footprint<ResourceKey>>>,
|
||||
gives_way| match gives_way {
|
||||
false => tracker::ordered(earlier.as_deref(), later.as_deref()),
|
||||
true => tracker::fenced(earlier.as_deref(), later.as_deref()),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/// Where `held` stands in the order across queues (`order.rs`'s **Held batches give way**): it
|
||||
/// waits for the program while a binary semaphore's signal it needs is not submitted or an event
|
||||
/// value it waits for is not reached; it gives way while it holds segments whose host step has
|
||||
/// not taken its gate (its pipelines being made, or a step that reads nothing the GPU writes),
|
||||
/// so the step reads what a later commit that goes first writes; else it keeps its place.
|
||||
fn place_of(held: &Held, binary: &BinarySignals<vk::Semaphore>) -> Place {
|
||||
if !binary.ready(&held.binary_needs) || !events_reachable(held) {
|
||||
return Place::Stops;
|
||||
}
|
||||
if held.segments && held.gate.is_none() && held.buffer.needs_host_step(held.index) {
|
||||
return Place::GivesWay;
|
||||
}
|
||||
Place::Keeps
|
||||
}
|
||||
|
||||
/// Whether every event value `held` waits for is reached by a submitted signal or the host:
|
||||
/// [`event_waits`] would answer, for a batch the order does not take yet.
|
||||
fn events_reachable(held: &Held) -> bool {
|
||||
|
||||
@@ -8,21 +8,39 @@
|
||||
//! ready holds back its own line, and the heads of other lines committed after it that it
|
||||
//! conflicts with:
|
||||
//!
|
||||
//! - **Tracked order across queues is commit order.** Metal tracks a resource across queues in
|
||||
//! the order it schedules the command buffers, which is their commit order unless one waits
|
||||
//! for an event (its tracking across queues). The runtime's tracker plans each batch as it is
|
||||
//! submitted, so a batch held for a reason of the runtime's own (its host step, its submission
|
||||
//! checks) must not let a later commit's batch that conflicts with it (a tracked resource's range
|
||||
//! that one of them writes, or a fence) go before it: such a head is [`behind`](Order::is_behind)
|
||||
//! it, and waits.
|
||||
//! - **Tracked order across queues is the order the batches go.** Metal tracks a resource across
|
||||
//! queues in the order the GPU takes the command buffers, which need not be their commit order:
|
||||
//! a command buffer committed after another on another queue, writing or reading one tracked
|
||||
//! buffer the first writes, ran before it now and then on a Radeon Pro 5300M and a UHD 630
|
||||
//! (macOS 26.7.1), and in commit order on an M3 Max (macOS 27.0.1)
|
||||
//! (`metal2vulkan-conformance`'s `probes/cross_queue_surface_order.m`, its `nocopy-one`
|
||||
//! control). The runtime's tracker plans each batch as it is submitted, so the batches it
|
||||
//! submits run in submission order wherever they conflict, and the order picks which goes
|
||||
//! first: a batch held for a reason of the runtime's own that keeps its place (its submission
|
||||
//! checks; below) must not let a later commit's batch that conflicts with it (a tracked
|
||||
//! resource's range that one of them writes, or a fence) go before it: such a head is
|
||||
//! [`behind`](Order::is_behind) it, and waits.
|
||||
//! - **Held batches give way.** A batch held unsubmitted for its host step before the step read
|
||||
//! anything the GPU writes ([`Place::GivesWay`]: its pipelines being made, or a step that reads
|
||||
//! nothing of the GPU's) does not keep its place: a later commit of another queue that
|
||||
//! conflicts with it goes, as an x86 Mac's GPU may take it first, and the held batch is
|
||||
//! submitted after it, so the tracker orders the two that way; the batches after it on its line
|
||||
//! give way with it. A head still waits behind such a batch where the two share a fence (one
|
||||
//! updates a fence the other waits for or updates, or a batch whose uses are not known yet and
|
||||
//! one that names a fence): a batch is never moved after a fence update it waits for. A step
|
||||
//! whose gate was taken keeps its place: what it reads stands from its gate on, and a later
|
||||
//! write going first would land after the step read. (A cold compute pipeline's making of 3 s
|
||||
//! on an Iris Xe held one guest process's command buffer, and with it every other process's
|
||||
//! frames over a surface they shared: the guest's display froze for 3.1 s.)
|
||||
//! - **Which batches keep their place.** Every batch of a line up to the first that waits for
|
||||
//! an event value not yet reached by a submitted signal or the host, or for a binary
|
||||
//! semaphore whose signal is not yet submitted. That one and those after it wait for the
|
||||
//! program's signal, as Metal schedules them after it, so a later commit may go first: Metal
|
||||
//! follows the event.
|
||||
//! - **No deadlock.** A head waits behind batches committed before it that keep their place
|
||||
//! only; the first of those waits for no batch but its line's earlier ones, or for the runtime
|
||||
//! (a host step's gate or pipelines, its checks), which never waits for a later commit.
|
||||
//! - **No deadlock.** A head waits behind batches committed before it that keep their place, or
|
||||
//! that give way but share a fence with it, only; the first of those waits for no batch but its
|
||||
//! line's earlier ones, or for the runtime (a host step's gate or pipelines, its checks), which
|
||||
//! never waits for a later commit.
|
||||
//! - **Heads put first.** The caller may put heads first ([`next`](Order::next)'s `first`): a
|
||||
//! ready one goes before the others, still behind any batch it conflicts with that keeps its
|
||||
//! place, as every head. The scheduler puts first an unshared queue's head on a `VkQueue` whose
|
||||
@@ -120,19 +138,20 @@ impl<B> Order<B> {
|
||||
}
|
||||
|
||||
/// Whether the line head of commit sequence number `sequence` waits behind a batch committed
|
||||
/// before it on another line: one that keeps its place there (`keeps` holds for it and for
|
||||
/// every batch before it on its line), whose footprint (`footprint`) and the head's `ordered`
|
||||
/// says run in commit order. `memo` keeps, for one pass over an unchanged order, each answer,
|
||||
/// each line's batches found to keep their place, and each footprint taken. False for a
|
||||
/// sequence number no head has.
|
||||
/// before it on another line: one that keeps its place there or gives way (`keeps` answers
|
||||
/// [`Place::Keeps`] or [`Place::GivesWay`] for it and for every batch before it on its line,
|
||||
/// one after a batch that gives way giving way too), whose footprint (`footprint`) and the
|
||||
/// head's `ordered` says run in commit order, given whether the earlier gives way. `memo`
|
||||
/// keeps, for one pass over an unchanged order, each answer, each line's batches found to keep
|
||||
/// their place, and each footprint taken. False for a sequence number no head has.
|
||||
pub(crate) fn is_behind<F>(
|
||||
&self,
|
||||
sequence: u64,
|
||||
memo: &mut Behind<F>,
|
||||
(keeps, footprint, ordered): (
|
||||
&mut impl FnMut(&B) -> bool,
|
||||
&mut impl FnMut(&B) -> Place,
|
||||
&mut impl FnMut(&B) -> F,
|
||||
&impl Fn(&F, &F) -> bool,
|
||||
&impl Fn(&F, &F, bool) -> bool,
|
||||
),
|
||||
) -> bool {
|
||||
if let Some(&answer) = memo.answers.get(&sequence) {
|
||||
@@ -149,9 +168,9 @@ impl<B> Order<B> {
|
||||
sequence: u64,
|
||||
memo: &mut Behind<F>,
|
||||
(keeps, footprint, ordered): (
|
||||
&mut impl FnMut(&B) -> bool,
|
||||
&mut impl FnMut(&B) -> Place,
|
||||
&mut impl FnMut(&B) -> F,
|
||||
&impl Fn(&F, &F) -> bool,
|
||||
&impl Fn(&F, &F, bool) -> bool,
|
||||
),
|
||||
) -> bool {
|
||||
if self.lines.len() < 2 {
|
||||
@@ -175,23 +194,34 @@ impl<B> Order<B> {
|
||||
if *first > sequence {
|
||||
break;
|
||||
}
|
||||
// Whether it and every batch before it on its line keep their place, each asked
|
||||
// once a pass.
|
||||
// Whether it and every batch before it on its line keep their place or give way,
|
||||
// each asked once a pass.
|
||||
let kept = &mut memo.kept[other];
|
||||
if index >= kept.scanned {
|
||||
if kept.stopped || !keeps(batch) {
|
||||
kept.stopped = true;
|
||||
if kept.stopped {
|
||||
break;
|
||||
}
|
||||
match keeps(batch) {
|
||||
Place::Stops => {
|
||||
kept.stopped = true;
|
||||
break;
|
||||
}
|
||||
Place::GivesWay => {
|
||||
kept.gives_way.get_or_insert(index);
|
||||
}
|
||||
Place::Keeps => {}
|
||||
}
|
||||
kept.scanned = index + 1;
|
||||
}
|
||||
let gives_way = kept.gives_way.is_some_and(|from| index >= from);
|
||||
memo.footprints
|
||||
.entry(*first)
|
||||
.or_insert_with(|| footprint(batch));
|
||||
memo.footprints
|
||||
.entry(sequence)
|
||||
.or_insert_with(|| footprint(head));
|
||||
if ordered(&memo.footprints[first], &memo.footprints[&sequence]) {
|
||||
let (earlier, later) = (&memo.footprints[first], &memo.footprints[&sequence]);
|
||||
if ordered(earlier, later, gives_way) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -383,10 +413,25 @@ impl<F> Default for Behind<F> {
|
||||
}
|
||||
}
|
||||
|
||||
/// How far one line's batches were found to keep their place: the first `scanned` do, and, where
|
||||
/// `stopped`, the next does not.
|
||||
/// How far one line's batches were found to keep their place: the first `scanned` do or give way,
|
||||
/// those from `gives_way` on giving way, and, where `stopped`, the next does neither.
|
||||
#[derive(Clone, Copy, Default)]
|
||||
struct Kept {
|
||||
scanned: usize,
|
||||
gives_way: Option<usize>,
|
||||
stopped: bool,
|
||||
}
|
||||
|
||||
/// Where a batch stands in the order across queues ([`Order::is_behind`], the module docs).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Place {
|
||||
/// It keeps its place: a later commit of another line that conflicts with it waits.
|
||||
Keeps,
|
||||
/// It is held unsubmitted for its host step before the step read anything the GPU writes:
|
||||
/// a later commit of another line goes ahead of it, but where the two share a fence, and so
|
||||
/// do the batches after it on its line (**Held batches give way**).
|
||||
GivesWay,
|
||||
/// It waits for the program (an event value or a binary semaphore's signal): it and the
|
||||
/// batches after it on its line keep no place.
|
||||
Stops,
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
use crate::pipeline::pool::held;
|
||||
use crate::{
|
||||
Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, ComputePipelineState, Device,
|
||||
DeviceKind, DeviceOptions, PipelineOptions, ResourceOptions, ShaderCacheOptions, Size,
|
||||
DeviceKind, DeviceOptions, Fence, PipelineOptions, ResourceOptions, ShaderCacheOptions, Size,
|
||||
};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -148,6 +148,28 @@ pub(super) fn dispatch(
|
||||
state: &ComputePipelineState,
|
||||
buffers: &Buffers,
|
||||
grid: Grid,
|
||||
) -> CommandBuffer {
|
||||
encoded(queue, state, buffers, grid, None)
|
||||
}
|
||||
|
||||
/// [`dispatch`], its encoder updating `fence` after the dispatch (`hold_sites.rs`).
|
||||
pub(super) fn dispatch_updating(
|
||||
queue: &CommandQueue,
|
||||
state: &ComputePipelineState,
|
||||
buffers: &Buffers,
|
||||
grid: Grid,
|
||||
fence: &Fence,
|
||||
) -> CommandBuffer {
|
||||
encoded(queue, state, buffers, grid, Some(fence))
|
||||
}
|
||||
|
||||
/// [`dispatch`], its encoder updating `fence` after the dispatch where one is given.
|
||||
fn encoded(
|
||||
queue: &CommandQueue,
|
||||
state: &ComputePipelineState,
|
||||
buffers: &Buffers,
|
||||
grid: Grid,
|
||||
fence: Option<&Fence>,
|
||||
) -> CommandBuffer {
|
||||
let command_buffer = queue.command_buffer().unwrap();
|
||||
let mut encoder = command_buffer.compute_command_encoder().unwrap();
|
||||
@@ -160,6 +182,9 @@ pub(super) fn dispatch(
|
||||
Grid::One(threads) => encoder.dispatch_threadgroups(Size::new(1, 1, 1), threads),
|
||||
}
|
||||
.unwrap();
|
||||
if let Some(fence) = fence {
|
||||
encoder.update_fence(fence).unwrap();
|
||||
}
|
||||
encoder.end_encoding().unwrap();
|
||||
command_buffer
|
||||
}
|
||||
|
||||
@@ -8,18 +8,17 @@
|
||||
//! reads them to find out where the time went.
|
||||
//!
|
||||
//! The hold that crosses queues is the one behind an earlier commit (`scheduler/order.rs`): Metal
|
||||
//! tracks a resource across queues in the order it schedules the command buffers, so a batch the
|
||||
//! runtime holds for a reason of its own must not let a later commit's conflicting batch go
|
||||
//! first. `a_head_that_shares_a_buffer_with_a_held_batch_waits_behind_it` holds one batch by its
|
||||
//! pipeline's making (the device's pool's test hold, so a making is as slow as the test makes
|
||||
//! it) and shows both sides of the question: a command buffer of another queue that shares
|
||||
//! nothing with it goes and is counted as waiting for nothing, and one that writes the buffer its
|
||||
//! dispatch writes waits behind it and is counted.
|
||||
//! `a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held` shows the
|
||||
//! line the hold stops at: two no-copy buffers over the same host bytes are two resources, which
|
||||
//! Metal orders across queues only as the program orders them (`host_aliases.rs`), so a command
|
||||
//! buffer of another queue that writes those bytes through the other buffer goes while the
|
||||
//! dispatch's making holds it.
|
||||
//! tracks a resource across queues in the order the GPU takes the command buffers, so a batch the
|
||||
//! runtime holds for its checks, or for a host step whose gate was taken, must not let a later
|
||||
//! commit's conflicting batch go first, and one held for its pipelines' making gives way
|
||||
//! (**Held batches give way**). Each test holds one batch by its pipeline's making (the device's
|
||||
//! pool's test hold, so a making is as slow as the test makes it):
|
||||
//! `a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first` and
|
||||
//! `a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held` show a
|
||||
//! command buffer of another queue that writes what the held dispatch writes going first,
|
||||
//! through the same buffer or through another over the same host pages, and the dispatch running
|
||||
//! after it; `a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it`
|
||||
//! shows the line that stops at: a fence the two share keeps commit order.
|
||||
//!
|
||||
//! Device tests: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`,
|
||||
//! `m2v_cpu_icd`), on the kind of device the cfg selects. The kernel is `scale_and_offset` of the
|
||||
@@ -27,7 +26,7 @@
|
||||
//! `dispatch_pending.rs` runs it.
|
||||
|
||||
use super::blit_holds::{device, exact_waits_device, Host, Scratch, BYTES, WAIT};
|
||||
use super::dispatch_pending::{dispatch, state, Buffers, Grid};
|
||||
use super::dispatch_pending::{dispatch, dispatch_updating, state, Buffers, Grid};
|
||||
use crate::pipeline::pool::held;
|
||||
use crate::{
|
||||
Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Device, EventRef, ResourceOptions,
|
||||
@@ -63,19 +62,21 @@ fn eventually(within: Duration, done: impl Fn() -> bool) -> bool {
|
||||
done()
|
||||
}
|
||||
|
||||
/// A dispatch whose pipeline's making the pool is held from finishing keeps its place in the
|
||||
/// scheduler's order: its host step has not run, and every wait of its own is satisfied. A
|
||||
/// command buffer committed after it **on another queue** that shares nothing with it goes, and
|
||||
/// nothing counts it as waiting; one that writes the buffer its dispatch writes waits behind it,
|
||||
/// counted, and so is the dispatch's own hold for its host step. Each batch a look found held is
|
||||
/// counted once as it goes, with the nanoseconds it waited.
|
||||
/// A dispatch whose pipeline's making the pool is held from finishing gives way in the
|
||||
/// scheduler's order (`scheduler/order.rs`, **Held batches give way**): a command buffer committed
|
||||
/// after it **on another queue** that writes the buffer its dispatch writes goes while the making
|
||||
/// holds it, as an x86 Mac's GPU may take a later commit of another queue first, and no look
|
||||
/// counts it as waiting behind an earlier commit; the dispatch's own hold for its host step is
|
||||
/// counted, once as it goes, with the nanoseconds it waited. Released, the dispatch runs after the
|
||||
/// fill: its words are over the fill's. (A cold compute pipeline's making of 3 s on an Iris Xe held
|
||||
/// a guest's compositor frames behind another process's command buffer in commit order.)
|
||||
#[test]
|
||||
fn a_head_that_shares_a_buffer_with_a_held_batch_waits_behind_it() {
|
||||
let scratch = Scratch::new("behind");
|
||||
let device = device(&scratch.0);
|
||||
fn a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first() {
|
||||
let scratch = Scratch::new("first");
|
||||
// Its recordings wait for the making until it is made: a bound passed would drop the dispatch.
|
||||
let device = exact_waits_device(&scratch.0);
|
||||
let state = state(&device);
|
||||
let buffers = Buffers::new(&device);
|
||||
let apart = device.new_buffer(64, ResourceOptions::shared()).unwrap();
|
||||
let (a, b) = (
|
||||
device.new_command_queue().unwrap(),
|
||||
device.new_command_queue().unwrap(),
|
||||
@@ -85,30 +86,16 @@ fn a_head_that_shares_a_buffer_with_a_held_batch_waits_behind_it() {
|
||||
let before = device.work_counts();
|
||||
pending.commit().unwrap();
|
||||
|
||||
let alone = fill(&b, &apart, None);
|
||||
alone.commit().unwrap();
|
||||
alone
|
||||
let sharing = fill(&b, buffers.output(), None);
|
||||
sharing.commit().unwrap();
|
||||
sharing
|
||||
.wait_until_completed_for(WAIT)
|
||||
.expect("a batch of another queue that shares nothing with the held one runs meanwhile");
|
||||
assert_eq!(alone.status(), CommandBufferStatus::Completed);
|
||||
.expect("a batch writing the buffer the dispatch held for its making writes waited for it");
|
||||
assert_eq!(sharing.status(), CommandBufferStatus::Completed);
|
||||
assert_eq!(
|
||||
device.work_counts().heads_held_for_earlier_commits,
|
||||
before.heads_held_for_earlier_commits,
|
||||
"a batch that shares nothing with the held one was counted as waiting behind it"
|
||||
);
|
||||
|
||||
let sharing = fill(&b, buffers.output(), None);
|
||||
sharing.commit().unwrap();
|
||||
assert!(
|
||||
sharing.wait_until_completed_for(WATCHED).is_err(),
|
||||
"a batch writing the buffer the held dispatch writes did not wait behind it"
|
||||
);
|
||||
assert!(
|
||||
eventually(WAIT, || {
|
||||
device.work_counts().heads_held_for_earlier_commits
|
||||
> before.heads_held_for_earlier_commits
|
||||
}),
|
||||
"the hold behind an earlier commit on another queue was not counted"
|
||||
"a batch that went before the held one was counted as waiting behind it"
|
||||
);
|
||||
assert!(
|
||||
device.work_counts().heads_held_for_host_steps > before.heads_held_for_host_steps,
|
||||
@@ -117,7 +104,73 @@ fn a_head_that_shares_a_buffer_with_a_held_batch_waits_behind_it() {
|
||||
assert_ne!(pending.status(), CommandBufferStatus::Completed);
|
||||
|
||||
drop(hold);
|
||||
for command_buffer in [&pending, &sharing] {
|
||||
pending.wait_until_completed_for(WAIT).unwrap();
|
||||
assert_eq!(
|
||||
pending.status(),
|
||||
CommandBufferStatus::Completed,
|
||||
"{:?} {:?}",
|
||||
pending.error(),
|
||||
pending.failed_pipeline()
|
||||
);
|
||||
assert!(
|
||||
buffers.written(THREADS),
|
||||
"the dispatch, after the fill, did not write what Metal's writes"
|
||||
);
|
||||
let after = device.work_counts();
|
||||
assert!(
|
||||
after.batches_held_past_a_look > before.batches_held_past_a_look,
|
||||
"the held dispatch was not counted as it went"
|
||||
);
|
||||
assert!(
|
||||
after.batch_hold_nanos > before.batch_hold_nanos,
|
||||
"the hold was counted as taking no time"
|
||||
);
|
||||
}
|
||||
|
||||
/// A dispatch whose pipeline's making the pool is held from finishing updates a fence, and a
|
||||
/// command buffer committed after it on another queue waits for that fence before a fill of a
|
||||
/// buffer of its own: the fence keeps commit order where the held batch gives way on resources
|
||||
/// (`scheduler/order.rs`, **Held batches give way**), so the fill waits behind the dispatch,
|
||||
/// counted, and both complete once the making ends.
|
||||
#[test]
|
||||
fn a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it() {
|
||||
let scratch = Scratch::new("fence");
|
||||
let device = exact_waits_device(&scratch.0);
|
||||
let state = state(&device);
|
||||
let buffers = Buffers::new(&device);
|
||||
let apart = device.new_buffer(64, ResourceOptions::shared()).unwrap();
|
||||
let fence = device.new_fence();
|
||||
let (a, b) = (
|
||||
device.new_command_queue().unwrap(),
|
||||
device.new_command_queue().unwrap(),
|
||||
);
|
||||
let hold = held::hold();
|
||||
let grid = Grid::One(Size::new(THREADS, 1, 1));
|
||||
let pending = dispatch_updating(&a, &state, &buffers, grid, &fence);
|
||||
let before = device.work_counts();
|
||||
pending.commit().unwrap();
|
||||
|
||||
let waiting = b.command_buffer().unwrap();
|
||||
let mut blit = waiting.blit_command_encoder().unwrap();
|
||||
blit.wait_for_fence(&fence).unwrap();
|
||||
blit.fill_buffer(&apart, 0..64, 7).unwrap();
|
||||
blit.end_encoding().unwrap();
|
||||
waiting.commit().unwrap();
|
||||
assert!(
|
||||
waiting.wait_until_completed_for(WATCHED).is_err(),
|
||||
"a batch waiting for a fence the held dispatch updates did not wait behind it"
|
||||
);
|
||||
assert!(
|
||||
eventually(WAIT, || {
|
||||
device.work_counts().heads_held_for_earlier_commits
|
||||
> before.heads_held_for_earlier_commits
|
||||
}),
|
||||
"the hold behind an earlier commit on another queue was not counted"
|
||||
);
|
||||
assert_ne!(pending.status(), CommandBufferStatus::Completed);
|
||||
|
||||
drop(hold);
|
||||
for command_buffer in [&pending, &waiting] {
|
||||
command_buffer.wait_until_completed_for(WAIT).unwrap();
|
||||
assert_eq!(
|
||||
command_buffer.status(),
|
||||
@@ -127,17 +180,7 @@ fn a_head_that_shares_a_buffer_with_a_held_batch_waits_behind_it() {
|
||||
command_buffer.failed_pipeline()
|
||||
);
|
||||
}
|
||||
let after = device.work_counts();
|
||||
assert!(
|
||||
after.batches_held_past_a_look >= before.batches_held_past_a_look + 2,
|
||||
"the two batches a look found held were not both counted as they went: {} to {}",
|
||||
before.batches_held_past_a_look,
|
||||
after.batches_held_past_a_look
|
||||
);
|
||||
assert!(
|
||||
after.batch_hold_nanos > before.batch_hold_nanos,
|
||||
"the holds were counted as taking no time"
|
||||
);
|
||||
assert!(buffers.written(THREADS), "the dispatch did not write");
|
||||
}
|
||||
|
||||
/// A `Shared` no-copy buffer of `device` over all of `host`'s pages.
|
||||
@@ -155,13 +198,12 @@ fn over(device: &Device, host: &Host) -> Buffer {
|
||||
/// A dispatch whose pipeline's making the pool is held from finishing writes host pages through
|
||||
/// one no-copy buffer, and a command buffer committed after it on another queue fills the same
|
||||
/// bytes through a second no-copy buffer over exactly those pages, which joins the first's memory
|
||||
/// (`host_aliases.rs`). The two are two resources: Metal orders two resources over one memory
|
||||
/// across queues only as the program orders them (an M4 under macOS 27.0.1, `host_aliases.rs`),
|
||||
/// so the fill goes while the dispatch's making holds it, and no look counts it as waiting behind
|
||||
/// an earlier commit. It had waited for the making (a guest's compositor frames behind another
|
||||
/// process's command buffer over a shared surface's pages, frozen for a cold compile's 3 s).
|
||||
/// Released, the dispatch runs after the fill, which went to the GPU first, so its words are what
|
||||
/// Metal's dispatch writes.
|
||||
/// (`host_aliases.rs`), so the two meet as one resource's uses do. The dispatch gives way
|
||||
/// (`scheduler/order.rs`, **Held batches give way**), so the fill goes while the dispatch's making
|
||||
/// holds it, and no look counts it as waiting behind an earlier commit. It had waited for the
|
||||
/// making (a guest's compositor frames behind another process's command buffer over a shared
|
||||
/// surface's pages, frozen for a cold compile's 3 s). Released, the dispatch runs after the fill,
|
||||
/// which went to the GPU first, so its words are what Metal's dispatch writes.
|
||||
#[test]
|
||||
fn a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held() {
|
||||
let host = Host::new();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//! committed in any order.
|
||||
|
||||
use crate::event_timeline::{EventTimeline, Signal, WaitFor};
|
||||
use crate::scheduler::order::{Behind, Order};
|
||||
use crate::scheduler::order::{Behind, Order, Place};
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
@@ -586,33 +586,73 @@ fn random_programs_complete_on_one_to_four_vk_queues() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A batch for the order across queues: held by the runtime (`step`: its host step or checks)
|
||||
/// or by a wait for an event the program has not reached (`event`), with the resources it reads
|
||||
/// and writes.
|
||||
/// A batch for the order across queues: held by the runtime (`step`: its checks, or a host step
|
||||
/// whose gate was taken; with `making`, its pipelines' making, before its step took a gate) or by
|
||||
/// a wait for an event the program has not reached (`event`), with the resources it reads and
|
||||
/// writes and the fences it names.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Work {
|
||||
name: char,
|
||||
step: bool,
|
||||
making: bool,
|
||||
event: bool,
|
||||
reads: &'static [u32],
|
||||
writes: &'static [u32],
|
||||
fences: &'static [u32],
|
||||
}
|
||||
|
||||
fn work(name: char, reads: &'static [u32], writes: &'static [u32]) -> Work {
|
||||
Work {
|
||||
name,
|
||||
step: false,
|
||||
making: false,
|
||||
event: false,
|
||||
reads,
|
||||
writes,
|
||||
fences: &[],
|
||||
}
|
||||
}
|
||||
|
||||
/// `work` held by the runtime.
|
||||
/// `work` held by the runtime, keeping its place.
|
||||
fn stepping(work: Work) -> Work {
|
||||
Work { step: true, ..work }
|
||||
}
|
||||
|
||||
/// `work` held for its pipelines' making, giving way.
|
||||
fn making(work: Work) -> Work {
|
||||
Work {
|
||||
step: true,
|
||||
making: true,
|
||||
..work
|
||||
}
|
||||
}
|
||||
|
||||
/// `work` naming `fences`.
|
||||
fn fencing(work: Work, fences: &'static [u32]) -> Work {
|
||||
Work { fences, ..work }
|
||||
}
|
||||
|
||||
/// Where `work` stands in the order across queues, as the scheduler's `place_of` answers.
|
||||
fn place(work: &Work) -> Place {
|
||||
match (work.event, work.making) {
|
||||
(true, _) => Place::Stops,
|
||||
(false, true) => Place::GivesWay,
|
||||
(false, false) => Place::Keeps,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether `later` runs after `earlier`, committed first on another line, in commit order: a fence
|
||||
/// both name, or, where `earlier` keeps its place, a resource one of them writes that the other
|
||||
/// uses.
|
||||
fn conflicts(earlier: &Work, later: &Work, gives_way: bool) -> bool {
|
||||
let meets = |a: &[u32], b: &[u32]| a.iter().any(|key| b.contains(key));
|
||||
meets(earlier.fences, later.fences)
|
||||
|| (!gives_way
|
||||
&& (meets(earlier.writes, later.reads)
|
||||
|| meets(earlier.writes, later.writes)
|
||||
|| meets(earlier.reads, later.writes)))
|
||||
}
|
||||
|
||||
/// `work` waiting for an event the program has not reached.
|
||||
fn waiting(work: Work) -> Work {
|
||||
Work {
|
||||
@@ -621,26 +661,18 @@ fn waiting(work: Work) -> Work {
|
||||
}
|
||||
}
|
||||
|
||||
/// What a [`Work`] reads and writes.
|
||||
type Uses = (&'static [u32], &'static [u32]);
|
||||
|
||||
/// The batch the scheduler submits next, as `submit_ready` takes it: the heads behind an earlier
|
||||
/// commit that keeps its place wait.
|
||||
fn take(order: &mut Order<Work>) -> Option<char> {
|
||||
let meets = |a: &[u32], b: &[u32]| a.iter().any(|key| b.contains(key));
|
||||
let mut memo = Behind::default();
|
||||
let behind = |order: &Order<Work>, sequence| {
|
||||
order.is_behind(
|
||||
sequence,
|
||||
&mut memo,
|
||||
(
|
||||
&mut |work: &Work| !work.event,
|
||||
&mut |work: &Work| (work.reads, work.writes),
|
||||
&|&(reads, writes): &Uses, &(later_reads, later_writes): &Uses| {
|
||||
meets(writes, later_reads)
|
||||
|| meets(writes, later_writes)
|
||||
|| meets(reads, later_writes)
|
||||
},
|
||||
&mut |work: &Work| place(work),
|
||||
&mut |work: &Work| *work,
|
||||
&conflicts,
|
||||
),
|
||||
)
|
||||
};
|
||||
@@ -658,6 +690,7 @@ fn stepped(order: &mut Order<Work>, name: char) {
|
||||
for head in order.heads_mut(&[]) {
|
||||
if head.name == name {
|
||||
head.step = false;
|
||||
head.making = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,7 +719,6 @@ fn a_later_commit_that_conflicts_waits_behind_a_batch_held_for_its_step() {
|
||||
/// true for ([`Behind::behind`]), each looked up on its own line ([`Order::head_mut_at`]). The
|
||||
/// batch taken, then those names.
|
||||
fn take_and_behind(order: &mut Order<Work>) -> (Option<char>, Vec<char>) {
|
||||
let meets = |a: &[u32], b: &[u32]| a.iter().any(|key| b.contains(key));
|
||||
let mut memo = Behind::default();
|
||||
let taken = {
|
||||
let behind = |order: &Order<Work>, sequence| {
|
||||
@@ -694,13 +726,9 @@ fn take_and_behind(order: &mut Order<Work>) -> (Option<char>, Vec<char>) {
|
||||
sequence,
|
||||
&mut memo,
|
||||
(
|
||||
&mut |work: &Work| !work.event,
|
||||
&mut |work: &Work| (work.reads, work.writes),
|
||||
&|&(reads, writes): &Uses, &(later_reads, later_writes): &Uses| {
|
||||
meets(writes, later_reads)
|
||||
|| meets(writes, later_writes)
|
||||
|| meets(reads, later_writes)
|
||||
},
|
||||
&mut |work: &Work| place(work),
|
||||
&mut |work: &Work| *work,
|
||||
&conflicts,
|
||||
),
|
||||
)
|
||||
};
|
||||
@@ -769,6 +797,44 @@ fn a_held_line_keeps_the_place_of_every_batch_in_it() {
|
||||
assert_eq!(taken, ['a', 'e', 'b', 'c']);
|
||||
}
|
||||
|
||||
/// A batch held for its pipelines' making gives way (`order.rs`, **Held batches give way**): a
|
||||
/// later commit of another queue that reads what it writes goes first, and so does one that
|
||||
/// writes it, as an x86 Mac's GPU may take them first; it goes once made.
|
||||
#[test]
|
||||
fn a_later_commit_goes_before_a_batch_held_for_its_making() {
|
||||
let mut order = Order::default();
|
||||
order.push(1, [making(work('a', &[3], &[1]))]);
|
||||
order.push(2, [work('b', &[1], &[])]);
|
||||
order.push(3, [work('c', &[], &[1])]);
|
||||
assert_eq!(take_and_behind(&mut order), (Some('b'), vec![]));
|
||||
assert_eq!(take_and_behind(&mut order), (Some('c'), vec![]));
|
||||
assert_eq!(take(&mut order), None);
|
||||
stepped(&mut order, 'a');
|
||||
assert_eq!(take(&mut order), Some('a'));
|
||||
}
|
||||
|
||||
/// A batch held for its making still holds back a later commit that shares a fence with it, and
|
||||
/// the batches after it on its line give way with it, a fence they share holding back alike.
|
||||
#[test]
|
||||
fn a_batch_held_for_its_making_holds_back_a_commit_sharing_a_fence() {
|
||||
let mut order = Order::default();
|
||||
order.push(
|
||||
1,
|
||||
[
|
||||
fencing(making(work('a', &[], &[1])), &[9]),
|
||||
fencing(work('e', &[], &[2]), &[8]),
|
||||
],
|
||||
);
|
||||
order.push(2, [fencing(work('b', &[], &[1]), &[9])]);
|
||||
order.push(3, [work('c', &[2], &[])]);
|
||||
order.push(4, [fencing(work('d', &[], &[]), &[8])]);
|
||||
assert_eq!(take_and_behind(&mut order), (Some('c'), vec!['b']));
|
||||
assert_eq!(take_and_behind(&mut order), (None, vec!['b', 'd']));
|
||||
stepped(&mut order, 'a');
|
||||
let taken: Vec<_> = std::iter::from_fn(|| take(&mut order)).collect();
|
||||
assert_eq!(taken, ['a', 'e', 'b', 'd']);
|
||||
}
|
||||
|
||||
/// A batch waiting for an event the program has not reached keeps no place, nor do the batches
|
||||
/// behind it on its line: Metal schedules them after the signal, so later commits go first.
|
||||
#[test]
|
||||
@@ -792,13 +858,15 @@ fn take_counted(order: &mut Order<Work>, footprints: &Cell<usize>, keeps: &Cell<
|
||||
(
|
||||
&mut |work: &Work| {
|
||||
keeps.set(keeps.get() + 1);
|
||||
!work.event
|
||||
place(work)
|
||||
},
|
||||
&mut |work: &Work| {
|
||||
footprints.set(footprints.get() + 1);
|
||||
work.writes
|
||||
},
|
||||
&|earlier: &&[u32], later: &&[u32]| earlier.iter().any(|key| later.contains(key)),
|
||||
&|earlier: &&[u32], later: &&[u32], _| {
|
||||
earlier.iter().any(|key| later.contains(key))
|
||||
},
|
||||
),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -2353,12 +2353,7 @@ impl<K: Copy + Ord> Footprint<K> {
|
||||
/// each shares a resource's range and one of them writes it, or one updates a fence the
|
||||
/// other waits for or updates.
|
||||
fn conflicts(&self, later: &Footprint<K>) -> bool {
|
||||
let fences = |updates: &[K], other: &Footprint<K>| {
|
||||
updates
|
||||
.iter()
|
||||
.any(|fence| other.waits.contains(fence) || other.updates.contains(fence))
|
||||
};
|
||||
if fences(&self.updates, later) || fences(&later.updates, self) {
|
||||
if self.fences_meet(later) {
|
||||
return true;
|
||||
}
|
||||
later.uses.iter().any(|used| {
|
||||
@@ -2372,6 +2367,21 @@ impl<K: Copy + Ord> Footprint<K> {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether one of `self` and `other` updates a fence the other waits for or updates.
|
||||
fn fences_meet(&self, other: &Footprint<K>) -> bool {
|
||||
let fences = |updates: &[K], other: &Footprint<K>| {
|
||||
updates
|
||||
.iter()
|
||||
.any(|fence| other.waits.contains(fence) || other.updates.contains(fence))
|
||||
};
|
||||
fences(&self.updates, other) || fences(&other.updates, self)
|
||||
}
|
||||
|
||||
/// Whether it waits for or updates a fence.
|
||||
fn names_a_fence(&self) -> bool {
|
||||
!self.waits.is_empty() || !self.updates.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a batch whose footprint is `earlier`, committed first, and one whose footprint is
|
||||
@@ -2389,6 +2399,22 @@ pub(super) fn ordered<K: Copy + Ord>(
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a batch whose footprint is `earlier`, committed first and held unsubmitted for its host
|
||||
/// step (`scheduler/order.rs`'s **Held batches give way**), and one whose footprint is `later`
|
||||
/// must still run in that order across queues: one updates a fence the other waits for or
|
||||
/// updates. `None` is a batch whose uses are not known yet, which may name any fence the other
|
||||
/// names.
|
||||
pub(super) fn fenced<K: Copy + Ord>(
|
||||
earlier: Option<&Footprint<K>>,
|
||||
later: Option<&Footprint<K>>,
|
||||
) -> bool {
|
||||
match (earlier, later) {
|
||||
(Some(earlier), Some(later)) => earlier.fences_meet(later),
|
||||
(None, Some(known)) | (Some(known), None) => known.names_a_fence(),
|
||||
(None, None) => true,
|
||||
}
|
||||
}
|
||||
|
||||
/// A fence's last update in the device's submission order.
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(test, derive(PartialEq))]
|
||||
|
||||
@@ -6249,9 +6249,12 @@ pub struct WorkCounts {
|
||||
pub heads_held_for_event_values: u64,
|
||||
/// Heads found held behind a batch of an earlier commit on **another logical queue** that
|
||||
/// keeps its place and whose footprint runs in commit order with the head's
|
||||
/// (`scheduler/order.rs`): Metal tracks a resource across queues in the order it schedules
|
||||
/// the command buffers, so a batch the runtime holds for a reason of its own (its host step,
|
||||
/// its submission checks) must not let a later commit's conflicting batch go first. This is
|
||||
/// (`scheduler/order.rs`): Metal tracks a resource across queues in the order the GPU takes
|
||||
/// the command buffers, so a batch the runtime holds for its submission checks, or for a host
|
||||
/// step whose gate was taken, must not let a later commit's conflicting batch go first. A batch
|
||||
/// held for its pipelines' making, or for a step that has not taken its gate, gives way: it
|
||||
/// holds a head back only where the two share a fence, as an x86 Mac's GPU may take a later
|
||||
/// commit of another queue first. This is
|
||||
/// the one hold that crosses logical queues and `VkQueue`s, and a batch whose uses are not
|
||||
/// all known yet (work a host step or its submission records, `tracker::ordered`'s `None`)
|
||||
/// conflicts with every batch that makes a tracked use or names a fence, but for a host
|
||||
|
||||
+7
-1
@@ -192,7 +192,13 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
`dispatch-dropped-still-making`, the first named by `CommandBuffer::dropped_draw` with
|
||||
`VK_TIMEOUT`, counted `WorkCounts::draws_dropped_still_making` and
|
||||
`dispatches_dropped_still_making`), and later command buffers draw and dispatch with the
|
||||
pipeline once made. Both bounds are 4.5 s by default. What one call waits for the driver's
|
||||
pipeline once made. Meanwhile it holds back only its own queue's later command buffers: one of
|
||||
another queue committed after it goes first, even where the two touch one tracked resource
|
||||
that one of them writes, and the waiting one runs after it, as an x86 Mac's GPU may take a
|
||||
later commit of another queue first (`metal2vulkan-conformance`'s
|
||||
`probes/cross_queue_surface_order.m`: a Radeon Pro 5300M and a UHD 630 under macOS 26.7.1;
|
||||
an M3 Max kept commit order); a fence the two share keeps commit order. Both bounds are 4.5 s
|
||||
by default. What one call waits for the driver's
|
||||
makings: a state's creation, its creation wait at most; a `commit`, until its own deadline at
|
||||
most (it records there what it can, an execution of render commands the CPU writes among
|
||||
them; every other recording runs on the runtime's scheduler thread, which no call waits for). A
|
||||
|
||||
Reference in new issue
Block a user