Skip to content

Commit

Permalink
Merge pull request #1371 from pbalcer/l0-query-status-sync-deadlock
Browse files Browse the repository at this point in the history
[L0] fix a deadlock in queue sync and event status query
  • Loading branch information
kbenzie authored Feb 22, 2024
2 parents 4e69cc6 + 4708475 commit 588615e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo(
auto UrQueue = Event->UrQueue;
if (UrQueue) {
// Lock automatically releases when this goes out of scope.
std::scoped_lock<ur_shared_mutex> lock(UrQueue->Mutex);
const auto &OpenCommandList = UrQueue->eventOpenCommandList(Event);
if (OpenCommandList != UrQueue->CommandListMap.end()) {
UR_CALL(UrQueue->executeOpenCommandList(
OpenCommandList->second.isCopy(UrQueue)));
std::unique_lock<ur_shared_mutex> Lock(UrQueue->Mutex, std::try_to_lock);
// If we fail to acquire the lock, it's possible that the queue might
// already be waiting for this event in synchronize().
if (Lock.owns_lock()) {
const auto &OpenCommandList = UrQueue->eventOpenCommandList(Event);
if (OpenCommandList != UrQueue->CommandListMap.end()) {
UR_CALL(UrQueue->executeOpenCommandList(
OpenCommandList->second.isCopy(UrQueue)));
}
}
}

Expand Down

0 comments on commit 588615e

Please sign in to comment.