Skip to content

[SYCL][L0]: Check Queue refcnt prior to using L0 members #2471

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

Merged
merged 1 commit into from
Sep 15, 2020
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
22 changes: 12 additions & 10 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3018,16 +3018,18 @@ pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) {
// Event has been signaled: If the fence for the associated command list
// is signalled, then reset the fence and command list and add them to the
// available list for reuse in PI calls.
EventList[I]->Queue->ZeCommandListFenceMapMutex.lock();
ze_result_t ZeResult = ZE_CALL_NOCHECK(zeFenceQueryStatus(
EventList[I]
->Queue->ZeCommandListFenceMap[EventList[I]->ZeCommandList]));
if (ZeResult == ZE_RESULT_SUCCESS) {
EventList[I]->Queue->resetCommandListFenceEntry(
EventList[I]->ZeCommandList, true);
EventList[I]->ZeCommandList = nullptr;
if (EventList[I]->Queue->RefCount > 0) {
EventList[I]->Queue->ZeCommandListFenceMapMutex.lock();
ze_result_t ZeResult = ZE_CALL_NOCHECK(zeFenceQueryStatus(
EventList[I]
->Queue->ZeCommandListFenceMap[EventList[I]->ZeCommandList]));
if (ZeResult == ZE_RESULT_SUCCESS) {
EventList[I]->Queue->resetCommandListFenceEntry(
EventList[I]->ZeCommandList, true);
EventList[I]->ZeCommandList = nullptr;
}
EventList[I]->Queue->ZeCommandListFenceMapMutex.unlock();
}
EventList[I]->Queue->ZeCommandListFenceMapMutex.unlock();
}
}
return PI_SUCCESS;
Expand Down Expand Up @@ -3059,7 +3061,7 @@ pi_result piEventRelease(pi_event Event) {
// If the fence associated with this command list has signalled, then
// Reset the Command List Used in this event and put it back on the
// available list.
if (Event->Queue->ZeCommandQueue) {
if (Event->Queue->RefCount > 0) {
Event->Queue->ZeCommandListFenceMapMutex.lock();
ze_result_t ZeResult = ZE_CALL_NOCHECK(zeFenceQueryStatus(
Event->Queue->ZeCommandListFenceMap[Event->ZeCommandList]));
Expand Down