The validation executor's Vulkan side runs on Linux through native ICDs and the runtime. No lane records MoltenVK rows any more, and no MoltenVK venue is wanted. This commit deletes the MoltenVK backend from the store up. Before the deletion, git grep ate35d9098c0showed these readers of Backend::Moltenvk rows outside tests: - C3's input (c3.rs: C3Input::moltenvk, the baseline, the old-mismatch ledger), its venue kind (venues.rs), the evidence census (index.rs: the index's candidate table and evidence_status); - the store's own layout check, shard rewrite and rekey; - the batch's worker store, which linked the other backend's rows; - the corpus-moltenvk binary, the host and driver checks (candidate.rs, platform/compute.rs) and candidate_batch's CPU refusal. Every one goes or loses its MoltenVK arm here. No reader is left. What goes: - The corpus-moltenvk binary (Cargo.toml entry included), and Backend::Moltenvk and BatchBackend::Moltenvk. Backend keeps one variant, Vulkan. Collapsing it is a follow-up commit. - corpus/observations/moltenvk: 64 shards, 4,809 rows. 4,802 of them are old-engine rows in about 60 slots: apple-m3-max-moltenvk 1,137, the byte-exact-* and local-* runs, and probe slots. The other 7 are engine rows of apple-m3-max-moltenvk@engine. corpus/observations/refusals/moltenvk: 16 shards, 6 refusals. - The store's MoltenVK shards: its layout check, the aligned rewrite, the refusal follow and the rekey now read the Vulkan backend alone. The batch's worker store links only the Metal rows. The index stores the Vulkan candidates alone, and evidence_status's rows have no moltenvk column (corpus-status's evidence line loses it too). - C3's MoltenVK venue (VenueKind::Moltenvk, c3-venues.json's apple-m3-max-moltenvk entry) and with it the old engine's baseline: - Population::OldEngineMatched, the baseline closure and the "new mismatch" count (SlotReport::new_mismatches); - the old-mismatch ledger (LedgerRow, C3Report::ledger, stale_causes, unexplained); - the reviewed list's old_mismatches part (OldMismatch, ListPart, EntryRow::part), and Venues::baseline and by_environment. The venue list's MoltenVK-driver check goes too. VenueDevice's metal_environment_id, which only an Apple GPU's venue device set, goes with Venue::identities_compared_with: a venue run is held to all of its devices' identities. - c3-reviewed.json: the 12 old_mismatches entries (all signed off), and the 10 fast_math_regrouping readings whose only observation was the apple-m3-max-moltenvk@engine slot. These are the linked-single radix 5/7/11/13/15 zero-write cases, two each, all signed off. A reading must list an observation, and theirs named a slot that no longer exists. A regrouping mismatch of those cases on another venue now reads unreviewed until a reading lists that venue's row. The 12 apple_reading entries are untouched; none named a MoltenVK slot. - corpus/authored-compile.tsv: the moltenvk-m3 column keeps its cells but drops their artifact digests (2,255 cells). Only a C3 venue's profile keeps a digest, and moltenvk-m3 is no venue's now. This is what a bless writes; the profile itself stays, since the translator's tests read it. - scripts/rerecord-venue's moltenvk kind (and its Homebrew validation layer path), and scripts/rerecord-commit's MoltenVK build, install and shard paths. docs/VALIDATION.md loses corpus-moltenvk, and its venue list names what each venue covers. - In the docs, the robustness leg's "profile-leg" (validation README, corpus README) is now "profile", which79d95a2887missed. What C3 still decides: per venue of c3-venues.json, lavapipe on arm64 and x86 (the public cases) and the 780M, the Iris Xe RPL-P and the RTX 5080 Laptop (every Metal-qualified case), each case's verdict in the venue's engine slot by the same rules as before (match, reviewed, device_gap, out_of_scope, reference_gap, mismatch, refused, stale, missing). It holds when every slot holds, every reviewed observation holds, every listed reference gap is recorded, every entry and recorded reference gap is signed off, and no sign-off is refused. It no longer holds anything to an old-engine population, counts new mismatches against one, or keeps a ledger of old-engine mismatch causes. Tests: - c3/tests.rs: the synthetic MoltenVK venue becomes a native GPU venue (GPU, Metal-qualified, still described by the moltenvk-m3 capture). Deleted: the baseline test (moltenvk_must_cover_every_case...), the ledger test, and the Apple-GPU Metal-environment test. Rewritten: the population tests (two populations now) and the reference-gap test (on lavapipe's public population). The schema test checks its review fields on a reading. The venue checks lose the baseline and driver cases. - index.rs and store.rs tests run their toy rows as Vulkan's. The cross-backend checks have no second backend and go. - vulkan_batch/tests.rs: the MoltenVK batch test goes. The install test refuses a Metal batch's record in place of a MoltenVK one. - tests/integration: the store-layout and worker tests drop corpus-moltenvk. fast_trig_within_apples_bound reads the Vulkan store and wants one row per venue (5). It wanted 10, which the robustness-off and MoltenVK rows made up. Device-level MoltenVK accommodations stay for the follow-up commit with the MSL helper, once a grep shows no Vulkan run on macOS: the loader word, MoltenVK's withheld diagnostics, coverage's robust-buffer host class and the pipeline flag. Verified: cargo fmt; no committed observation path, C3 list entry, venue or script names the MoltenVK backend (git grep). The compile gate of the Q3 commits follows as a potluck job.
357 lines
14 KiB
Rust
357 lines
14 KiB
Rust
//! The engine compile worker across a real process boundary: every validation binary that
|
|
//! compiles engine pipelines for a device serves the worker, and what comes back through the
|
|
//! pipeline's cache artifact bytes is the pipeline the public API compiles in process. A pipeline
|
|
//! holding a constant blob crosses it without the worker copying the blob.
|
|
|
|
use metal2vulkan::device::DevicePolicy;
|
|
use metal2vulkan::library::FunctionConstantValues;
|
|
use metal2vulkan::pipeline::ComputePipeline;
|
|
use metal2vulkan_devtools::{engine_dir, llvm_assemble, AssembleError};
|
|
use metal2vulkan_validation::acceptance::{
|
|
compile_draw_in_worker, compile_pipeline, compile_row_in_worker, retained, row,
|
|
AcceptancePipeline, PipelineRequest, Projection, RequestFunction, RowCompile, RowPipeline,
|
|
RowStage,
|
|
};
|
|
use metal2vulkan_validation::engine::{load_description, RowSource};
|
|
use metal2vulkan_validation::worker::compile::{
|
|
compile_compute, CompileWorker, NotCompiled, WorkerCompile, WorkerDevice,
|
|
};
|
|
use metal2vulkan_validation::worker::{WorkerFailure, DEADLINE, MEMORY_LIMIT_BYTES};
|
|
use std::path::{Path, PathBuf};
|
|
|
|
fn fixture(name: &str) -> Option<Vec<u8>> {
|
|
match llvm_assemble(&engine_dir().join(name)) {
|
|
Ok(bytes) => Some(bytes),
|
|
Err(AssembleError::Missing(why)) => {
|
|
eprintln!("SKIPPED: {why}");
|
|
None
|
|
}
|
|
Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected {name}: {why}"),
|
|
}
|
|
}
|
|
|
|
/// `program`, executed once before any compile: the OS may scan a freshly linked binary on its
|
|
/// first exec (seconds on macOS), which the 20-s worker deadline would count. A tool's worker is
|
|
/// the tool's own executable, which has run by the time it spawns one.
|
|
fn worker(program: &Path) -> CompileWorker {
|
|
let _ = std::process::Command::new(program)
|
|
.arg("--help")
|
|
.stdout(std::process::Stdio::null())
|
|
.stderr(std::process::Stdio::null())
|
|
.status();
|
|
CompileWorker::program(program)
|
|
}
|
|
|
|
fn device(stem: &str) -> WorkerDevice {
|
|
WorkerDevice::new(load_description(stem).unwrap(), DevicePolicy::default()).unwrap()
|
|
}
|
|
|
|
/// Every binary that compiles through the worker serves it (and installs the allocator it
|
|
/// refuses to serve without).
|
|
fn serving() -> [PathBuf; 2] {
|
|
[bin_exe!("corpus-pipeline"), bin_exe!("corpus-vulkan")]
|
|
}
|
|
|
|
#[test]
|
|
fn every_device_tool_serves_the_compile_worker_with_the_public_apis_pipeline() {
|
|
let Some(bitcode) = fixture("store_const.ll") else {
|
|
return;
|
|
};
|
|
let device = device("moltenvk-m3");
|
|
let request = PipelineRequest::Compute {
|
|
entry: "store_const".into(),
|
|
constants: FunctionConstantValues::defaults(),
|
|
};
|
|
let AcceptancePipeline::Compute(expected) =
|
|
compile_pipeline(&[&bitcode], &request, device.device(), None)
|
|
.unwrap()
|
|
.pipeline
|
|
else {
|
|
panic!("a kernel compiles to a compute pipeline");
|
|
};
|
|
for path in serving() {
|
|
let program = path.display();
|
|
let worker = worker(&path);
|
|
let compiled = compile_compute(
|
|
&worker,
|
|
&device,
|
|
&retained(&bitcode),
|
|
"store_const",
|
|
&FunctionConstantValues::defaults(),
|
|
)
|
|
.unwrap_or_else(|failure| panic!("{program}: {}", failure.message()));
|
|
let compiled_pipeline = compiled.result.unwrap();
|
|
assert_eq!(compiled_pipeline.pipeline, *expected, "{program}");
|
|
assert!(compiled_pipeline.handles.is_empty(), "{program}");
|
|
assert!(
|
|
compiled.allocator_peak.is_some_and(|peak| peak > 0),
|
|
"{program}"
|
|
);
|
|
assert!(compiled.measured.elapsed < DEADLINE, "{program}");
|
|
if cfg!(any(target_os = "macos", target_os = "linux")) {
|
|
assert!(compiled.measured.peak_resident_bytes.is_some(), "{program}");
|
|
}
|
|
// The worker's report carries its counting allocator's process peak beside the sampled
|
|
// RSS: at least the compile's own peak, which it contains.
|
|
let process_peak = compiled.measured.allocator_peak_bytes;
|
|
assert!(
|
|
process_peak.is_some_and(|peak| peak >= compiled.allocator_peak.unwrap()),
|
|
"{program}: {process_peak:?}"
|
|
);
|
|
assert!(compiled.measured.peak_bytes() >= process_peak, "{program}");
|
|
}
|
|
}
|
|
|
|
/// A logged draw (`corpus-pipeline --draws`) crosses the worker boundary: the vertex and
|
|
/// fragment functions of two sources, drawn together under the logged template, come back as the
|
|
/// render pipeline the in-process compile builds, a fragment row's.
|
|
#[test]
|
|
fn a_logged_draw_compiles_in_the_worker_as_in_process() {
|
|
let Some(bitcode) = fixture("stage_io.ll") else {
|
|
return;
|
|
};
|
|
let worker = worker(&bin_exe!("corpus-pipeline"));
|
|
let device = device("moltenvk-m3");
|
|
let undefined = FunctionConstantValues::defaults();
|
|
let mut template = row::fragment_row(&bitcode, "stage_io_fragment", &undefined)
|
|
.unwrap()
|
|
.template;
|
|
template.vertex_descriptor = row::vertex_row(&bitcode, "stage_io_vertex", &undefined)
|
|
.unwrap()
|
|
.template
|
|
.vertex_descriptor;
|
|
assert!(template.vertex_descriptor.is_some());
|
|
let request = PipelineRequest::Draw {
|
|
vertex: RequestFunction::new("stage_io_vertex", undefined.clone()),
|
|
fragment: RequestFunction::new("stage_io_fragment", undefined),
|
|
template: template.clone(),
|
|
shape: None,
|
|
};
|
|
let AcceptancePipeline::Render(expected) =
|
|
compile_pipeline(&[&bitcode, &bitcode], &request, device.device(), None)
|
|
.unwrap()
|
|
.pipeline
|
|
else {
|
|
panic!("a draw compiles to a render pipeline");
|
|
};
|
|
let (compiled, measured) = compile_draw_in_worker(
|
|
&worker,
|
|
&device,
|
|
&[retained(&bitcode), retained(&bitcode)],
|
|
"stage_io_vertex",
|
|
"stage_io_fragment",
|
|
&template,
|
|
);
|
|
let RowCompile::Compiled(pipeline) = compiled else {
|
|
panic!("{compiled:?}");
|
|
};
|
|
let RowPipeline::Render {
|
|
pipeline,
|
|
row: RowStage::Fragment,
|
|
} = *pipeline
|
|
else {
|
|
panic!("a draw came back as another kind");
|
|
};
|
|
assert_eq!(pipeline.stages.len(), 2);
|
|
assert_eq!(pipeline, *expected);
|
|
assert!(measured.is_some());
|
|
}
|
|
|
|
#[test]
|
|
fn a_vertex_function_and_a_refusal_cross_the_worker_boundary() {
|
|
let Some(bitcode) = fixture("stage_io.ll") else {
|
|
return;
|
|
};
|
|
let worker = worker(&bin_exe!("corpus-pipeline"));
|
|
let device = device("moltenvk-m3");
|
|
// A vertex function that reads attributes and a fragment function, as L4 rows: the
|
|
// descriptor and the companion are derived (and the companion assembled) in the worker, and
|
|
// the render pipeline itself (not a refusal) crosses the boundary.
|
|
for (entry, stage, stages) in [
|
|
("stage_io_vertex", RowStage::Vertex, 1),
|
|
("stage_io_fragment", RowStage::Fragment, 2),
|
|
] {
|
|
let request = PipelineRequest::Row {
|
|
entry: entry.into(),
|
|
stage,
|
|
projection: Projection::Derived,
|
|
constants: FunctionConstantValues::defaults(),
|
|
};
|
|
let AcceptancePipeline::Render(expected) =
|
|
compile_pipeline(&[&bitcode], &request, device.device(), None)
|
|
.unwrap()
|
|
.pipeline
|
|
else {
|
|
panic!("{entry} compiles to a render pipeline");
|
|
};
|
|
let (compiled, measured) = compile_row_in_worker(
|
|
&worker,
|
|
&device,
|
|
&retained(&bitcode),
|
|
entry,
|
|
stage,
|
|
Projection::Derived,
|
|
&FunctionConstantValues::defaults(),
|
|
);
|
|
let RowCompile::Compiled(pipeline) = compiled else {
|
|
panic!("{entry}: {compiled:?}");
|
|
};
|
|
let RowPipeline::Render { pipeline, .. } = *pipeline else {
|
|
panic!("{entry} came back as another kind");
|
|
};
|
|
assert_eq!(pipeline, *expected);
|
|
assert_eq!(pipeline.stages.len(), stages);
|
|
assert!(measured.unwrap().elapsed < DEADLINE);
|
|
}
|
|
|
|
// The product's typed refusal comes back as its outcome, not as a worker failure.
|
|
let refused = compile_compute(
|
|
&worker,
|
|
&device,
|
|
&retained(&bitcode),
|
|
"no_such_entry",
|
|
&Default::default(),
|
|
)
|
|
.unwrap();
|
|
let Err(NotCompiled::Product(outcome, detail)) = refused.result else {
|
|
panic!("no_such_entry compiled");
|
|
};
|
|
assert_eq!(outcome.label(), "invalid_descriptor", "{detail}");
|
|
}
|
|
|
|
#[test]
|
|
fn a_program_that_does_not_serve_the_worker_is_a_worker_failure() {
|
|
let device = device("runtime-floor");
|
|
// `true` exits successfully without a result: the result cannot be read.
|
|
match compile_compute(
|
|
&CompileWorker::program("true"),
|
|
&device,
|
|
&retained(b"bitcode"),
|
|
"main",
|
|
&Default::default(),
|
|
) {
|
|
Err(failure @ WorkerFailure::Output(..)) => {
|
|
assert_eq!(failure.outcome().key(), "worker_exit")
|
|
}
|
|
other => panic!("{other:?}"),
|
|
}
|
|
// A program that cannot start is a setup failure (transient tooling).
|
|
match compile_compute(
|
|
&CompileWorker::program("/nonexistent/compile-worker"),
|
|
&device,
|
|
&retained(b"bitcode"),
|
|
"main",
|
|
&Default::default(),
|
|
) {
|
|
Err(failure @ WorkerFailure::Setup(_)) => assert!(failure.outcome().is_transient()),
|
|
other => panic!("{other:?}"),
|
|
}
|
|
}
|
|
|
|
/// A kernel reading two words of `@g`, a closed constant struct DAG `depth` levels deep
|
|
/// (`%e1 = { i32, i32 }`, `%e{k} = { %e{k-1}, %e{k-1} }`), all zero: past 14 levels `@g` is in
|
|
/// the constant blob, `2^(depth+2)` bytes (the product's `tests/constant_blob_footprint.rs`).
|
|
fn blob_kernel(depth: u32) -> String {
|
|
let mut types = String::from("%e1 = type { i32, i32 }\n");
|
|
for k in 2..=depth {
|
|
types += &format!("%e{k} = type {{ %e{p}, %e{p} }}\n", p = k - 1);
|
|
}
|
|
format!(
|
|
r#"target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
|
|
target triple = "air64_v28-apple-macosx26.0.0"
|
|
|
|
{types}@g = internal addrspace(2) constant %e{depth} zeroinitializer, align 4
|
|
|
|
define void @blob(ptr addrspace(1) %out, i32 %t) {{
|
|
%v0 = load i32, ptr addrspace(2) @g, align 4
|
|
%q = getelementptr inbounds i8, ptr addrspace(2) @g, i32 4
|
|
%v1 = load i32, ptr addrspace(2) %q, align 4
|
|
%i0 = shl i32 %t, 1
|
|
%o0 = getelementptr inbounds i32, ptr addrspace(1) %out, i32 %i0
|
|
store i32 %v0, ptr addrspace(1) %o0, align 4
|
|
%i1 = add i32 %i0, 1
|
|
%o1 = getelementptr inbounds i32, ptr addrspace(1) %out, i32 %i1
|
|
store i32 %v1, ptr addrspace(1) %o1, align 4
|
|
ret void
|
|
}}
|
|
|
|
!air.kernel = !{{!0}}
|
|
!0 = !{{ptr @blob, !1, !2}}
|
|
!1 = !{{}}
|
|
!2 = !{{!3, !4}}
|
|
!3 = !{{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"}}
|
|
!4 = !{{i32 1, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"}}
|
|
"#
|
|
)
|
|
}
|
|
|
|
/// Compile [`blob_kernel`] `depth` levels deep for `lavapipe` through `corpus-pipeline`'s compile
|
|
/// worker (the child assembles the text): the compile, and its blob's length, `2^(depth+2)`.
|
|
fn compile_blob(depth: u32) -> (WorkerCompile<ComputePipeline>, u64) {
|
|
let worker = worker(&bin_exe!("corpus-pipeline"));
|
|
let text = blob_kernel(depth);
|
|
let compiled = compile_compute(
|
|
&worker,
|
|
&device("lavapipe"),
|
|
&RowSource::Text(text.as_str().into()),
|
|
"blob",
|
|
&FunctionConstantValues::defaults(),
|
|
)
|
|
.unwrap_or_else(|failure| panic!("{depth} levels: {}", failure.message()));
|
|
let blob = match &compiled.result {
|
|
Ok(compiled) => compiled
|
|
.pipeline
|
|
.stage
|
|
.constant_blob
|
|
.as_ref()
|
|
.map_or(0, |blob| blob.len() as u64),
|
|
Err(refused) => panic!("{depth} levels: {refused:?}"),
|
|
};
|
|
assert_eq!(blob, 4 << depth, "{depth} levels");
|
|
(compiled, blob)
|
|
}
|
|
|
|
/// The worker reports a pipeline holding a constant blob without copying the blob: it writes the
|
|
/// artifact to the parent's file a chunk at a time, so its process's allocator peak passes its
|
|
/// compile's by under a quarter of the blob (4 MiB at 20 levels). Encoding the artifact whole and
|
|
/// then as base64 for the report held over twice the blob beside the pipeline.
|
|
#[test]
|
|
fn a_constant_blob_crosses_the_worker_without_a_copy() {
|
|
if fixture("store_const.ll").is_none() {
|
|
return;
|
|
}
|
|
let (compiled, blob) = compile_blob(20);
|
|
let process = compiled.measured.allocator_peak_bytes.unwrap();
|
|
let compile = compiled.allocator_peak.unwrap();
|
|
eprintln!("20 levels: process peak {process} bytes, compile peak {compile} bytes, blob {blob}");
|
|
assert!(
|
|
process < compile + blob / 4,
|
|
"process peak {process} bytes, compile peak {compile} bytes, blob {blob}"
|
|
);
|
|
}
|
|
|
|
/// The largest closed constant the ledger admits, 26 levels (a 256-MiB blob), compiles through
|
|
/// the worker boundary within its ceilings: under 500 MiB, the sampled resident set and the
|
|
/// allocator's peak alike, and within the 20-second deadline. The ceilings are release-mode
|
|
/// contracts, so this runs in release, ignored otherwise.
|
|
#[test]
|
|
#[ignore = "a release-mode measurement of the worker's ceilings"]
|
|
fn the_largest_admitted_constant_blob_compiles_within_the_worker_ceilings() {
|
|
if fixture("store_const.ll").is_none() {
|
|
return;
|
|
}
|
|
let (compiled, blob) = compile_blob(26);
|
|
let measured = compiled.measured;
|
|
eprintln!(
|
|
"26 levels: blob {blob} bytes, {:?}, resident peak {:?} bytes, allocator peak {:?} \
|
|
bytes, compile peak {:?} bytes",
|
|
measured.elapsed,
|
|
measured.peak_resident_bytes,
|
|
measured.allocator_peak_bytes,
|
|
compiled.allocator_peak
|
|
);
|
|
assert!(measured.elapsed < DEADLINE, "{:?}", measured.elapsed);
|
|
let peak = measured.peak_bytes().unwrap();
|
|
assert!(peak < MEMORY_LIMIT_BYTES, "{peak} bytes");
|
|
}
|