From e129303c427f646d78de3550a07091495be29def Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 26 Nov 2026 18:37:37 -0800 Subject: [PATCH] Tests: the point-counting test makes the calls the runtime makes at each point The first run (lavapipe, job m3-max-75846) settled at the submission's point too, which the runtime never does, so the identity calls() asserts (the invalidated bytes are the retirements', the events' and at most the staging's) failed there: [1, 128, 1, 128, 0, 128, 0, 0, 0]. The test now flushes at the submission's point, settles at the retirement's and the event's, and does both at the staging point, as the product's sites do. Verified: cargo fmt only; the lavapipe job follows. --- .../src/tests/coherence.rs | 72 +++++++++++-------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/coherence.rs b/crates/metal2vulkan-runtime/src/tests/coherence.rs index 8cdd746b6..99b9e26a7 100644 --- a/crates/metal2vulkan-runtime/src/tests/coherence.rs +++ b/crates/metal2vulkan-runtime/src/tests/coherence.rs @@ -414,10 +414,11 @@ mod on_device { /// of its own over the device's Shared type read through the refused device's view /// (`crate::tests::command::on_device::viewed`), which leaves that type not coherent: the /// device itself is made as the device tests make it, so this runs where the floor refuses - /// the view. At each point, a flush and then a settle of a Shared buffer's range count its - /// atoms at that point alone and at no other, the settle's invalidate among the invalidated - /// bytes, with no call failing; and the host time inside the calls is counted, the flushes' - /// apart from the invalidates'. + /// the view. At each point, the calls the runtime makes there (a flush before a submission, a + /// settle at a retirement and before an event's value is seen, both around its own host + /// accesses) over a Shared buffer's range count its atoms at that point alone and at no other, + /// a settle's invalidate among the invalidated bytes, with no call failing; and the host time + /// inside the calls is counted, the flushes' apart from the invalidates'. #[test] fn a_coherence_state_counts_each_call_at_its_point_and_times_it() { use crate::buffer::BufferObject; @@ -448,40 +449,49 @@ mod on_device { let widened = atoms(block.offset + OFFSET, LEN, coherence.atom); let core = device.core(); let start = counters.metrics(); + // Each point with the calls the runtime makes there: whether it flushes, whether it + // settles. let points = [ - ("the submission's", Point::Reach), - ("the retirement's", Point::Retirement), - ("the event's", Point::EventSeen), - ("the staging's", Point::Staging), + ("the submission's", Point::Reach, [true, false]), + ("the retirement's", Point::Retirement, [false, true]), + ("the event's", Point::EventSeen, [false, true]), + ("the staging's", Point::Staging, [true, true]), ]; - for (at, (what, point)) in points.into_iter().enumerate() { + for (at, (what, point, [flushes, settles])) in points.into_iter().enumerate() { let mut alone = [1, widened, 0, 0, 0, 0, 0, 0, 0]; alone[5 + at] = widened; - let mut settled_alone = alone; - settled_alone[2..4].copy_from_slice(&[1, widened]); - let before = counters.metrics(); - coherence.flush(core, point, &[range]); - let flushed = counters.metrics(); - coherence.settle(core, point, &[range]); - let settled = counters.metrics(); - let flush = calls(&before, &flushed); - let settle = calls(&flushed, &settled); - println!( - "coherence_points: {name}: at {what} point, a flush {flush:?}, a settle \ - {settle:?}; the buffer {widened} bytes" - ); - assert_eq!( - flush, alone, - "{name}: a flush at {what} point, counted there alone" - ); - assert_eq!( - settle, settled_alone, - "{name}: a settle at {what} point, its flush counted there alone" - ); + if flushes { + let before = counters.metrics(); + coherence.flush(core, point, &[range]); + let flush = calls(&before, &counters.metrics()); + println!( + "coherence_points: {name}: a flush at {what} point {flush:?}; the buffer \ + {widened} bytes" + ); + assert_eq!( + flush, alone, + "{name}: a flush at {what} point, counted there alone" + ); + } + if settles { + let mut settled_alone = alone; + settled_alone[2..4].copy_from_slice(&[1, widened]); + let before = counters.metrics(); + coherence.settle(core, point, &[range]); + let settle = calls(&before, &counters.metrics()); + println!( + "coherence_points: {name}: a settle at {what} point {settle:?}; the \ + buffer {widened} bytes" + ); + assert_eq!( + settle, settled_alone, + "{name}: a settle at {what} point, its flush counted there alone" + ); + } } let [flush, invalidate] = nanos(&start, &counters.metrics()); println!( - "coherence_points: {name}: 8 flushes in {flush} ns, 4 invalidates in {invalidate} \ + "coherence_points: {name}: 5 flushes in {flush} ns, 3 invalidates in {invalidate} \ ns" ); assert!(