Tests: three barrier and instruction counts take their kernels' rates as the test's input

On lavapipe the measured rates cut these tests' command buffers into pieces, each cut ending a
segment with its barrier and its CPU work (job m3-max-68387):
- compute every_device_places_barriers_at_hazards_only: independent 2 barriers against 1;
- compute every_device_counts_no_instructions_for_a_stage_in_region_a_kernel_does_not_read: 37,422
  instructions a dispatch against 39,033 under a region, the arms cut differently;
- surface every_device_carries_each_form_of_surface: the ordered pair 2 barriers against the
  control's 2 (its control cut too), where one more is asserted.
Each sets its kernels' rates to 1 ps a threadgroup before the counted command buffer, so the
dispatches share one piece and the counts are the test's own. No assertion changes.
This commit is contained in:
Anees Iqbal committed 2026-11-22 11:11:24 -08:00
1 parent c9c53b85cf
commit 75773059e7
2 files changed
+14 -2

No files matched your search

@@ -191,8 +191,11 @@ pub(crate) mod on_device {
size: [4, 5, 6],
};
let mut per_dispatch = Vec::new();
// No region, a region set before each dispatch, and the setter with no dispatch.
// No region, a region set before each dispatch, and the setter with no dispatch. The
// kernel's rate 1 ps a threadgroup, the test's own input, so each arm's dispatches
// share one piece (`crate::piece`): no arm pays for a cut the others do not.
for (set, dispatched) in [(false, true), (true, true), (true, false)] {
state.inner.compiled.rate.set_for_test(1);
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder = command_buffer
.compute_command_encoder(DispatchType::Serial)
@@ -361,11 +364,14 @@ pub(crate) mod on_device {
let expected: Vec<u32> = (0..WORDS as u32).map(chained).collect();
assert_eq!(words(&x), expected, "{name}: dependent");
// Independent: each dispatch has a buffer of its own.
// Independent: each dispatch has a buffer of its own. The kernel's rate 1 ps a
// threadgroup, the test's own input, so the dispatches share one piece
// (`crate::piece`) and the barriers counted are the hazards' alone; so too below.
let buffers: Vec<Buffer> = (0..count).map(|_| arena.buffer()).collect();
for buffer in &buffers {
write_words(buffer, |index| index);
}
state.inner.compiled.rate.set_for_test(1);
let before = device.counters().metrics();
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder = command_buffer
@@ -389,6 +395,7 @@ pub(crate) mod on_device {
// Concurrent: barriers where asked for, and none at the hazards.
write_words(&x, |index| index);
state.inner.compiled.rate.set_for_test(1);
let before = device.counters().metrics();
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder = command_buffer
@@ -1106,6 +1106,11 @@ mod on_device {
let out = (device.new_texture(&d, Some(first + 1)))
.unwrap_or_else(|error| panic!("{label}: the output: {error}"));
let pair = |target: &crate::Buffer| -> u64 {
// Each kernel's rate 1 ps a threadgroup, the test's own input, so the two dispatches
// share one piece (`crate::piece`) and the barriers counted are the pair's own.
for state in [add, invert] {
state.inner.compiled.rate.set_for_test(1);
}
let before = counters.metrics().barriers;
let command_buffer = queue.command_buffer().expect("a command buffer");
let mut encoder =