partial_threadgroups: the heavy kernel is 10,000 steps, asserted large by the runtime's measure

On ANV (Mesa 26.2.6, the Iris Xe of RPL-P) the heavy kernel's 40,000-step chain took the driver
about 52 s to make with 8 values live (Iris job m3-max-33783: the first ragged grid done at
53.76 s, one VkPipeline) and more than 120 s with the test's 400, and the test makes seven
pipelines of it, so it ran for minutes there. Its compiler took about 3.2 MB of stack for that
chain (3,216,936 bytes measured), about 80 bytes for each value; the runtime now makes every
driver compile on a stack with that room (RUNTIME 2392), so the chain's length no longer stands
in for the stack guard, which tests::small_stack_device and the relay's and the pool's unit
tests cover.

STEPS is now 10,000, and the test asserts the premise that keeps it heavy by the product's own
measure: each state it makes is large (`ComputePipelineState::whole_on_partial`, the module at
`compile_memory::COUNTED_WORDS` SPIR-V words or more), so a smaller chain cannot pass the test
vacuously. LARGE_STEPS (8,000, window 8) already meets that measure, so 10,000 holds it with room.

docs/FAST-PATHS.md records the driver's time and stack as a device gap, with what the runtime
does about the stack: the pool's threads start with 8 MiB, and a call asked for on a thread with
less than 4 MiB of stack left is made on a thread of the runtime's started with 8 MiB.

Verified: an msi job's clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and the ledger tests,
and an Iris job running tests::partial_threadgroups (the heavy test prints its ANV times) and
tests::small_stack_device from this commit's archive.

Verified at a96a3ef68d: m3-max-33936 (msi) clippy -D warnings for metal2vulkan-runtime (all targets, all features) plain, --cfg m2v_cpu_icd and --cfg m2v_gpu; metal2vulkan tests::fast_paths 34/34. Running at landing: the heavy test and small_stack_device on the Iris (m3-max-33948).
This commit is contained in:
Anees Iqbal committed 2026-11-15 15:38:35 -08:00
1 parent 911692b55d
commit 94f9436cd8
2 files changed
+14 -4

No files matched your search

