diff --git a/crates/metal2vulkan-runtime/examples/host_ab/main.rs b/crates/metal2vulkan-runtime/examples/host_ab/main.rs index 43de9ebe1..3e0e2913f 100644 --- a/crates/metal2vulkan-runtime/examples/host_ab/main.rs +++ b/crates/metal2vulkan-runtime/examples/host_ab/main.rs @@ -240,7 +240,7 @@ use gpu::Gpu; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; -use std::time::Instant; +use std::time::{Duration, Instant}; use workloads::Sizes; const WORKLOADS: [&str; 21] = [ @@ -406,7 +406,7 @@ fn child(side: &str, options: &Options) { #[cfg(target_os = "macos")] "native" => { let native = native::Native::open(); - run(&native, t, metallib, options); + run(&native, t.elapsed(), metallib, options); } "runtime" => { let cache = options @@ -415,7 +415,9 @@ fn child(side: &str, options: &Options) { .unwrap_or_else(|| scratch_default().join("cache")); let runtime = runtime::Runtime::open(&cache, &options.announce_each, options.sink_least); - run(&runtime, t, metallib, options); + let opened = t.elapsed(); + runtime.settle_checks(); + run(&runtime, opened, metallib, options); let c = runtime.device().work_counts(); eprintln!( "runtime work counts: queue_submissions {} command_buffers_submitted {} \ @@ -487,12 +489,13 @@ fn child(side: &str, options: &Options) { } } -fn run(g: &G, opened: Instant, metallib: &Path, options: &Options) { +/// Run the selected workloads on `g`, whose device took `opened` to open. +fn run(g: &G, opened: Duration, metallib: &Path, options: &Options) { workloads::emit( "meta", "device_open", "ms", - &mut [opened.elapsed().as_secs_f64() * 1e3], + &mut [opened.as_secs_f64() * 1e3], ); eprintln!("{}", g.label()); let sizes = &options.sizes; diff --git a/crates/metal2vulkan-runtime/examples/host_ab/percall.rs b/crates/metal2vulkan-runtime/examples/host_ab/percall.rs index 8fe1f6200..ca1a05d22 100644 --- a/crates/metal2vulkan-runtime/examples/host_ab/percall.rs +++ b/crates/metal2vulkan-runtime/examples/host_ab/percall.rs @@ -5,7 +5,9 @@ //! times; then drains the state, committing and waiting where the calls encoded work. Three //! warm windows run first, and every pipeline state, library and texture the groups bind is made //! before any of them, so no making falls inside a timed window (the `variant_pipelines_made` -//! count a group reports is the proof). +//! count a group reports is the proof); and the runtime's device's own checks answered before +//! any workload (`runtime.rs`'s `Runtime::settle_checks`), so none of their work, which the +//! device counts as its own, falls inside one either. //! //! Per call a group reports //! diff --git a/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs b/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs index 8188ea91c..047c9fd2b 100644 --- a/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs +++ b/crates/metal2vulkan-runtime/examples/host_ab/runtime.rs @@ -2,7 +2,9 @@ //! finds (MoltenVK on a Mac). The device is opened as the consumer opens it (reims-vgpu's //! `device_options`): GPU times from the host's clock, the exact completion and uncompressed heap //! textures, the rest of the policy at its defaults, the shader cache in a directory of the -//! bench's own. +//! bench's own. It is then held until the device's own checks answered +//! ([`Runtime::settle_checks`]), as a consumer's device that reads their verdicts from its cache's +//! records knows them as it is made. use crate::gpu::{Format, Gpu}; use metal2vulkan::bind::SamplerDescriptor; @@ -19,6 +21,7 @@ use metal2vulkan_runtime as rt; use std::path::Path; use std::ptr::NonNull; use std::sync::atomic::{AtomicU64, Ordering}; +use std::time::{Duration, Instant}; /// The degradation notices the runtime's device announced. pub static NOTICES: AtomicU64 = AtomicU64::new(0); @@ -26,6 +29,9 @@ pub static NOTICES: AtomicU64 = AtomicU64::new(0); /// The other messages the runtime's device's sink heard. pub static MESSAGES: AtomicU64 = AtomicU64::new(0); +/// How long [`Runtime::settle_checks`] waits for each of the device's checks to answer. +const SETTLE: Duration = Duration::from_secs(30); + pub struct Runtime { device: rt::Device, queue: rt::CommandQueue, @@ -59,6 +65,40 @@ impl Runtime { Runtime { device, queue } } + /// Wait until the device's own checks answered: of textures over host pages in place, of its + /// submissions and of its queue switch. Each runs once per driver on a thread of its own, its + /// verdicts kept in the shader cache's records, and the bench's cache is a new directory of + /// each run's unless `--cache` names one, so each would else run beside the workloads: its + /// work, which the device counts as its own, in whichever call's window it fell (the in-place + /// check, which the first texture over a buffer in exported memory starts, makes and binds + /// its images on its thread for as long as it runs), and the calls before its verdicts taking + /// another path than those after. A consumer's device that read the verdicts from its cache's + /// records runs none of them, and so is the device every workload is measured on. How long + /// they took is reported apart from the device's opening (`meta device_checks`, ms); a check + /// that did not answer within [`SETTLE`] is named on stderr, and the run goes on. + pub fn settle_checks(&self) { + let started = Instant::now(); + let settled = [ + ("in-place", self.device.settle_in_place_checks(SETTLE)), + ("submission", self.device.settle_submit_checks(SETTLE)), + ( + "queue switch", + self.device.settle_queue_switch_check(SETTLE), + ), + ]; + crate::workloads::emit( + "meta", + "device_checks", + "ms", + &mut [started.elapsed().as_secs_f64() * 1e3], + ); + for (check, answered) in settled { + if !answered { + eprintln!("runtime: the device's {check} check did not answer within {SETTLE:?}"); + } + } + } + pub fn device(&self) -> &rt::Device { &self.device }