Skip to content

Commit 20a7abc

Browse files
authored
[UR][L0] Lock context mutex during UsmPoolHandles cleanup (#18461)
1 parent 026d4ea commit 20a7abc

File tree

1 file changed

+4
-1
lines changed
  • unified-runtime/source/adapters/level_zero

1 file changed

+4
-1
lines changed

unified-runtime/source/adapters/level_zero/queue.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,12 @@ ur_result_t urQueueRelease(
630630
UR_CALL(Queue->synchronize());
631631

632632
// Cleanup the allocations from 'AsyncPool' made by this queue.
633-
634633
Queue->Context->AsyncPool.cleanupPoolsForQueue(Queue);
634+
std::shared_lock<ur_shared_mutex> ContextLock(Queue->Context->Mutex);
635635
for (auto &Pool : Queue->Context->UsmPoolHandles) {
636636
Pool->cleanupPoolsForQueue(Queue);
637637
}
638+
ContextLock.unlock();
638639

639640
// Destroy all the fences created associated with this queue.
640641
for (auto it = Queue->CommandListMap.begin();
@@ -913,9 +914,11 @@ ur_result_t urQueueFinish(
913914
}
914915

915916
Queue->Context->AsyncPool.cleanupPoolsForQueue(Queue);
917+
std::shared_lock<ur_shared_mutex> ContextLock(Queue->Context->Mutex);
916918
for (auto &Pool : Queue->Context->UsmPoolHandles) {
917919
Pool->cleanupPoolsForQueue(Queue);
918920
}
921+
ContextLock.unlock();
919922

920923
return UR_RESULT_SUCCESS;
921924
}

0 commit comments

Comments
 (0)