Skip to content

Commit 123d88f

Browse files
[SYCL][NFC] Fix flaky behavior in cleanup related unit tests (#7798)
1 parent b211d0d commit 123d88f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sycl/unittests/scheduler/GraphCleanup.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ TEST_F(SchedulerTest, HostTaskCleanup) {
301301

302302
Lock.unlock();
303303
Event.wait();
304+
// The command should be sent to graph cleanup as part of the task
305+
// submitted to the thread pool, shortly after the event is marked
306+
// as complete.
307+
detail::GlobalHandler::instance().drainThreadPool();
304308
ASSERT_EQ(EventImpl->getCommand(), nullptr);
305309
}
306310

@@ -345,6 +349,9 @@ TEST_F(SchedulerTest, StreamBufferDeallocation) {
345349
// The buffers should have been released with graph cleanup once the work is
346350
// finished.
347351
EventImplPtr->wait(EventImplPtr);
352+
// Drain the thread pool to ensure that the cleanup is able to acquire
353+
// the graph lock.
354+
detail::GlobalHandler::instance().drainThreadPool();
348355
MSPtr->cleanupCommands({});
349356
ASSERT_EQ(MSPtr->MDeferredMemObjRelease.size(), 0u);
350357
}

0 commit comments

Comments
 (0)