Scheduler: a committing thread's pass ends by waking the scheduler's thread, as a commit does
Since a committing thread's batch went alone on a grouping driver (4d4e103471), a `commit_and_submit` that submitted its batch itself no longer woke the scheduler's thread; before it, on such a driver, that batch was left to the thread, whose wake came with it. The thread so slept across those commits, and the plain `commit`s made beside them often fell into a slow mode: in the completion-latency lane (three shapes committed in turn 2 ms apart), the plain shapes' p50 was slow in 4 of 6 rounds (three jobs) without the wake and in none of 10 with it, before the alone path or after this change. Mechanism (gem10, RX 7900 XTX, RADV, Mesa 26.2.6, exclusive; m3-max-3816, a probe build): the thread's own counts over the lane show the wake source: before the alone path, sleeps 6000, woken by a commit 4000 and by the host 2000 (the committed batch left to it), batches submitted at commit 0; at3e9230adf2, sleeps 4000, commit 4000, host 0, at commit 2000; with a wake after the committing thread's submissions, sleeps 6000, commit 4000, host 2000, at commit 2000. The latency followed: in 3e9230adf2's slow round, the plain shapes' thread wake p50 4.5-10.6 us (p90 51-104) and commit to watch p50 56-104 us, `vkQueueSubmit` itself 27-62 us at the median, on every thread, the committing one's included; with the wake, both rounds at the old figures. The system-wide cpuidle counts (entries and residency of each state, the menu governor, amd-pstate-epp) did not separate the legs, so the idle-depth part of the account is not shown by them. Fix: `Scheduler::submit_at_commit` wakes the thread after its pass, for what it left (`Woken::Host`, as before) or else for the commit itself (`Woken::Commit`), once a sleep as any waker. The wake comes after the submissions and their submission handlers, so nothing on a command buffer's way to its `VkQueue` waits for it. Docs: the scheduler module, `submit_at_commit`, `Woken::Commit`, `CommandBuffer::commit_and_submit`, `WorkCounts::scheduler_wakes_commit` and `scheduler_wakes_host`, the runtime README's item, and FAST-PATHS row 37's figures for the alone path. New test: `tests::scheduler_wakes::a_commit_and_submit_wakes_the_sleeping_thread_as_a_commit_does` (ten `commit_and_submit`s after idle gaps, each submitted at commit, each a commit's waking). Verified (m3-max-3823, gem10 exclusive, release, base = the three scheduler files before4d4e103471, dev = development's scheduler, fix = this; two alternating rounds of both lanes): - the plain shapes back at base: commit to watch p50 31.3-37.0 us against base 29.9-39.4 (dev 33.4-169.9), the thread's wake p50 4.1-4.5 us against 4.0-4.2 (dev 4.3-51.0); - commit_and_submit keeps its gain: a checked fill's commit to submission handler p50 30.7-32.2 us against base 34.2-70.0, 520 of 520 submitted at commit; the call returns at 32.0-33.5 us against dev's 31.8-33.8; the shape in turn with the plain ones, commit to watch p50 31.3-31.6 us against base 31.3-39.5 (dev 29.6-102.4). Tests alone on RADV (each `--exact`, one thread): commit_and_submit, deferred_calls and scheduler_wakes, 31 of 31 pass at the fix; with development's scheduler 30 of 31, the new test failing with 0 commit wakings of 10. Clippy (plain, m2v_gpu, m2v_cpu_icd) and rustdoc with -D warnings pass (m3-max-3824, um870). (cherry picked from commit b80e092759fb412a0154365bfb378ee38e096f56)
This commit is contained in:
1 parent
2d194d6c4a
commit
ff870f6403
6 files changed
+68
-20
No files matched your search
@@ -409,9 +409,9 @@ Calls Metal does not have, for a consumer that emulates a Metal device:
|
||||
inside the call just before each submission (unless one waits for a shared event's GPU signal
|
||||
to land, which the scheduler's thread waits for; a plain event's wait goes to the `VkQueue`, as
|
||||
Metal submits an `MTLEvent` wait at once) and their submission handlers after it, in submission
|
||||
order with every other command buffer's. What it leaves goes
|
||||
to the scheduler's thread. One wake and one thread hop fewer per command buffer than `commit`,
|
||||
whose submission is the scheduler thread's, as Metal's is its own thread's
|
||||
order with every other command buffer's. Then it wakes the scheduler's thread, as `commit`
|
||||
does, and what it left goes to that thread. No wake and no thread hop lies on its way to the
|
||||
`VkQueue`, where `commit`'s submission is the scheduler thread's, as Metal's is its own thread's
|
||||
(`WorkCounts::scheduler_passes_at_commit`, `batches_submitted_at_commit`,
|
||||
`batches_checked_at_commit`). Under `RenderLoweringPolicy::Worker`, one whose last render
|
||||
encoder's end the lowering thread has not lowered returns as `commit` does, and the thread that
|
||||
|
||||
@@ -2854,9 +2854,9 @@ impl CommandBuffer {
|
||||
/// holds it in the group, where two or more run. A batch held back
|
||||
/// (another queue's, for its checks, an event value or a host step) holds back only the later
|
||||
/// commits that wait behind it, as on the scheduler's thread: those of its own queue, and
|
||||
/// another queue's whose resources it uses. What it leaves goes to the scheduler's thread,
|
||||
/// which it wakes; where a pass is under way, that pass takes this commit in, as for
|
||||
/// `commit`.
|
||||
/// another queue's whose resources it uses. Then it wakes the scheduler's thread, as `commit`
|
||||
/// does, after its submissions, and what it left goes to that thread; where a pass is under
|
||||
/// way, that pass takes this commit in, as for `commit`.
|
||||
///
|
||||
/// - **Its submission checks run here**, inside this call, for the batches it submits
|
||||
/// ([`set_submission_check`](Self::set_submission_check)): each just before its batch's
|
||||
|
||||
@@ -32,9 +32,14 @@
|
||||
//! no earlier commit, has its checks run there too, without the lock, the head marked so this
|
||||
//! thread leaves them ([`claim_check`]), and is submitted by a pass of the committing thread's
|
||||
//! right after. A head another queue holds back (its checks waiting for a signal to land, or run
|
||||
//! by this thread) so holds back no later commit that does not wait behind it. What it leaves
|
||||
//! goes to this thread, which it wakes, and a pass under way takes the commit in instead. One wake and one thread hop fewer per command
|
||||
//! buffer, its submission's cost on the committing thread.
|
||||
//! by this thread) so holds back no later commit that does not wait behind it. Its pass ends
|
||||
//! by waking this thread, as the commit would have, after its submissions: for what it left,
|
||||
//! else for the commit itself; a pass under way takes the commit in instead. So no wake and no
|
||||
//! thread hop lies on a command buffer's way to its `VkQueue`, its submission's cost on the
|
||||
//! committing thread, and this thread still wakes once for each commit that finds it asleep,
|
||||
//! whichever thread submits: a thread left asleep across the commits sleeps longer, and where
|
||||
//! the host's cores idle deeper the longer they sleep, its next wake and pass, for a `commit`,
|
||||
//! take several times longer (`tests::completion_latency`, RADV).
|
||||
//! - **Submission handlers run in submission order, whichever thread runs them** ([`Turns`]).
|
||||
//! Each pass that took batches with submission handlers takes a ticket under the lock, in the
|
||||
//! order the passes ran; the handlers of a ticket run once those of every earlier one ran, on
|
||||
@@ -316,7 +321,8 @@ struct GpuWait {
|
||||
/// [`Scheduler::sleeps_and_wakings`] gives them.
|
||||
#[derive(Clone, Copy)]
|
||||
enum Woken {
|
||||
/// A commit left its batches to the thread.
|
||||
/// A commit left its batches to the thread, or a committing thread's pass took them
|
||||
/// ([`Scheduler::submit_at_commit`]).
|
||||
Commit,
|
||||
/// A completion turn: what a head waited for from the GPU was met, or the device was lost.
|
||||
Completion,
|
||||
@@ -939,10 +945,11 @@ impl Scheduler {
|
||||
/// only for its submission checks and this thread may run them ([`claim_check`]), it runs them
|
||||
/// then, as the scheduler's thread does (`CommandBufferShared::run_checks`), and passes again
|
||||
/// under the lock ([`Inbox::pass_again`]), which submits that head; and so on, up to
|
||||
/// [`PASS_SUBMISSIONS`] batches in all. What it leaves, and anything committed or nudged
|
||||
/// meanwhile, goes to the thread, which it wakes. Where a passer is counted, that pass takes
|
||||
/// the commit in. Then it makes the completion turn a command buffer that needs no GPU work
|
||||
/// left it (`Completion::turn_owed`).
|
||||
/// [`PASS_SUBMISSIONS`] batches in all. Then it wakes the thread, as the commit would have
|
||||
/// (the module docs): for what it left and anything committed or nudged meanwhile
|
||||
/// ([`Woken::Host`]), else for the commit ([`Woken::Commit`]). Where a passer is counted, that
|
||||
/// pass takes the commit in. Then it makes the completion turn a command buffer that needs no
|
||||
/// GPU work left it (`Completion::turn_owed`).
|
||||
///
|
||||
/// It runs the program's code only in the submission checks of the heads it checks and the
|
||||
/// submission handlers of the batches it submitted: a scheduled handler is run on its queue's
|
||||
@@ -980,9 +987,11 @@ impl Scheduler {
|
||||
return;
|
||||
};
|
||||
device.shared().counts.committer_passed(submitted, checked);
|
||||
if left_over || shared.inbox.passed_over() {
|
||||
self.wake_for(Woken::Host);
|
||||
}
|
||||
// After the submissions, so none waits for the wake.
|
||||
self.wake_for(match left_over || shared.inbox.passed_over() {
|
||||
true => Woken::Host,
|
||||
false => Woken::Commit,
|
||||
});
|
||||
device.shared().completion.turn_owed();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
//! `commit_and_submit` in turn, never waiting for a command buffer (a wait would submit for
|
||||
//! itself), see every command buffer complete within a bound: a commit whose wake was lost
|
||||
//! would leave its batches in the inbox of an idle thread that sleeps until woken.
|
||||
//! - **Woken by a committing thread's pass too.** A `commit_and_submit` that submits its batch
|
||||
//! itself, after an idle gap, wakes the sleeping thread once after its submission, as a
|
||||
//! `commit` does (`scheduler/mod.rs`, "A committing thread may submit for itself"): the thread
|
||||
//! keeps the commits' pace whichever thread submits them.
|
||||
//! - **Never behind a submission.** A commit that finds no pass under way wakes the thread without
|
||||
//! the lock a pass holds across its `vkQueueSubmit`: with the `VkQueue` held and that lock held,
|
||||
//! no pass counted, a commit from another thread returns at once.
|
||||
@@ -195,6 +199,40 @@ fn commits_with_idle_gaps_lose_no_wake() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Commits made with `commit_and_submit` alone, each after an idle gap and each submitted by its
|
||||
/// committing thread: each wakes the sleeping thread once, as a `commit` does, counted as a
|
||||
/// commit's waking.
|
||||
#[test]
|
||||
fn a_commit_and_submit_wakes_the_sleeping_thread_as_a_commit_does() {
|
||||
const COMMITS: u64 = 10;
|
||||
let device = device();
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let target = device.new_buffer(256, ResourceOptions::private()).unwrap();
|
||||
let completed = Arc::new(AtomicU64::new(0));
|
||||
// The first use of the queue and the target, untimed and uncounted.
|
||||
counted_fill(&queue, &target, 0, &completed)
|
||||
.commit()
|
||||
.unwrap();
|
||||
settle(&completed, 1, "the first");
|
||||
let before = device.work_counts();
|
||||
for at in 1..=COMMITS {
|
||||
// The thread sleeps by now.
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
let command_buffer = counted_fill(&queue, &target, at as u8, &completed);
|
||||
command_buffer.commit_and_submit().unwrap();
|
||||
settle(&completed, at + 1, &format!("commit {at}"));
|
||||
}
|
||||
let after = device.work_counts();
|
||||
let by_commit = after.scheduler_wakes_commit - before.scheduler_wakes_commit;
|
||||
let at_commit = after.batches_submitted_at_commit - before.batches_submitted_at_commit;
|
||||
println!("{by_commit} wakings by a commit, {at_commit} batches submitted at commit, {COMMITS} commits");
|
||||
assert_eq!(at_commit, COMMITS, "a batch was left to the thread");
|
||||
assert_eq!(
|
||||
by_commit, COMMITS,
|
||||
"a commit_and_submit left the sleeping thread asleep"
|
||||
);
|
||||
}
|
||||
|
||||
/// A commit that finds no pass under way wakes the scheduler's thread without the lock a pass
|
||||
/// holds across its `vkQueueSubmit` (`scheduler/inbox.rs`, "Posted, never passed"). A pass
|
||||
/// counted only after the commit looked for one can take that lock before the commit's wake, and
|
||||
|
||||
@@ -4653,7 +4653,8 @@ pub struct WorkCounts {
|
||||
/// was woken or [`scheduler_sleep_slices`](Self::scheduler_sleep_slices) says it timed out.
|
||||
pub scheduler_sleeps: u64,
|
||||
/// Times a commit woke the scheduler's thread, which slept: it left its batches to the
|
||||
/// thread. Each waking here is a notify of its condition variable, or a signal of its nudge
|
||||
/// thread, or its committing thread's own pass submitted them and then woke the thread, as a
|
||||
/// commit does (`CommandBuffer::commit_and_submit`). Each waking here is a notify of its condition variable, or a signal of its nudge
|
||||
/// where it slept on the GPU, made only where it slept, and once a sleep: a later waker
|
||||
/// before the thread ran makes none. With the completion and host wakings, at most one a
|
||||
/// sleep (`scheduler_sleeps`).
|
||||
@@ -4664,7 +4665,7 @@ pub struct WorkCounts {
|
||||
pub scheduler_wakes_completion: u64,
|
||||
/// Times a host signal woke it: an event's value set by the host, a pipeline a host step waits
|
||||
/// for made, a texture decode finished, a command buffer encoded again after a rebind, the
|
||||
/// rest of a pass a thread about to block left it, a lost device.
|
||||
/// rest of a pass a thread about to block or a committing thread left it, a lost device.
|
||||
pub scheduler_wakes_host: u64,
|
||||
/// Sleeps that ended at the thread's longest wait with nothing having woken it.
|
||||
pub scheduler_sleep_slices: u64,
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ three consumer pipelines: A2X (`a2x-s4`, `a2x-s96`), Xgc14 (`xgc14-bgra8`) and X
|
||||
|---|---|---|---|---|
|
||||
| A blend into a packed 16-bit attachment the device renders through its word view (`A1BGR5Unorm`, `ABGR4Unorm` on the RTX 5080; `WordAttachment`), which the function computes in the interlocked storage form, reads the attachment's codes, where Metal's tile holds the pass's clear and each earlier blend's result as a `half`, finer; under fast math it also sums a few states otherwise than Metal. Every device rendering such an attachment. | The in-shader blend over the codes (no switch) | **Not built yet:** the extended-range attachments' `half` shadow (`render/extended_shadow.rs`, `VariantKey::extended_shadows`) taken by word attachments: the runtime's shadow start and end, its load of the codes and the clear's halves, and the word's shadowed variant in `lower::fragment::fetch`, for a single-sampled pass and a multisampled one (an extended-range color's shadow holds per sample, from the pass's clear). Fast math's regrouped sums have no model | One code: without fast math exact over a loaded attachment (the 2,891 states of the M3 sweep, every channel), under fast math 3,527 of 94,732,288 channels a code apart; after a clear or an earlier blend in the pass, a code apart where the two readings store different codes. `DeviceColorConversion` (`device-color-conversion`) | Not measured. Expected from the shadow's form: an `R16G16B16A16_SFLOAT` image of the pass's extent per such color (8 bytes a pixel, 16.6 MB at 1920x1080), set at the draw it starts by a fill or a load dispatch, and an 8-byte storage read and write per blended fragment inside the interlock beside the word's |
|
||||
| A heap's colour texture that Metal keeps losslessly compressed (`allowGPUOptimizedContents`, no `ShaderWrite`, `PixelFormatView` or `ShaderAtomic` usage, 16 texels or more a side), on a driver whose compressed images may keep their texels apart from the memory they are bound to (`DriverFact::CompressedImagesHideAliasedWrites`: ANV), is the driver's compressed optimal image, its compression and fast clears kept. A texture Metal keeps uncompressed takes the uncompressed image under either value. The runtime's choice: no pipeline differs. | `heap_compression = HeapCompressionPolicy::Compressed` | `heap_compression = HeapCompressionPolicy::Uncompressed`: an image the driver keeps uncompressed in the heap's bytes, as for a texture Metal keeps uncompressed: host-transfer usage where the device enabled `hostImageCopy` (`heap-texture-host-transfer`), else a linear image (`heap-texture-linear`), else the optimal one (`heap-texture-hides-aliased-writes`) | A write through a buffer or another texture over the texture's bytes may leave its texels as they were or change them otherwise than as written, where Metal's texture reads opaque magenta (`0xffff00ff`) in every texel of drawn content the write covers and the written bytes where it held only a clear; the texture's own writes may show in those bytes compressed. Within Metal's contract: Metal documents such a texture's layout as its own (`allowGPUOptimizedContents` lets it "adjust the private layout"), so no write through another view over its bytes has a defined result there either. `HeapTextureCompressed` (`heap-texture-compressed`), announced once per device where such a texture is made; `runtime_lane::heap_textures` | ANV (Iris Xe of RPL-P; `heap_textures::heap_compression_costs`), a 2048x2048 `RGBA8Unorm` render target in a `Private` placement heap: a pass that clears it 26.9 us against 676.2-676.5 us; a copy into another such texture 647.7-649.1 us against 673.9-693.2 us |
|
||||
| Batches of command buffers committed on one queue that the scheduler finds ready together (a backlog) go to the driver in one `vkQueueSubmit`, at most four, only the last signalling the queue's timeline, on a device whose own check finds a submission that signals nothing merged into the next (`submit_check.rs`, once per driver, release and kernel: one `vkQueueSubmit` of four empty infos against four calls of one, merged where the one costs at most 0.6 of the four; Mesa 26.2.6's RADV on the Radeon 780M, the RX 7900 XTX and the RX 550 at 0.33-0.38, ANV on the Iris Xe of RPL-P at 0.39, MoltenVK 1.4.2 on the M3 Max at 0.98; a device whose check has not answered, or that does not merge, takes the ungrouped form under either value of the switch): one kernel submission, where ANV on i915 lists every `VkDeviceMemory` in each (the consumer's guest drag on the Iris Xe: about 300 entries per execbuffer, 260 of them its host imports, at 112 to 128 execbuffers a frame). A batch's event signals ride to the group's end, which signals each event's semaphore to the highest index the batches held signal it to (an event's indices rise in commit order). A batch that signals a binary semaphore, takes a fence, binds a sparse update, does first work, names the caller's wrapped image, or waits for anything not seen complete (an event, another queue's work) goes alone, after the batches held: a batch with a wait leads a group, never joins one. So that checked command buffers (the consumer checks each) are found ready together, the submission checks of up to three batches right behind a line's head that goes run with the head's, in commit order, none committed after another queue's batch: such a check runs before the previous batch's `vkQueueSubmit` rather than after it, in the scheduler pass that submits its own batch. A pass that finds no batch ready sends the batches held, unless two or more earlier submissions of their `VkQueue` are not seen complete: the GPU runs those first in any case, so the batches stay held, and those committed meanwhile join them, until one submission is left in flight (a completion turn wakes the scheduler at its value), the group fills, a later batch sends it, a head waits for the GPU, or a thread waits for one of their command buffers' completion, which sends them at once; a batch that ends a command buffer with a switch of storage forms riding on it, which settles by its submission's outcome, is never kept so. A batch a committing thread submits (`CommandBuffer::commit_and_submit`) goes alone where its `VkQueue` runs at most one earlier submission not seen complete, as the pass that held it would send the group at once; where two or more run it is left to the scheduler's thread, which holds it. A held batch that ends its command buffer is `Scheduled` as it is held, its submission handlers run first, then its scheduled handlers, and its kernel end time set, as an M3 Max schedules a command buffer committed behind running work 0.04 to 0.18 ms after its commit. The runtime's: no pipeline differs. | `completion = CompletionPolicy::Grouped` | `completion = CompletionPolicy::Exact`: one submission per batch, each signalling its own values; each line's head checked alone | Each command buffer of a submission but the last is seen complete (status, completed handlers, waits), and the event values it signals are reached (by the GPU waits on other queues, the host's waits, value reads and listeners), once the last completed: late by the GPU time of at most three later batches (about 0.1 to 0.2 ms each in the consumer's compositor frames on the Iris Xe; about 20 ms behind a 20 ms batch), never early, in commit order. Metal's contract states no bound on when completion is seen (an M3 Max reports a command buffer complete, its handlers, status, waits and event listeners alike, 0.04 to 0.10 ms after its GPU end), and no member but the first waits, so no wait holds a member back: a valid program sees only later completion, as of slower GPU work. A batch kept while earlier work runs is seen complete within the same bound, and, where the one submission left in flight ends before its group reaches the GPU, late besides by that gap: at most a completion turn's reaction and the group's `vkQueueSubmit`. Commands, barriers and GPU times are unchanged. `GroupedCompletion` (`grouped-completion`), announced once per device at its first such submission; `runtime_lane::grouped_submissions` | ANV (Iris Xe of RPL-P; `frame_costs::frame_costs_over_imports`, the checked device, 67 command buffers a frame, GPU at 467-783 MHz), with 520 host imports live, where the Exact form's submissions fall behind the commits as the guest's do: 32.0-33.2 kernel submissions a frame against 67.0, 3.4-3.5 ms of execbuffer ioctl a frame against 6.9-7.9 ms, the scheduler thread's CPU 61-63 us a command buffer against 121-136 us, a frame through completion 4.7-5.9 ms against 8.6-9.7 ms; in the guest's shape with 520 (a second queue taking every 20th Line truncated
|
||||
| Batches of command buffers committed on one queue that the scheduler finds ready together (a backlog) go to the driver in one `vkQueueSubmit`, at most four, only the last signalling the queue's timeline, on a device whose own check finds a submission that signals nothing merged into the next (`submit_check.rs`, once per driver, release and kernel: one `vkQueueSubmit` of four empty infos against four calls of one, merged where the one costs at most 0.6 of the four; Mesa 26.2.6's RADV on the Radeon 780M, the RX 7900 XTX and the RX 550 at 0.33-0.38, ANV on the Iris Xe of RPL-P at 0.39, MoltenVK 1.4.2 on the M3 Max at 0.98; a device whose check has not answered, or that does not merge, takes the ungrouped form under either value of the switch): one kernel submission, where ANV on i915 lists every `VkDeviceMemory` in each (the consumer's guest drag on the Iris Xe: about 300 entries per execbuffer, 260 of them its host imports, at 112 to 128 execbuffers a frame). A batch's event signals ride to the group's end, which signals each event's semaphore to the highest index the batches held signal it to (an event's indices rise in commit order). A batch that signals a binary semaphore, takes a fence, binds a sparse update, does first work, names the caller's wrapped image, or waits for anything not seen complete (an event, another queue's work) goes alone, after the batches held: a batch with a wait leads a group, never joins one. So that checked command buffers (the consumer checks each) are found ready together, the submission checks of up to three batches right behind a line's head that goes run with the head's, in commit order, none committed after another queue's batch: such a check runs before the previous batch's `vkQueueSubmit` rather than after it, in the scheduler pass that submits its own batch. A pass that finds no batch ready sends the batches held, unless two or more earlier submissions of their `VkQueue` are not seen complete: the GPU runs those first in any case, so the batches stay held, and those committed meanwhile join them, until one submission is left in flight (a completion turn wakes the scheduler at its value), the group fills, a later batch sends it, a head waits for the GPU, or a thread waits for one of their command buffers' completion, which sends them at once; a batch that ends a command buffer with a switch of storage forms riding on it, which settles by its submission's outcome, is never kept so. A batch a committing thread submits (`CommandBuffer::commit_and_submit`) goes alone where its `VkQueue` runs at most one earlier submission not seen complete, as the pass that held it would send the group at once; where two or more run it is left to the scheduler's thread, which holds it. A held batch that ends its command buffer is `Scheduled` as it is held, its submission handlers run first, then its scheduled handlers, and its kernel end time set, as an M3 Max schedules a command buffer committed behind running work 0.04 to 0.18 ms after its commit. The runtime's: no pipeline differs. | `completion = CompletionPolicy::Grouped` | `completion = CompletionPolicy::Exact`: one submission per batch, each signalling its own values; each line's head checked alone | Each command buffer of a submission but the last is seen complete (status, completed handlers, waits), and the event values it signals are reached (by the GPU waits on other queues, the host's waits, value reads and listeners), once the last completed: late by the GPU time of at most three later batches (about 0.1 to 0.2 ms each in the consumer's compositor frames on the Iris Xe; about 20 ms behind a 20 ms batch), never early, in commit order. Metal's contract states no bound on when completion is seen (an M3 Max reports a command buffer complete, its handlers, status, waits and event listeners alike, 0.04 to 0.10 ms after its GPU end), and no member but the first waits, so no wait holds a member back: a valid program sees only later completion, as of slower GPU work. A batch kept while earlier work runs is seen complete within the same bound, and, where the one submission left in flight ends before its group reaches the GPU, late besides by that gap: at most a completion turn's reaction and the group's `vkQueueSubmit`. Commands, barriers and GPU times are unchanged. `GroupedCompletion` (`grouped-completion`), announced once per device at its first such submission; `runtime_lane::grouped_submissions` | ANV (Iris Xe of RPL-P; `frame_costs::frame_costs_over_imports`, the checked device, 67 command buffers a frame, GPU at 467-783 MHz), with 520 host imports live, where the Exact form's submissions fall behind the commits as the guest's do: 32.0-33.2 kernel submissions a frame against 67.0, 3.4-3.5 ms of execbuffer ioctl a frame against 6.9-7.9 ms, the scheduler thread's CPU 61-63 us a command buffer against 121-136 us, a frame through completion 4.7-5.9 ms against 8.6-9.7 ms; in the guest's shape with 520 (a second queue taking every 20th Line truncated
|
||||
| Batches of command buffers on one `VkQueue`, on a driver measured to start no kernel submission of a queue before the one before it completed (ANV, RADV and NVIDIA's; `batch_order.rs`), are ordered by their ends: each ends with a barrier ordering its work before every later command of its `VkQueue` (the exact form's end orders it before the host's reads and writes alone), so a batch that depends on an earlier one there begins with no barrier of its own, often no command buffer of barriers, and its first encoder's GPU start is written at the bottom of the pipe, once everything before it completed. Metal starts an independent command buffer committed behind running work while that work runs (an M3 Max under macOS 27.0.1, probe `gpustart`); those drivers ran two batches of independent work one after the other under every shape measured (no end barrier, the host's or the widened one; in one `vkQueueSubmit` or two, merged into one kernel submission or not), where two dispatches of one command buffer ran side by side. The runtime's: no pipeline differs. | `batch_order = BatchOrderPolicy::Ends` | `batch_order = BatchOrderPolicy::Exact`: a barrier for each dependency of a batch's work on an earlier batch's of its `VkQueue`, the end's barrier to the host's reads and writes alone, the GPU start written at the top of the pipe; every other driver takes it under either value | None: on those drivers each batch starts once the one before it completed under either value, so the work's order, its results and its GPU times are the same, and a batch's GPU start is the end of the work before it, when such a driver starts it. Not announced; `runtime_lane::commit_work` and `runtime_lane::gpu_times` test both values | UHD 770 (ANV, RPL-S), the consumer's frame shape over 520 host imports, 67 command buffers a frame, Grouped completion, the widened end barrier against the exact form (a probe build of each): with no fill ahead of each command buffer, 67.0 command buffers submitted a frame against 129.3-129.7, the GPU's span a frame 1.84-1.90 ms against 1.99-2.06 ms, a frame through completion 2.13-2.22 ms against 2.27-2.38 ms; with a 1 MiB fill ahead of each, 134.0 against 262.9, 8.03-8.22 ms against 8.32-8.42 ms, 9.00-9.15 ms against 9.25-9.36 ms. Radeon 780M (RADV, Mesa 26.0.8), this switch: with no fill, 67.0 against 128.9-129.0, a frame through completion 48.3-48.6 ms against 42.6-47.0 ms; with a 16 MiB fill committed at once, 134.0 against 251.0-251.1, 50.6-50.8 ms against 50.8-57.3 ms; committed every 1 ms, 134.0 against 249.7-250.2, 71.3-83.6 ms against 106.3-113.6 ms (each kernel submission there leaves about 2.5 ms of the GPU idle over 520 host imports, which sets these frames) |
|
||||
| Command queues on a device whose GPU idles when consecutive work comes from another `VkQueue` share `VkQueue`s by choice (`queue_share.rs`): the runtime's own self-check, not a `DriverFact` row, measures that idling once per driver, release and runtime on a thread of its own and keeps its verdict (`Idles`, `DoesNotIdle`, `Unchecked`) in the shader cache's directory, as the in-place check keeps its own (`queue_switch_check.rs`: 48.7 to 51.3 us a switch on the RTX 5080 Laptop GPU, NVIDIA 615.71.09, `Idles` above 20 us). A command queue that makes a command buffer while it holds no other uncompleted one moves onto the busy `VkQueue` of its family whose oldest batch has run under 0.5 ms, the most batches in flight first, so short command buffers of several queues run with no switch between them. A queue one of whose command buffers ran on the GPU for over 2 ms, by its own timestamps (not the host's view of how long it ran as its `VkQueue`'s oldest, which also holds its wait for the GPU to start it and the waiter's lateness to see it complete), is long: no queue joins its `VkQueue` while it lives, and it moves once more, at its next idle point, to an idle `VkQueue` no long or unshared queue holds. A queue whose command buffers must never wait behind another queue's (a compositor's beside an application's) is made with `Device::new_command_queue_unshared`: it never moves and no queue joins its `VkQueue`. Presenting queues and a queue that lent its `VkQueue` (`with_vk_queue`) never move. Before the verdict, and where it is not `Idles` or there are no two `VkQueue`s of one family (MoltenVK, RADV, lavapipe), every queue keeps the `VkQueue` it took at its creation; so does every queue of a device whose command buffers write no GPU timestamps it reads (`gpu_times_from_host`, or a driver whose timestamps wait for every queue's), which does not share and is counted (`WorkCounts::queue_sharing_untimed`). The runtime's: no pipeline differs. | `queue_sharing = QueueSharingPolicy::Adaptive` | `queue_sharing = QueueSharingPolicy::PerQueue`: each command queue keeps the `VkQueue` it took at its creation, round robin, and the check does not run | A command buffer waits behind the command buffers of the queues sharing its `VkQueue`, where Metal's queues wait for each other only inside one command. The residual stall: once per logical queue that goes long, for a queue that joined its `VkQueue` during its short phase, about one long command buffer's length: the command buffers committed behind that queue's first long one there wait for its whole length (and those behind its later ones while it holds work, until its next idle point). Measured on the RTX 5080 Laptop GPU beside an application that alternates draws with 30 ms command buffers: a shared compositor's commits at 4,800 a second had 64 completions over 10 ms, at most 26.4 to 30.1 ms, in each of 3 runs of each of two such shapes (one join each), against none over 10 ms under `PerQueue` in those 6 runs (at most 5.6 to 9.7 ms); with 2 ms of draws between long command buffers, none over 10 ms in 3 runs (at most 5.7 to 9.8 ms) against 7, 0 and 0 under `PerQueue` (at most 6.9 to 11.2 ms). On an unshared queue, 0 over 10 ms in every run. A command buffer's GPU start time includes the other queues' work before it. `QueueSharing` (`queue-sharing`), at the device's first join | Command buffers a second on the RTX 5080 Laptop GPU, one-draw command buffers, each thread its own queue, the default against `PerQueue`, runs after a lock hold's first: 8 threads with 3 in flight 50.7k to 54.7k against 27.4k to 28.0k (5 runs each); 8 threads with 1 in flight 47.0k to 50.1k against 13.9k to 14.3k (5); 2 threads with 3 in flight 28.0k to 53.7k against 21.4k to 28.0k (10 each, in turn, the default above `PerQueue` in each pair; no thread's queue marked long), and beside another process's 30 ms command buffers 5.1k to 6.7k against 4.0k to 4.1k (3 each; the host's view marked a thread's queue long in 1 of 3 runs, which then ran at `PerQueue`'s 4.1k); 2 threads with 1 in flight 16.9k to 20.7k against 10.1k to 11.5k (5); one thread over 16 queues in turn 21.7k to 43.3k against 10.2k to 11.1k, over 2,048 20.0k to 39.2k against 10.2k to 11.2k (4). Beside an application whose queue never shared with the compositor (isolation, 300 and 30 dispatches), both 0 over 10 ms |
|
||||
| A chain of `half` additions, subtractions and products on a device without `shaderFloat16` (vk12-floor, SwiftShader, Pascal; capability emulation: the module computes each in `float` and rounds it by the device's `OpQuantizeToF16`): an operation whose flags hold `contract` and `reassoc` and whose result only such operations read is held at `float` precision unrounded, so the chain rounds where a value leaves it (a store, an output, a conversion, a comparison, a call, a phi, a vector move, an operation without both flags), one quantize per exit instead of one per operation (`lower::arith::half_chain`). A device with `shaderFloat16` computes `half` alike under either value. | `half_chains = HalfChainPolicy::AtExits` | `half_chains = HalfChainPolicy::EachOperation`: every operation's result rounded to `half`, as the AIR computes it | The result may differ from the rounded operations' by the roundings the chain skips, each within half a unit in the last place of a `half` at its step, compounded along the chain; a value inside the chain past `half`'s range (65504) stays finite where the rounded operations reach infinity. Within the AIR's flags, which let a compiler regroup and fuse such operations. `FastMathRewrites` (`fast-math-rewrites`) | Not timed. Size on vk12-floor (the fixtures' SPIR-V words, the default against the accurate form): `hfb_filter_bank` 121,270 against 131,766 (1,024 quantizes against 2,464), `grd_half_many_samples` 82,019 against 84,627, `nan_half_fast` 9,808 against 9,832 |
|
||||
|
||||
Reference in new issue
Block a user