Skip to content

Commit a3e93e0

Browse files
authored
[SYCL] [L0] With immediate commandlists recycle events after they have signalled (#7368)
This change checks if an event has signalled completion before it is reset and reused.
1 parent 01ac72d commit a3e93e0

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,11 +1022,25 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
10221022
}
10231023

10241024
auto &EventList = CommandList->second.EventList;
1025-
// Remember all the events in this command list which needs to be
1026-
// released/cleaned up and clear event list associated with command list.
1027-
std::move(std::begin(EventList), std::end(EventList),
1028-
std::back_inserter(EventListToCleanup));
1029-
EventList.clear();
1025+
// Check if standard commandlist
1026+
if (CommandList->second.ZeFence != nullptr) {
1027+
// Remember all the events in this command list which needs to be
1028+
// released/cleaned up and clear event list associated with command list.
1029+
std::move(std::begin(EventList), std::end(EventList),
1030+
std::back_inserter(EventListToCleanup));
1031+
EventList.clear();
1032+
} else {
1033+
// For immediate commandlist reset only those events that have signalled.
1034+
for (auto it = EventList.begin(); it != EventList.end(); it++) {
1035+
std::scoped_lock<pi_shared_mutex> EventLock((*it)->Mutex);
1036+
ze_result_t ZeResult =
1037+
ZE_CALL_NOCHECK(zeEventQueryStatus, ((*it)->ZeEvent));
1038+
if (ZeResult == ZE_RESULT_SUCCESS) {
1039+
std::move(it, it, std::back_inserter(EventListToCleanup));
1040+
EventList.erase(it, it);
1041+
}
1042+
}
1043+
}
10301044

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

0 commit comments

Comments
 (0)