Skip to content

Commit 32e2533

Browse files
authored
Merge pull request #1300 from nrspruit/queue_release_cleanup
[L0] Cleanup Queue at Release unconditionally and reset command list after failure
2 parents 9babc4d + 24066e4 commit 32e2533

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

source/adapters/level_zero/queue.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueRelease(
407407
//
408408
// It is possible to get to here and still have an open command list
409409
// if no wait or finish ever occurred for this queue.
410-
if (auto Res = Queue->executeAllOpenCommandLists())
411-
return Res;
410+
auto Res = Queue->executeAllOpenCommandLists();
412411

413412
// Make sure all commands get executed.
414-
UR_CALL(Queue->synchronize());
413+
if (Res == UR_RESULT_SUCCESS)
414+
UR_CALL(Queue->synchronize());
415415

416416
// Destroy all the fences created associated with this queue.
417417
for (auto it = Queue->CommandListMap.begin();
@@ -1207,6 +1207,12 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
12071207
// Turn into a more informative end-user error.
12081208
return UR_RESULT_ERROR_UNKNOWN;
12091209
}
1210+
// Reset Command List and erase the Fence forcing the user to resubmit
1211+
// their commands.
1212+
std::vector<ur_event_handle_t> EventListToCleanup;
1213+
resetCommandList(CommandList, true, EventListToCleanup, false);
1214+
CleanupEventListFromResetCmdList(EventListToCleanup,
1215+
true /* QueueLocked */);
12101216
return ze2urResult(ZeResult);
12111217
}
12121218
}

0 commit comments

Comments
 (0)