@@ -15,7 +15,9 @@
//! ragged grid, with the plain pipeline's words and Metal's. A smaller kernel's whole grids take the
//! plain pipeline.
//!
//! Under `m2v_gpu`, a kernel heavy enough that its driver's compile is the cost: its ragged grids'
//! Under `m2v_gpu`, a kernel heavy enough that its driver's compile is the cost, a large kernel by
//! the runtime's own measure (`ComputePipelineState::whole_on_partial`: `COUNTED_WORDS` SPIR-V
//! words or more, observing its threadgroup partition), which the test asserts: its ragged grids'
//! creation time on the variant and split, one run each.
//!
//! A device test: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`,
@@ -251,10 +253,13 @@ fn ragged_grids_of_a_kernel_run_partial_threadgroups_on_one_pipeline() {
}
}
/// A kernel heavy enough that its driver's compile is the cost of a pipeline: [`STEPS`] fused
/// multiply-adds of [`WINDOW`] values live at once, after the barrier.
/// A kernel heavy enough that its driver's compile is the cost of a pipeline, and large by the
/// runtime's measure, which the test asserts: [`STEPS`] fused multiply-adds of [`WINDOW`] values
/// live at once, after the barrier. Not many more: ANV (Mesa 26.2.6) on the Iris Xe took about 52 s
/// to make the pipeline of a chain of 40,000 steps with 8 values live and more than 120 s with 400
/// (`docs/FAST-PATHS.md`'s device gaps), and the test makes seven.
#[cfg(m2v_gpu)]
const STEPS: usize = 40_000;
const STEPS: usize = 10_000;
/// The values each step's operand is behind.
#[cfg(m2v_gpu)]
@@ -362,6 +367,10 @@ fn a_heavy_kernel_s_ragged_grids_pay_one_creation() {
let mut took = Vec::new();
for split in [false, true] {
let state = state(&device, &text);
assert!(
state.whole_on_partial(false),
"a large kernel by the runtime's measure: COUNTED_WORDS SPIR-V words or more"
);
if split {
state.split_ragged_grids();
}
+1
View File
@@ -99,6 +99,7 @@ known. The rest of the differences are docs/API.md section 9's precision notes.
| A vertex or fragment function keeps more than 16 KiB a thread of private memory, up to the 192 KiB Metal holds, on a device whose Function storage was not measured: it runs on the driver's scratch, which past what the driver holds answers wrongly or hangs the GPU with no error. | Vulkan states no amount of Function storage; only a measurement of the device does. No other form is exact: a fragment function's helper invocations may not write the memory it would move to, and a vertex function's, a compute pre-pass, is not built. | `FunctionStorageAssumed` (`function-storage-assumed`) |
| A render pipeline of more color attachments than the device draws at once (the lesser of `maxColorAttachments` and `maxFragmentOutputAttachments`, four at Vulkan's floor; Metal takes eight) draws each draw once per group of that many, each group in a render pass of its own over a twin of the pass's depth and stencil. Every variant's vertex stage is one module, `Position` invariant, and every fragment variant's `FragDepth`, `SampleMask` and `FragStencilRefEXT` are `Invariant`; groups past the first may differ at discard or depth edges if the driver compiles the variants differently. | The device holds no more attachments in one subpass. Vulkan's invariance rules make only identical pipelines repeat exactly, and the groups' fragment modules and attachments differ. | `ColorAttachmentGroups` (`color-attachment-groups`) |
| On NVIDIA's driver (615.71.09 on an RTX 5080 Laptop GPU) one `vkQueueSubmit` in every 1024 that signal on a `VkQueue` takes 2 to 4 ms in the driver (1.97 to 4.06 ms measured), which holds the command buffer whose batch it falls on, and the ones committed behind it, from the GPU that long. | The cost is the driver's, and every batch signals its completion. The scheduler's thread takes the stall while idle, by empty submissions, once one was seen (`DriverFact::SignallingSubmitsStallEvery1024`, `device/submit_stalls.rs`; a call in which the calling thread spent 1 ms or more of its CPU, and once one came where the count put it, only there; a call that only waits that long, as beside other processes' GPU work, is none): it falls on work only before then, after a use of the queue the runtime cannot count, or on a queue that never idles 1 ms. Whether the driver's stall also holds other threads' semaphore calls is unsettled: a probe polling the timeline from a second thread during 10 stalls saw 5 of its 9 slow calls (up to 7.1 ms) overlap one in one run, and none of its 3 in another; in `host_ab present` the completion handlers of command buffers that completed during a stall taken idle ran 126 us (p50, 341 at most) after their GPU end, as elsewhere. | None (timing only; `WorkCounts::submit_stalls_on_work`, `WorkCounts::submit_stalls_idle`) |
| On ANV (Mesa 26.2.6, the Iris Xe of RPL-P) a compute pipeline whose 40,000 `float` fused multiply-adds form one chain of dependent values takes the driver about 52 s to make with 8 values live at once, and more than 120 s with 400, and its compiler takes about 3.2 MB of stack on the thread that makes the call: about 80 bytes for each value of the chain. | The time is the driver's compiler's. The runtime makes every driver compile on a stack with that room: the pipeline pool's threads start with 8 MiB, and a call asked for on a thread with less than 4 MiB of stack left (a device made on a small stack, a Rust or macOS secondary thread) is made on a thread of the runtime's started with 8 MiB, the asking thread waiting (`device/compiles.rs`). | None (timing only) |
| Command buffers that share no resource run one after another, where Metal overlaps them while the GPU has room. | The runtime orders nothing between them and runs at each driver's floor for one completion signal per command buffer; a signal shared by several would hold an earlier one's completion for the later ones' work. | None (timing only) |
| On MoltenVK a light queue's command buffer waits for the latest one another queue committed, where Metal waits for none: MoltenVK fences every encoder of every queue device-wide when argument buffers and a residency set are on. | The runtime needs argument buffers, and MoltenVK has no setting for its residency set; `runtime_lane::queue_storms` judges the runtime against Metal under those fences. | None (timing only) |
| A `Boolean` visibility result where a sample passed is the device's occlusion query result without `VK_QUERY_CONTROL_PRECISE_BIT` (ORed over a split pass's render pass instances, and under `Accumulate` into the word the buffer held), which Vulkan states only as nonzero; where none passed it is 0 (under `Accumulate`, the word). An Apple M3 Max writes 1, Metal on the AMD Radeon Pro 5300M and the Intel UHD Graphics 630 (macOS 26.7.1) the samples that passed. | Metal's contract is nonzero, and the device's query answers it natively: no dispatch rewrites the word to 1. | `DeviceBooleanVisibility` (`device-boolean-visibility`) |