Skip to content

Commit 2c86cd8

Browse files
authored
Merge pull request #1749 from nrspruit/fix_NonBlocking_LastCommand
[L0] Maintain Lock of Queue while syncing the Last Command Event and update Last Command Event only if matching
2 parents f23ee23 + a461778 commit 2c86cd8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

source/adapters/level_zero/queue.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,15 +1696,9 @@ ur_result_t ur_queue_handle_t_::synchronize() {
16961696
// If event is discarded then it can be in reset state or underlying level
16971697
// zero handle can have device scope, so we can't synchronize the last
16981698
// event.
1699+
auto savedLastCommandEvent = LastCommandEvent;
16991700
if (isInOrderQueue() && !LastCommandEvent->IsDiscarded) {
1700-
if (UrL0QueueSyncNonBlocking) {
1701-
auto SyncZeEvent = LastCommandEvent->ZeEvent;
1702-
this->Mutex.unlock();
1703-
ZE2UR_CALL(zeHostSynchronize, (SyncZeEvent));
1704-
this->Mutex.lock();
1705-
} else {
1706-
ZE2UR_CALL(zeHostSynchronize, (LastCommandEvent->ZeEvent));
1707-
}
1701+
ZE2UR_CALL(zeHostSynchronize, (LastCommandEvent->ZeEvent));
17081702

17091703
// clean up all events known to have been completed as well,
17101704
// so they can be reused later
@@ -1744,7 +1738,12 @@ ur_result_t ur_queue_handle_t_::synchronize() {
17441738
}
17451739
}
17461740
}
1747-
LastCommandEvent = nullptr;
1741+
// If the current version of the LastCommandEvent == savedLastCommandEvent,
1742+
// then LastCommandEvent = nullptr; Otherwise, if LastCommandEvent !=
1743+
// savedLastCommandEvent, then LastCommandEvent is unchanged.
1744+
if (LastCommandEvent == savedLastCommandEvent) {
1745+
LastCommandEvent = nullptr;
1746+
}
17481747
}
17491748

17501749
// Since all timestamp recordings should have finished with the

0 commit comments

Comments
 (0)