Runtime tests: the set pools hold flat across an encode and retire loop
AGENTS.md's leak lines for the set pools, a bounded store the bound form adds: zero at the device's drop and a fill past capacity were shown by every_device_shares_its_set_pools_and_keeps_at_most_seventeen; flat between loop iterations 100 and 200 was not. The new test encodes 200 command buffers of half a pool's sets and one more, each retired before the next, so the pool the device hands out from runs out every other iteration and a pool's sets come back while another serves, and asserts the buffer_set_pools gauge equal after iterations 100 and 200, at most the kept pools, and zero at the device's drop; a device in the address form holds none. Test only; it runs in the device suites at the landing tip.
This commit is contained in:
1 parent
503431ab7d
commit
29c40fa526
1 file changed
+60
-1
@@ -13,7 +13,9 @@
|
||||
//! and destroys the one past them; a command buffer of `(FREE_POOLS + 1) * POOL_SETS` then takes
|
||||
//! those and makes none; and none is left once the device drops;
|
||||
//! - two threads encoding a command buffer each at once take runs from the same pools, under the
|
||||
//! validation layer, whose thread-safety checks report two threads at one pool or one set.
|
||||
//! validation layer, whose thread-safety checks report two threads at one pool or one set;
|
||||
//! - a loop of 200 command buffers, each retired before the next, keeps the pools alive flat
|
||||
//! between iterations 100 and 200, and none is left once the device drops.
|
||||
//!
|
||||
//! Each command buffer's outputs are checked. A device that keeps its kernels' buffers at their
|
||||
//! addresses writes no set and holds no pool. `llvm-as` assembles the fixture; without it the
|
||||
@@ -254,4 +256,61 @@ mod on_device {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// A loop that encodes, retires and encodes again: 200 iterations, each one command buffer of
|
||||
/// half a pool's sets and one more, retired before the next, so the pool the device hands out
|
||||
/// from runs out every other iteration and a pool's sets come back while another serves. The
|
||||
/// pools alive read the same after iterations 100 and 200, and none once the device is gone.
|
||||
#[test]
|
||||
fn every_device_s_set_pools_hold_flat_across_an_encode_and_retire_loop() {
|
||||
each_device("set_pools_loop", |name, _, device| {
|
||||
let Some(state) = state(name, &device) else {
|
||||
return;
|
||||
};
|
||||
let bound = device.translator().profile().binds_kernel_buffers();
|
||||
let counters = device.counters();
|
||||
let pools = || counters.gauges().buffer_set_pools;
|
||||
let queue = device.new_command_queue(4).expect("a queue");
|
||||
let mut arena = Arena::new(&device);
|
||||
let work = Work::new(&mut arena, [2.0, 3.0, 5.0]);
|
||||
let dispatches = POOL_SETS as usize / 2 + 1;
|
||||
let mut read = Vec::new();
|
||||
for iteration in 1..=200 {
|
||||
let command_buffer = work.encode(name, &queue, &state, dispatches);
|
||||
run(name, &command_buffer);
|
||||
drop(command_buffer);
|
||||
within("the command buffer's retirement", || {
|
||||
counters.gauges().command_buffers == 0
|
||||
});
|
||||
if iteration % 100 == 0 {
|
||||
read.push(pools());
|
||||
}
|
||||
}
|
||||
work.check(
|
||||
&format!("{name}: the loop's last command buffer"),
|
||||
dispatches,
|
||||
);
|
||||
println!(
|
||||
"set_pools_loop: {name}: pools alive after iterations 100 and 200 of {dispatches} \
|
||||
dispatches each: {read:?}"
|
||||
);
|
||||
match bound {
|
||||
true => {
|
||||
assert_eq!(
|
||||
read[0], read[1],
|
||||
"{name}: the pools at iterations 100 and 200"
|
||||
);
|
||||
assert!(
|
||||
(1..=FREE_POOLS as u64 + 1).contains(&read[1]),
|
||||
"{name}: {} pools alive, past the {} kept",
|
||||
read[1],
|
||||
FREE_POOLS + 1
|
||||
);
|
||||
}
|
||||
false => assert_eq!(read, [0, 0], "{name}: pools"),
|
||||
}
|
||||
drop((state, work, arena, queue, device));
|
||||
assert_eq!(pools(), 0, "{name}: the pools at the device's drop");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user