File tree 1 file changed +9
-5
lines changed
source/adapters/level_zero 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -399,11 +399,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo(
399
399
auto UrQueue = Event->UrQueue ;
400
400
if (UrQueue) {
401
401
// Lock automatically releases when this goes out of scope.
402
- std::scoped_lock<ur_shared_mutex> lock (UrQueue->Mutex );
403
- const auto &OpenCommandList = UrQueue->eventOpenCommandList (Event);
404
- if (OpenCommandList != UrQueue->CommandListMap .end ()) {
405
- UR_CALL (UrQueue->executeOpenCommandList (
406
- OpenCommandList->second .isCopy (UrQueue)));
402
+ std::unique_lock<ur_shared_mutex> Lock (UrQueue->Mutex , std::try_to_lock);
403
+ // If we fail to acquire the lock, it's possible that the queue might
404
+ // already be waiting for this event in synchronize().
405
+ if (Lock.owns_lock ()) {
406
+ const auto &OpenCommandList = UrQueue->eventOpenCommandList (Event);
407
+ if (OpenCommandList != UrQueue->CommandListMap .end ()) {
408
+ UR_CALL (UrQueue->executeOpenCommandList (
409
+ OpenCommandList->second .isCopy (UrQueue)));
410
+ }
407
411
}
408
412
}
409
413
You can’t perform that action at this time.
0 commit comments