Skip to content

[SYCL] Fix memory leak in piEnqueueEventsWaitWithBarrier with discarded output event #7229

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
Oct 31, 2022
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
27 changes: 15 additions & 12 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6466,15 +6466,15 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
}
}

// Insert a barrier into each unique command queue using the available
// command-lists.
std::vector<pi_event> EventWaitVector(CmdLists.size());
for (size_t I = 0; I < CmdLists.size(); ++I)
if (auto Res = insertBarrierIntoCmdList(CmdLists[I], _pi_ze_event_list_t{},
EventWaitVector[I], false))
return Res;

if (CmdLists.size() > 1) {
// Insert a barrier into each unique command queue using the available
// command-lists.
std::vector<pi_event> EventWaitVector(CmdLists.size());
for (size_t I = 0; I < CmdLists.size(); ++I)
if (auto Res = insertBarrierIntoCmdList(
CmdLists[I], _pi_ze_event_list_t{}, EventWaitVector[I], false))
return Res;

// If there were multiple queues we need to create a "convergence" event to
// be our active barrier. This convergence event is signalled by a barrier
// on all the events from the barriers we have inserted into each queue.
Expand All @@ -6498,10 +6498,13 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
*Event, IsInternal))
return Res;
} else {
// If there is only a single queue we have inserted all the barriers we need
// and the single result event can be used as our active barrier and used as
// the return event.
*Event = EventWaitVector[0];
PI_ASSERT(CmdLists.size() == 1, PI_ERROR_INVALID_QUEUE);
// If there is only a single queue then insert a barrier and the single
// result event can be used as our active barrier and used as the return
// event. Take into account whether output event is discarded or not.
if (auto Res = insertBarrierIntoCmdList(CmdLists[0], _pi_ze_event_list_t{},
*Event, IsInternal))
return Res;
}

// Execute each command list so the barriers can be encountered.
Expand Down