Runtime test: a vec16 argument bound 4 past a multiple of 16 beside one at 0, with its dispatches' forms

every_device_places_each_vector_access_at_its_own_address gains a run binding vwp_vec16's a 4
bytes past a multiple of 16 and b at 0: one argument of alignment 16 at a multiple of 4 below its
alignment beside one at its alignment, the shape a guest kernel's refused bind had (index 0 at
offset 1871700, 4 past a multiple of 16, alignment 16). Each run now prints how many of its two
dispatches ran with their buffers bound (Metrics::bound_dispatches) and how many at their
addresses (Metrics::address_dispatches), so a card run shows which form served the bind.

Verified: the test passes on lavapipe (llvmpipe, LLVM 23.1.1), job m3-max-81994, with clippy
-D warnings under --cfg m2v_cpu_icd clean: every run's two dispatches at addresses (lavapipe has
no bound form), the a-at-4, b-at-0 run included. On the RTX 3090, job m3-max-81997, the same run's
two dispatches both ran bound (a in the variant that keeps its address, b through its binding),
the a-at-4, b-at-8 run one bound and one at addresses, and every other run two bound; every
buffer held Metal's words on both.
This commit is contained in:
Anees Iqbal committed 2026-12-02 21:24:07 -08:00
1 parent e2ab03dc71
commit ece306e521
1 file changed
+19 -5
@@ -4070,9 +4070,12 @@ attributes #1 = { convergent nounwind willreturn }
/// `vwp_words`'s at 0 and `vwp_vec16`'s 4 and 8 bytes past a multiple of 16
/// (`VEC16_AT_WORDS`: arguments of alignment 16 at multiples of 4 only, which plain Metal
/// runs, and which run on the state's variant that holds them to 4, lowered at that dispatch),
/// all four buffers hold Metal's words afterwards, byte for byte from their first byte: the
/// conformance crate's `vector-word-phases-*` cases hold the answer an Apple M3 Max recorded
/// equal to the same words.
/// and with `a` alone 4 bytes past one and `b` at 0, all four buffers hold Metal's words
/// afterwards, byte for byte from their first byte: the conformance crate's
/// `vector-word-phases-*` cases hold the answer an Apple M3 Max recorded equal to the same
/// words. Each run prints how many of its two dispatches ran with their buffers bound
/// (`Metrics::bound_dispatches`, on a device whose profile binds kernel buffers) and how many
/// at their addresses (`Metrics::address_dispatches`).
#[test]
fn every_device_places_each_vector_access_at_its_own_address() {
use metal2vulkan_devtools::vector_word_phases::{
@@ -4099,13 +4102,15 @@ attributes #1 = { convergent nounwind willreturn }
let lowered = || device.counters().metrics().translations;
let runs: Vec<(u64, (u64, u64))> = (OFFSETS.into_iter())
.map(|offset| (offset, vec16_offsets(offset)))
.chain([(0, VEC16_AT_WORDS)])
.chain([(0, VEC16_AT_WORDS), (0, (VEC16_AT_WORDS.0, 0))])
.collect();
let mut forms = Vec::new();
for &(offset, (a_at, b_at)) in &runs {
for (buffer, bytes) in &held {
write(buffer, 0, bytes);
}
let start = lowered();
let counted = device.counters().metrics();
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder = command_buffer
.compute_command_encoder(DispatchType::Serial)
@@ -4134,6 +4139,12 @@ attributes #1 = { convergent nounwind willreturn }
a_at % 16 != 0,
"{name}: vec16 at {a_at} and {b_at}: a variant lowered"
);
let after = device.counters().metrics();
forms.push((
(offset, (a_at, b_at)),
after.bound_dispatches - counted.bound_dispatches,
after.address_dispatches - counted.address_dispatches,
));
let want = answer_at(offset, (a_at, b_at));
for ((buffer, bytes), (which, want)) in held.iter().zip([
("src", &want.src),
@@ -4156,7 +4167,10 @@ attributes #1 = { convergent nounwind willreturn }
);
}
}
println!("{name}: Metal's words at bind offsets {runs:?}");
println!(
"{name}: Metal's words at bind offsets, with the dispatches bound and at addresses: \
{forms:?}"
);
});
}