Skip to content

Commit 52feab3

Browse files
[SYCL] Fix cleanup of deferred commands (#6605)
When we work in multiple threads and lock on graph failed because of its ownership by another thread - we add command to cleanup to the pool with deferred commands. Sometimes it happens that this pool is never cleaned and even in scheduler destructor it is ignored because of not fully correct check. Current solution let scheduler to cleanup deferred commands in its destructor. Although in most cases it will be cleaned up much earlier because in any place where vector ToCleanup was empty - we will check if there is deferred commands awaiting for destruction. Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent afb6dc3 commit 52feab3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sycl/source/detail/scheduler/scheduler.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,12 @@ MemObjRecord *Scheduler::getMemObjRecord(const Requirement *const Req) {
448448

449449
void Scheduler::cleanupCommands(const std::vector<Command *> &Cmds) {
450450
if (Cmds.empty())
451-
return;
451+
{
452+
std::lock_guard<std::mutex> Lock{MDeferredCleanupMutex};
453+
if (MDeferredCleanupCommands.empty())
454+
return;
455+
}
456+
452457
WriteLockT Lock(MGraphLock, std::try_to_lock);
453458
// In order to avoid deadlocks related to blocked commands, defer cleanup if
454459
// the lock wasn't acquired.

0 commit comments

Comments
 (0)