submit_stalls_idle: frames until a stall is taken idle or six periods of calls passed
The 5080 check of the stall fix (b5080 entry stallfix-233857) passed alone once of twice. The probe entry stallprobe2-010023 (aed3f80c65, every signalling call of 0.5 ms or more with its count) shows why: with the scheduler merging ready batches, 200 frames made 1686 to 1882 signalling calls; the 32nd and the 784th stalled (the period's count is forgotten across the device's uncounted uses of the queue before then), so the first stall due idle was the 1808th call, past the end of the run that failed (1686 calls: two stalls on work, none idle). The runs that reached it took it idle (the 1808th, an empty call, 2.7 and 3.6 ms of thread CPU). The test now runs frames, on a driver with the stall, until a stall was taken idle or the device's calls to its queues passed six periods (at most 2000 frames), and asserts as before; a driver without the stall runs its 200 frames and makes no empty submission. The product is unchanged. Verification: pending (b5080 c entry). (cherry picked from commit e50d699573d7b1e7a206ecec8ea7ec0cd60e1d03)
This commit is contained in:
1 parent
6962de9cdc
commit
26c06a4bca
1 file changed
+48
-19
@@ -5,18 +5,35 @@
|
||||
//! 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.
|
||||
|
||||
use crate::{CommandQueue, Device, DeviceKind, DeviceOptions, ResourceOptions, ShaderCacheOptions};
|
||||
use crate::device::submit_stalls::{MARGIN, PERIOD};
|
||||
use crate::{
|
||||
CommandQueue, Device, DeviceKind, DeviceOptions, ResourceOptions, ShaderCacheOptions,
|
||||
WorkCounts,
|
||||
};
|
||||
use metal2vulkan::device::DriverFact;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
||||
/// The frames, and each frame's command buffers, at the 25 command buffers a frame `host_ab
|
||||
/// present` commits: about five of the driver's periods of 1024 signalling submissions where each
|
||||
/// batch takes a call of its own, about two on the RTX 5080, where the scheduler merges the
|
||||
/// batches it finds ready together (2190 to 2500 signalling calls a run there).
|
||||
/// The frames on a driver without the stall, and each frame's command buffers, at the 25 command
|
||||
/// buffers a frame `host_ab present` commits: about five of the driver's periods of 1024
|
||||
/// signalling submissions where each batch takes a call of its own.
|
||||
const FRAMES: u32 = 200;
|
||||
const PER_FRAME: u32 = 25;
|
||||
|
||||
/// The device's calls to its queues after which a driver with the stall must have had one taken
|
||||
/// idle: [`PERIOD`] times this. Frames go on until a stall was taken idle or the calls passed it,
|
||||
/// for the calls a frame makes vary: where the scheduler merges the batches it finds ready
|
||||
/// together (the RTX 5080, 615.71.09), 200 frames made 1686 to 1882 signalling calls in three
|
||||
/// runs, and a stall is first due idle only a period after the second the runtime saw, which
|
||||
/// follows uses of the queue it does not count (in those runs the 32nd and the 784th signalling
|
||||
/// call stalled, so the first due idle was the 1808th, past the end of one run;
|
||||
/// `device/submit_stalls.rs`).
|
||||
const PERIODS: u64 = 6;
|
||||
|
||||
/// The most frames a driver with the stall runs: they reach [`PERIODS`] periods of calls at 3.1
|
||||
/// calls a frame or more (the RTX 5080 made about 9).
|
||||
const MOST_FRAMES: u32 = 2000;
|
||||
|
||||
/// The gap after each frame: longer than the idle the scheduler's thread waits for before it
|
||||
/// takes a stall due (`IDLE_NANOS`), with room for the stall itself.
|
||||
const GAP: Duration = Duration::from_millis(8);
|
||||
@@ -59,11 +76,12 @@ fn device(scratch: &Scratch) -> Device {
|
||||
Device::system_default_with(&options).unwrap()
|
||||
}
|
||||
|
||||
/// [`FRAMES`] frames of [`PER_FRAME`] command buffers of `queue`, each a fill of 16 bytes,
|
||||
/// committed back to back, the last waited for, then [`GAP`] with nothing committed.
|
||||
fn frames(device: &Device, queue: &CommandQueue) {
|
||||
/// Frames of [`PER_FRAME`] command buffers of `queue`, each a fill of 16 bytes, committed back to
|
||||
/// back, the last waited for, then [`GAP`] with nothing committed: at most `most`, and none once
|
||||
/// `done` answers true of the device's counts after a frame.
|
||||
fn frames(device: &Device, queue: &CommandQueue, most: u32, done: impl Fn(&WorkCounts) -> bool) {
|
||||
let target = device.new_buffer(16, ResourceOptions::shared()).unwrap();
|
||||
for frame in 0..FRAMES {
|
||||
for frame in 0..most {
|
||||
let mut last = None;
|
||||
for _ in 0..PER_FRAME {
|
||||
let command_buffer = queue.command_buffer().unwrap();
|
||||
@@ -77,13 +95,17 @@ fn frames(device: &Device, queue: &CommandQueue) {
|
||||
last.wait_until_completed().unwrap();
|
||||
assert_eq!(last.error(), None);
|
||||
std::thread::sleep(GAP);
|
||||
if done(&device.work_counts()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Over about five periods of frames with idle gaps between them: on a driver with the stall,
|
||||
/// the scheduler took at least one stall in a gap, by empty submissions that took at most the
|
||||
/// burst and the margin a stall (`WorkCounts::submit_stalls_idle`, `WorkCounts::idle_submits`);
|
||||
/// on every other driver it made no empty submission. The counts are printed either way.
|
||||
/// Frames with idle gaps between them: on a driver with the stall, the scheduler took a stall in
|
||||
/// a gap within [`PERIODS`] periods of the device's calls to its queues, by empty submissions
|
||||
/// that took at most the burst and the margin a stall (`WorkCounts::submit_stalls_idle`,
|
||||
/// `WorkCounts::idle_submits`); on every other driver, over [`FRAMES`] frames, it made no empty
|
||||
/// submission. The counts are printed either way.
|
||||
#[test]
|
||||
fn the_scheduler_takes_the_driver_s_stalls_while_idle_only_where_the_driver_has_them() {
|
||||
let scratch = Scratch::new();
|
||||
@@ -92,28 +114,35 @@ fn the_scheduler_takes_the_driver_s_stalls_while_idle_only_where_the_driver_has_
|
||||
let stalls =
|
||||
(device.properties().driver_facts).contains(&DriverFact::SignallingSubmitsStallEvery1024);
|
||||
let before = device.work_counts();
|
||||
frames(&device, &queue);
|
||||
let calls = |counts: &WorkCounts| counts.queue_submissions - before.queue_submissions;
|
||||
let bound = PERIODS * u64::from(PERIOD);
|
||||
match stalls {
|
||||
true => frames(&device, &queue, MOST_FRAMES, |counts| {
|
||||
counts.submit_stalls_idle > before.submit_stalls_idle || calls(counts) >= bound
|
||||
}),
|
||||
false => frames(&device, &queue, FRAMES, |_| false),
|
||||
}
|
||||
let after = device.work_counts();
|
||||
let idle_submits = after.idle_submits - before.idle_submits;
|
||||
let idle = after.submit_stalls_idle - before.submit_stalls_idle;
|
||||
let on_work = after.submit_stalls_on_work - before.submit_stalls_on_work;
|
||||
let behind = after.submits_behind_idle_stalls - before.submits_behind_idle_stalls;
|
||||
println!(
|
||||
"{}: driver stalls every 1024th signalling submit: {stalls}; over {} command buffers: \
|
||||
"{}: driver stalls every 1024th signalling submit: {stalls}; over {} calls to its queues: \
|
||||
idle_submits {idle_submits} submit_stalls_idle {idle} submit_stalls_on_work {on_work} \
|
||||
submits_behind_idle_stalls {behind} wait_behind_idle_stall_longest_nanos {}",
|
||||
device.name(),
|
||||
FRAMES * PER_FRAME,
|
||||
calls(&after),
|
||||
after.wait_behind_idle_stall_longest_nanos,
|
||||
);
|
||||
match stalls {
|
||||
true => {
|
||||
assert!(
|
||||
idle >= 1,
|
||||
"no stall was taken idle over {} command buffers",
|
||||
FRAMES * PER_FRAME
|
||||
"no stall was taken idle over {} calls to the device's queues",
|
||||
calls(&after)
|
||||
);
|
||||
let most = idle * u64::from(PER_FRAME + crate::device::submit_stalls::MARGIN);
|
||||
let most = idle * u64::from(PER_FRAME + MARGIN);
|
||||
assert!(idle_submits <= most, "{idle_submits} empty submissions");
|
||||
}
|
||||
false => {
|
||||
|
||||
Reference in new issue
Block a user