Skip to content

Commit

Permalink
Merge pull request #1749 from nrspruit/fix_NonBlocking_LastCommand
Browse files Browse the repository at this point in the history
[L0] Maintain Lock of Queue while syncing the Last Command Event and update Last Command Event only if matching
  • Loading branch information
kbenzie authored Jun 14, 2024
2 parents f23ee23 + a461778 commit 2c86cd8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,15 +1696,9 @@ ur_result_t ur_queue_handle_t_::synchronize() {
// If event is discarded then it can be in reset state or underlying level
// zero handle can have device scope, so we can't synchronize the last
// event.
auto savedLastCommandEvent = LastCommandEvent;
if (isInOrderQueue() && !LastCommandEvent->IsDiscarded) {
if (UrL0QueueSyncNonBlocking) {
auto SyncZeEvent = LastCommandEvent->ZeEvent;
this->Mutex.unlock();
ZE2UR_CALL(zeHostSynchronize, (SyncZeEvent));
this->Mutex.lock();
} else {
ZE2UR_CALL(zeHostSynchronize, (LastCommandEvent->ZeEvent));
}
ZE2UR_CALL(zeHostSynchronize, (LastCommandEvent->ZeEvent));

// clean up all events known to have been completed as well,
// so they can be reused later
Expand Down Expand Up @@ -1744,7 +1738,12 @@ ur_result_t ur_queue_handle_t_::synchronize() {
}
}
}
LastCommandEvent = nullptr;
// If the current version of the LastCommandEvent == savedLastCommandEvent,
// then LastCommandEvent = nullptr; Otherwise, if LastCommandEvent !=
// savedLastCommandEvent, then LastCommandEvent is unchanged.
if (LastCommandEvent == savedLastCommandEvent) {
LastCommandEvent = nullptr;
}
}

// Since all timestamp recordings should have finished with the
Expand Down

0 comments on commit 2c86cd8

Please sign in to comment.