commit_and_submit: the order test drains its queue every 50th commit, as the checked one does
What: submission_handlers_keep_commit_order_across_commit_and_commit_and_submit now makes every 50th commit a commit_and_submit that first waits for the commit before it to complete, as checked_command_buffers_keep_commit_order_across_commit_and_commit_and_submit does. Why: the test asserts some submission handlers ran on a committing thread. Each commit() wakes the scheduler's thread, whose pass is often still under way at the other thread's next commit_and_submit, which then makes no pass; and on a driver whose batches group, a committing thread submits only where its VkQueue runs at most one earlier submission not seen complete, which the two threads' backlog may never leave it. On the Radeon 780M (RADV) inside the touched suites' run it failed: 0 of 1000 handlers on a committing thread, 1 pass at commit, 0 batches (m3-max-36934, debug, 76 tests in parallel). Run alone in release it passed 10 of 10 with 12-17 of 1000 on a committing thread, with RUNTIME 2461's fix and without it alike (m3-max-36983): the margin, not that fix. After a drain the scheduler's thread is idle and the VkQueue runs nothing, so the commit_and_submit makes its pass and submits alone. Verified: in the jobs named in the lane's report.
This commit is contained in:
1 parent
2ccc3e9c38
commit
8167cc60de
1 file changed
+21
-8
@@ -36,7 +36,7 @@ const PER_THREAD: u64 = 500;
|
||||
/// How long each submission handler of the order test runs.
|
||||
const HANDLER: Duration = Duration::from_micros(30);
|
||||
|
||||
/// How often, in commits, the checked order test lets its queue drain before a commit.
|
||||
/// How often, in commits, the order tests let their queue drain before a commit.
|
||||
const DRAINED: u64 = 50;
|
||||
|
||||
/// The device the cfg selects: a CPU device under `m2v_cpu_icd`, else a GPU.
|
||||
@@ -216,22 +216,28 @@ fn a_commit_call_is_timed_phase_by_phase_within_its_whole() {
|
||||
}
|
||||
|
||||
/// Two threads commit 1000 command buffers to one queue, each in turn with `commit` and with
|
||||
/// `commit_and_submit`, their commits in one order (a lock held across each call): every
|
||||
/// submission handler runs in that order, some on a committing thread and some on the
|
||||
/// scheduler's.
|
||||
/// `commit_and_submit`, their commits in one order (a lock held across each call): every submission
|
||||
/// handler runs in that order, some on a committing thread and some on the scheduler's. Every
|
||||
/// [`DRAINED`]th commit, a `commit_and_submit`, first waits for the commit before it to complete:
|
||||
/// each `commit` wakes the scheduler's thread, whose pass is often under way at the next
|
||||
/// `commit_and_submit`, which then makes none (on the Radeon 780M, under the suites' load, one of
|
||||
/// its 500 calls made a pass, which submitted nothing), and on a device whose batches may wait in a
|
||||
/// group a committing thread submits only where its `VkQueue` runs at most one earlier submission
|
||||
/// not seen complete, which the two threads' backlog alone may never leave it.
|
||||
#[test]
|
||||
fn submission_handlers_keep_commit_order_across_commit_and_commit_and_submit() {
|
||||
let device = device();
|
||||
let queue = device.new_command_queue().unwrap();
|
||||
let target = device.new_buffer(256, ResourceOptions::private()).unwrap();
|
||||
let next = Mutex::new(0u64);
|
||||
let last: Mutex<Option<CommandBuffer>> = Mutex::default();
|
||||
let ran: Arc<Mutex<Vec<(u64, ThreadId)>>> = Arc::default();
|
||||
let before = device.work_counts();
|
||||
let (committers, committed): (Vec<ThreadId>, Vec<Vec<CommandBuffer>>) =
|
||||
std::thread::scope(|scope| {
|
||||
let threads: Vec<_> = (0..2u64)
|
||||
.map(|thread| {
|
||||
let (queue, target, next, ran) = (&queue, &target, &next, &ran);
|
||||
let (queue, target, next, last, ran) = (&queue, &target, &next, &last, &ran);
|
||||
scope.spawn(move || {
|
||||
let mut committed = Vec::new();
|
||||
for at in 0..PER_THREAD {
|
||||
@@ -252,12 +258,19 @@ fn submission_handlers_keep_commit_order_across_commit_and_commit_and_submit() {
|
||||
}))
|
||||
.unwrap();
|
||||
let mut next = next.lock().unwrap();
|
||||
let drained = *next % DRAINED == DRAINED - 1;
|
||||
if drained {
|
||||
if let Some(before) = last.lock().unwrap().as_ref() {
|
||||
before.wait_until_completed().unwrap();
|
||||
}
|
||||
}
|
||||
sequence.store(*next, Ordering::SeqCst);
|
||||
*next += 1;
|
||||
match (at + thread) % 2 {
|
||||
0 => command_buffer.commit_and_submit().unwrap(),
|
||||
_ => command_buffer.commit().unwrap(),
|
||||
match drained || (at + thread) % 2 == 0 {
|
||||
true => command_buffer.commit_and_submit().unwrap(),
|
||||
false => command_buffer.commit().unwrap(),
|
||||
}
|
||||
*last.lock().unwrap() = Some(command_buffer.clone());
|
||||
drop(next);
|
||||
committed.push(command_buffer);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user