Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L0] Maintain Lock of Queue while syncing the Last Command Event and update Last Command Event only if matching #1749

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
nrspruit marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading