Skip to content

Commit

Permalink
[SYCL] [L0] With immediate commandlists recycle events after they hav…
Browse files Browse the repository at this point in the history
…e signalled (#7368)

This change checks if an event has signalled completion before it is
reset and reused.
  • Loading branch information
rdeodhar authored Nov 15, 2022
1 parent 01ac72d commit a3e93e0
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,11 +1022,25 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
}

auto &EventList = CommandList->second.EventList;
// Remember all the events in this command list which needs to be
// released/cleaned up and clear event list associated with command list.
std::move(std::begin(EventList), std::end(EventList),
std::back_inserter(EventListToCleanup));
EventList.clear();
// Check if standard commandlist
if (CommandList->second.ZeFence != nullptr) {
// Remember all the events in this command list which needs to be
// released/cleaned up and clear event list associated with command list.
std::move(std::begin(EventList), std::end(EventList),
std::back_inserter(EventListToCleanup));
EventList.clear();
} else {
// For immediate commandlist reset only those events that have signalled.
for (auto it = EventList.begin(); it != EventList.end(); it++) {
std::scoped_lock<pi_shared_mutex> EventLock((*it)->Mutex);
ze_result_t ZeResult =
ZE_CALL_NOCHECK(zeEventQueryStatus, ((*it)->ZeEvent));
if (ZeResult == ZE_RESULT_SUCCESS) {
std::move(it, it, std::back_inserter(EventListToCleanup));
EventList.erase(it, it);
}
}
}

// Standard commandlists move in and out of the cache as they are recycled.
// Immediate commandlists are always available.
Expand Down

0 comments on commit a3e93e0

Please sign in to comment.