host_ab: the runtime's device's checks answer before any workload, so no call's window holds their work

host_ab's runtime side now opens the device, times the open, and then waits for the device's
in-place, submission and queue-switch checks (Runtime::settle_checks) before the first workload.
It reports that wait as `meta device_checks` (ms), apart from `meta device_open`. A check that
does not answer within 30 s is named on stderr, and the run goes on.

Why: the RTX 5080's percall failed about one run in three. Row buffer_texture_256 read
rt_vk_images_made_at_call and rt_vk_image_bindings_at_call at 1.0625 or 1.125 against their bound
of 1. The maker is the device's in-place check (in_place_check.rs, thread m2v-in-place-check).
On the 5080 the first texture over a buffer in exported memory starts it: buffer_texture_256's
first warm call, whose Buffer::new_texture over the group's buffer asks a pending verdict
(texture.rs's exported_takes). The check then makes and binds its probe images on its own thread
(in_place_image.rs) for as long as it runs. The device counts that work as its own
(Counted::AsTheDevice), so the group's counting window read it whenever the two overlapped. A
probe build that named the thread of every making off the program's threads, and marked each
window, showed the check's images inside buffer_texture_256's counting window in 5 of 8 runs.
Only some runs fail because it depends on where the check's run falls against that window.

host_ab's shader cache is a new directory each run, so the check ran in every run. A consumer's
device reads the verdicts from its cache's records as it is made and runs no check; settling the
checks first measures that device. The calls after the verdicts can take another path than the
calls before them. On the 5080, each texture_256_shared call then found a pool growing and
read the list of its blocks made ahead (memory/ready.rs's held), one allocation a call. A later
commit sums those bytes in place.

Verified (release host_ab, the same metallib, development 58c3147007 against this tree with the
later commits of this branch):
- RTX 5080 Laptop (nvidia ICD, three b5080 entries, base and this branch in turn in each):
  base failed 11 of 40 runs (buffer_texture_256 images and bindings 1.0625 to 1.125 a call).
  This branch failed 0 of 40: 24 runs without the held-bytes commit and 16 with it. Every
  other row was within its bound in every run.
- lavapipe and the 780M PHOENIX (radeon ICD, 1002:15bf!), 6 runs each: no row moved up, and
  every row is within its bound on both, except PHOENIX heap_texture_256 allocs. That row is
  over its bound at base and here (79.25 and 75.25 a call against 17.25): the heap-tiled path,
  handed to the orchestrator.
- device_checks: 5080 606 to 793 ms, lavapipe 532 to 2954 ms, PHOENIX 490 to 540 ms.
- clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc -D warnings clean on Linux.
This commit is contained in:
Anees Iqbal committed 2026-11-11 06:16:11 -08:00
1 parent d95f5c099d
commit f3aee27ec8
3 files changed
+52 -7

No files matched your search

@@ -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: Gpu>(g: &G, opened: Instant, metallib: &Path, options: &Options) {
/// Run the selected workloads on `g`, whose device took `opened` to open.
fn run<G: Gpu>(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;
@@ -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
//!
@@ -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
}