@@ -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