Pin 97 test fixes: the busy-VkQueue join test takes its own rounds; held_step_order calibrates by its own times
Test-only; no RUNTIME bump. Two commits from steelbrain/regr97q: command_queues: the busy-VkQueue join takes rounds of its own until a queue joined, and says what each look found What: a_queue_joining_another_s_busy_vk_queue_is_announced_once made one busy queue and three joiners, each joiner making one fill while 24 of the busy queue's fills were in flight, and asserted a join where the device shares. Now each round makes a busy queue and a joiner of its own, at least three rounds, and, where the device shares and no queue joined yet, up to 16. The assertions are unchanged: joins above 0 exactly where the device shares, and queue-sharing announced exactly once where a queue joined. Every run prints, and a failure says, the joins, the rounds, and the looks that found no other VkQueue busy (picks_with_none_busy), passed over a busy one's old oldest batch (joins_withheld_from_old_heads) or an unshared queue's (joins_withheld_from_unshared), and the queues gone long. Why: pin 97's RTX 3090 leg (m3-max-31476) failed it with "0 joins where the device shares: true"; pin 96's passed. Nothing between them touches its path: its work is plain blit fills, which no host-step rule sees, and joining reads queue_share.rs's per-VkQueue state, which no commit in 9303a1f03f..eee64c8668 changed (the test queue limits of58de9ba9a1,3db60efc33and5efe2f1d73are the runtime crate's cfg(test) alone; this test takes the plan). A join needs the joiner's look to land while the busy VkQueue has a batch in flight whose oldest has run under 0.5 ms (YOUNG_HEAD), and the 24 fills of 16 MiB are about that much of a 3090's work; on that loaded leg (its neighbours took 15-16 s each) a late test thread or completion thread misses it at every look, or a fill sliced between other processes' work marks the busy queue long, after which nothing joins it. The old test could not say which. A product that never joins still fails every round. Verified: in the lane's report (the 3090 run of the old test alone, and this one). ---- held_step_order: the long work's host share stays small, and a run is judged by its own times What: command_buffers_behind_a_waiting_step_read_scheduled requires the long command buffer and its follower to read Scheduled within 10 ms of their commits while the step waits at its gate. It failed in two loaded venues, in two ways: - lavapipe on msi (m3-max-31554): of 3 runs only the first, warm-up run was "early"; runs 2 and 3 read Scheduled at 7.5 and 7.7 ms, but their long work ended 38-41 ms after the follower's commit, short of the calibrated 100 ms, so the filter's "half the long work" (50 ms) dropped them; - the RX 7900 XTX suite leg of pin 97 (m3-max-31481): every run early, the follower Scheduled at 0.35 and 2.2 ms, but the long one at 12.6 and 17.1 ms after its commit call. At 64 MiB a fill the XTX's calibration takes about 1400 fills, and that commit's encoding, planning and submission of them, before its pass's batch reaches its gate, falls inside the measured time and grows with the GPU's speed. Now: - each fill writes 256 MiB (the calibration starts at 16 fills, at least 2), so a fast GPU's long work is a quarter as many commands; - a run counts where the long work ended at least twice the 10 ms bound after the follower's commit, by that run's own times: a command buffer made Scheduled only as the long work ended would then read it past the bound, so the run still tells the two apart; - each run prints the fills and when the long one's commit returned. The 10 ms bound and every assertion are unchanged. The other leg of the module (the unshared queue's fill and reset) shares the fills and keeps its own criteria. Verified: in the lane's report (lavapipe here; the XTX through the orchestrator). Verified: lavapipe m3-max-31646 3/3 with clippy (m2v_cpu_icd) 0, m2v_gpu clippy 0 in m3-max-31647; 780M HP m3-max-31597 9/9 (queue_order x6, steps_apart, held_step_order x2); 3090 join test alone m3-max-31627 pass in 1.18 s.
This commit is contained in:
1 parent
723f8fa1cd
commit
2fadc74ab7
2 files changed
+73
-31
No files matched your search
@@ -30,8 +30,12 @@ use metal2vulkan::metal::{PixelFormat, TextureUsage};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// The bytes one fill of the long work writes.
|
||||
const FILL_BYTES: u64 = 64 << 20;
|
||||
/// The bytes one fill of the long work writes: few fills make it on a fast GPU, so the host's
|
||||
/// share of the long command buffer (its fills' encoding, planning and submission, before its
|
||||
/// pass's batch reaches its gate) stays small whatever the GPU's speed. At 64 MiB the RX 7900 XTX's
|
||||
/// calibration took about 1400 fills, and on that loaded suite leg the long one read `Scheduled`
|
||||
/// 12.6 and 17.1 ms after its commit, its follower 0.35 and 2.2 ms after its own.
|
||||
const FILL_BYTES: u64 = 256 << 20;
|
||||
|
||||
/// The long work's length the fills are calibrated to, in seconds.
|
||||
const LONG: f64 = 0.1;
|
||||
@@ -77,7 +81,7 @@ impl Run {
|
||||
|
||||
/// The fills that take about [`LONG`] of `queue`'s GPU.
|
||||
fn long_fills(queue: &CommandQueue, target: &Buffer) -> usize {
|
||||
let mut fills = 64;
|
||||
let mut fills = 16;
|
||||
for _ in 0..3 {
|
||||
let command_buffer = queue.command_buffer().unwrap();
|
||||
let mut blit = command_buffer.blit_command_encoder().unwrap();
|
||||
@@ -88,7 +92,7 @@ fn long_fills(queue: &CommandQueue, target: &Buffer) -> usize {
|
||||
command_buffer.commit().unwrap();
|
||||
command_buffer.wait_until_completed_for(WAIT).unwrap();
|
||||
let gpu = command_buffer.gpu_end_time().unwrap() - command_buffer.gpu_start_time().unwrap();
|
||||
fills = ((fills as f64 * LONG / gpu.max(1e-6)) as usize).clamp(8, 4096);
|
||||
fills = ((fills as f64 * LONG / gpu.max(1e-6)) as usize).clamp(2, 4096);
|
||||
}
|
||||
fills
|
||||
}
|
||||
@@ -126,10 +130,12 @@ fn long(work: &Workload, big: &Buffer, fills: usize, counted: bool) -> CommandBu
|
||||
command_buffer
|
||||
}
|
||||
|
||||
/// Commit `long`, then wait until its pass's batch waits at its gate.
|
||||
fn commit_to_its_gate(work: &Workload, long: &CommandBuffer) {
|
||||
/// Commit `long`, then wait until its pass's batch waits at its gate: the host time its commit
|
||||
/// returned.
|
||||
fn commit_to_its_gate(work: &Workload, long: &CommandBuffer) -> f64 {
|
||||
let before = work.device.work_counts();
|
||||
long.commit().unwrap();
|
||||
let returned = crate::host_time();
|
||||
let began = Instant::now();
|
||||
while work.device.work_counts().heads_waiting_at_their_gate
|
||||
== before.heads_waiting_at_their_gate
|
||||
@@ -140,6 +146,7 @@ fn commit_to_its_gate(work: &Workload, long: &CommandBuffer) {
|
||||
);
|
||||
std::thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
returned
|
||||
}
|
||||
|
||||
/// Commit the long command buffer, wait until its pass's batch waits at its gate, then commit the
|
||||
@@ -228,8 +235,9 @@ fn an_unshared_queue_s_fill_does_not_wait_for_another_queue_s_host_step() {
|
||||
/// One run of [`command_buffers_behind_a_waiting_step_read_scheduled`]'s: host times, in seconds
|
||||
/// of `host_time`'s clock.
|
||||
struct Early {
|
||||
/// The long command buffer's commit was called, and its kernel end (made `Scheduled`).
|
||||
long: (f64, f64),
|
||||
/// The long command buffer's commit was called, returned, and its kernel end (made
|
||||
/// `Scheduled`).
|
||||
long: (f64, f64, f64),
|
||||
/// The follower's commit was called, its submission handler ran, and its
|
||||
/// `wait_until_scheduled` returned.
|
||||
follower: (f64, f64, f64),
|
||||
@@ -243,15 +251,18 @@ struct Early {
|
||||
}
|
||||
|
||||
impl Early {
|
||||
/// Whether the follower was committed at least half the long work before it ended: else the
|
||||
/// test's thread came late (a loaded host), and the run shows nothing.
|
||||
/// Whether the follower was committed at least twice [`SCHEDULED`] before the long work
|
||||
/// ended, by this run's own times: a command buffer that read `Scheduled` only once the long
|
||||
/// work ended would then read it past the bound, so the run tells the two apart. Else the
|
||||
/// test's thread came late (a loaded host), or the long work ran short of its calibration,
|
||||
/// and the run shows nothing.
|
||||
fn early(&self) -> bool {
|
||||
self.long_end - self.follower.0 > LONG / 2.0
|
||||
self.long_end - self.follower.0 > 2.0 * SCHEDULED
|
||||
}
|
||||
|
||||
/// The time from the long one's commit to its `Scheduled`.
|
||||
fn long_scheduled(&self) -> f64 {
|
||||
self.long.1 - self.long.0
|
||||
self.long.2 - self.long.0
|
||||
}
|
||||
|
||||
/// The time from the follower's commit to its `Scheduled`.
|
||||
@@ -271,7 +282,7 @@ fn early_run(work: &Workload, (big, small): (&Buffer, &Buffer), fills: usize) ->
|
||||
let long = long(work, big, fills, false);
|
||||
let before = work.device.work_counts();
|
||||
let long_committed = crate::host_time();
|
||||
commit_to_its_gate(work, &long);
|
||||
let long_returned = commit_to_its_gate(work, &long);
|
||||
let follower = work.queue.command_buffer().unwrap();
|
||||
let mut blit = follower.blit_command_encoder().unwrap();
|
||||
blit.fill_buffer(small, 0..256, 1).unwrap();
|
||||
@@ -291,7 +302,7 @@ fn early_run(work: &Workload, (big, small): (&Buffer, &Buffer), fills: usize) ->
|
||||
let after = work.device.work_counts();
|
||||
let handler = (*handled.lock().unwrap()).expect("the follower's submission handler ran");
|
||||
Early {
|
||||
long: (long_committed, long.kernel_end_time()),
|
||||
long: (long_committed, long_returned, long.kernel_end_time()),
|
||||
follower: (committed, handler, scheduled),
|
||||
times: [
|
||||
follower.kernel_start_time(),
|
||||
@@ -311,8 +322,9 @@ fn early_run(work: &Workload, (big, small): (&Buffer, &Buffer), fills: usize) ->
|
||||
/// behind a GPU hang so, `command_buffer/hang.rs`): Metal's are `Scheduled` once their
|
||||
/// dependencies are resolved. Before, each read so with its last batch, after the long work. The
|
||||
/// follower's times stay in its life's order: its commit, kernel start and end, GPU start and end
|
||||
/// (`gpu_time.rs`). Of [`RUNS`] runs, the one whose later of the two read `Scheduled` soonest: on
|
||||
/// lavapipe the first run's long one read it 25.5 ms after its commit, the later runs' 1.9 ms.
|
||||
/// (`gpu_time.rs`). Of [`RUNS`] runs that each tell the two apart ([`Early::early`]), the one
|
||||
/// whose later of the two read `Scheduled` soonest: on lavapipe the first run's long one read it
|
||||
/// 25.5 ms after its commit, the later runs' 1.9 ms.
|
||||
#[test]
|
||||
fn command_buffers_behind_a_waiting_step_read_scheduled() {
|
||||
let scratch = Scratch::new("held-step-scheduled");
|
||||
@@ -326,9 +338,11 @@ fn command_buffers_behind_a_waiting_step_read_scheduled() {
|
||||
.inspect(|run| {
|
||||
let since = |at: f64| (at - run.follower.0) * 1e3;
|
||||
println!(
|
||||
"the long one Scheduled {:.2} ms after its commit; the follower committed at 0, \
|
||||
its handler at {:.2} ms, Scheduled at {:.2} ms, its kernel end {:.2} ms; the \
|
||||
long work's end {:.2} ms; {} made Scheduled behind the step",
|
||||
"{fills} fills: the long one's commit returned {:.2} ms after its call, Scheduled \
|
||||
{:.2} ms after it; the follower committed at 0, its handler at {:.2} ms, \
|
||||
Scheduled at {:.2} ms, its kernel end {:.2} ms; the long work's end {:.2} ms; {} \
|
||||
made Scheduled behind the step",
|
||||
(run.long.1 - run.long.0) * 1e3,
|
||||
run.long_scheduled() * 1e3,
|
||||
since(run.follower.1),
|
||||
since(run.follower.2),
|
||||
@@ -339,7 +353,7 @@ fn command_buffers_behind_a_waiting_step_read_scheduled() {
|
||||
})
|
||||
.filter(Early::early)
|
||||
.min_by(|a, b| a.scheduled().total_cmp(&b.scheduled()))
|
||||
.expect("a run committed the follower before half the long work ran");
|
||||
.expect("a run committed the follower twice the bound before the long work ended");
|
||||
assert!(
|
||||
run.long_scheduled() < SCHEDULED,
|
||||
"the long one read Scheduled while its step waited"
|
||||
|
||||
@@ -450,6 +450,14 @@ fn a_presenting_queue_s_lock_holds_no_other_queue_where_the_device_reserved_one(
|
||||
/// ([`a_queue_joining_another_s_busy_vk_queue_is_announced_once`]).
|
||||
pub(super) const QUEUE_SHARING: [Degradation; 1] = [Degradation::QueueSharing];
|
||||
|
||||
/// The rounds [`a_queue_joining_another_s_busy_vk_queue_is_announced_once`] makes at least, each a
|
||||
/// joiner of its own, so that more than one queue may join.
|
||||
const JOINERS: usize = 3;
|
||||
|
||||
/// The rounds [`a_queue_joining_another_s_busy_vk_queue_is_announced_once`] makes at most, where
|
||||
/// the device shares and no queue joined yet.
|
||||
const JOIN_ROUNDS: usize = 16;
|
||||
|
||||
/// A command queue that makes a command buffer while it holds no other uncompleted one, beside a
|
||||
/// queue whose short command buffers keep its `VkQueue` busy, joins that `VkQueue` where the device
|
||||
/// shares (`QueueSharingPolicy::Adaptive`, set here over the lane's `exact_answers()`, on a device
|
||||
@@ -457,6 +465,15 @@ pub(super) const QUEUE_SHARING: [Degradation; 1] = [Degradation::QueueSharing];
|
||||
/// `queue-sharing` once however many queues join: each notice a join (`WorkCounts::queue_joins`,
|
||||
/// above 0 where the device shares), never one without. On a device that shares no `VkQueue`
|
||||
/// (lavapipe, RADV, MoltenVK) nothing joins and nothing is announced, and the test says why.
|
||||
///
|
||||
/// A joiner joins only where it looks while the busy `VkQueue` still has a batch in flight whose
|
||||
/// oldest has run under half a millisecond (`queue_share.rs`), and the busy queue's 24 fills are
|
||||
/// about that much of an RTX 3090's work: on a loaded host the test's thread or the completions'
|
||||
/// can miss that window (`WorkCounts::picks_with_none_busy`,
|
||||
/// `WorkCounts::joins_withheld_from_old_heads`), or a fill sliced between other processes' work
|
||||
/// can mark the busy queue long for good (`WorkCounts::queues_gone_long`). So each of
|
||||
/// [`JOIN_ROUNDS`] rounds, at least [`JOINERS`] of them, takes a busy queue and a joiner of its own,
|
||||
/// until a queue joined; the failure names what each look found.
|
||||
#[test]
|
||||
fn a_queue_joining_another_s_busy_vk_queue_is_announced_once() {
|
||||
use metal2vulkan_runtime::ResourceOptions;
|
||||
@@ -498,26 +515,37 @@ fn a_queue_joining_another_s_busy_vk_queue_is_announced_once() {
|
||||
command_buffer.commit().unwrap();
|
||||
command_buffer
|
||||
};
|
||||
let busy = device.new_command_queue().unwrap();
|
||||
let joiners: Vec<CommandQueue> = (0..3)
|
||||
.map(|_| device.new_command_queue().unwrap())
|
||||
.collect();
|
||||
for joiner in &joiners {
|
||||
let mut rounds = 0;
|
||||
while rounds < JOINERS
|
||||
|| (shares && rounds < JOIN_ROUNDS && device.work_counts().queue_joins == 0)
|
||||
{
|
||||
rounds += 1;
|
||||
let (busy, joiner) = (
|
||||
device.new_command_queue().unwrap(),
|
||||
device.new_command_queue().unwrap(),
|
||||
);
|
||||
let kept: Vec<CommandBuffer> = (0..24).map(|_| fill(&busy)).collect();
|
||||
// Submitted, so the busy `VkQueue` has work in flight as the joiner makes its own.
|
||||
kept.last().unwrap().wait_until_scheduled().unwrap();
|
||||
let joined = fill(joiner);
|
||||
let joined = fill(&joiner);
|
||||
joined.wait_until_completed_for(WAIT).unwrap();
|
||||
for command_buffer in kept {
|
||||
command_buffer.wait_until_completed_for(WAIT).unwrap();
|
||||
}
|
||||
}
|
||||
let joins = device.work_counts().queue_joins;
|
||||
assert_eq!(
|
||||
joins > 0,
|
||||
shares,
|
||||
"{joins} joins where the device shares: {shares}"
|
||||
let counts = device.work_counts();
|
||||
let joins = counts.queue_joins;
|
||||
let found = format!(
|
||||
"{joins} joins in {rounds} rounds where the device shares: {shares}; looks that found \
|
||||
no other VkQueue busy {}, that passed over a busy one's old oldest batch {}, or an \
|
||||
unshared queue's {}; queues gone long {}",
|
||||
counts.picks_with_none_busy,
|
||||
counts.joins_withheld_from_old_heads,
|
||||
counts.joins_withheld_from_unshared,
|
||||
counts.queues_gone_long
|
||||
);
|
||||
println!("{}: {found}", device.name());
|
||||
assert_eq!(joins > 0, shares, "{found}");
|
||||
assert_eq!(
|
||||
sharing_kinds(),
|
||||
usize::from(joins > 0),
|
||||
|
||||
Reference in new issue
Block a user