@@ -897,7 +897,7 @@ _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
897897 // calls.
898898 ZE_CALL (zeFenceReset, (CommandList->second .ZeFence ));
899899 ZE_CALL (zeCommandListReset, (CommandList->first ));
900- CommandList->second .InUse = false ;
900+ CommandList->second .ZeFenceInUse = false ;
901901 }
902902
903903 auto &EventList = CommandList->second .EventList ;
@@ -1140,8 +1140,8 @@ pi_result resetCommandLists(pi_queue Queue) {
11401140 for (auto &&it = Queue->CommandListMap .begin ();
11411141 it != Queue->CommandListMap .end (); ++it) {
11421142 // It is possible that the fence was already noted as signalled and
1143- // reset. In that case the InUse flag will be false.
1144- if (it->second .InUse ) {
1143+ // reset. In that case the ZeFenceInUse flag will be false.
1144+ if (it->second .ZeFence != nullptr && it-> second . ZeFenceInUse ) {
11451145 ze_result_t ZeResult =
11461146 ZE_CALL_NOCHECK (zeFenceQueryStatus, (it->second .ZeFence ));
11471147 if (ZeResult == ZE_RESULT_SUCCESS) {
@@ -1220,7 +1220,8 @@ _pi_context::getAvailableCommandList(pi_queue Queue,
12201220 auto it = Queue->CommandListMap .find (ZeCommandList);
12211221 if (it != Queue->CommandListMap .end ()) {
12221222 CommandList = it;
1223- CommandList->second .InUse = true ;
1223+ if (CommandList->second .ZeFence != nullptr )
1224+ CommandList->second .ZeFenceInUse = true ;
12241225 } else {
12251226 // If there is a command list available on this context, but it
12261227 // wasn't yet used in this queue then create a new entry in this
@@ -3360,7 +3361,7 @@ pi_result piQueueRelease(pi_queue Queue) {
33603361 // For immediate commandlists we don't need to do an L0 reset of the
33613362 // commandlist but do need to do event cleanup which is also in the
33623363 // resetCommandList function.
3363- if (it->second .InUse ) {
3364+ if (it->second .ZeFence != nullptr && it-> second . ZeFenceInUse ) {
33643365 Queue->resetCommandList (it, true , EventListToCleanup);
33653366 }
33663367 // TODO: remove "if" when the problem is fixed in the level zero
0 commit comments