From 9d319a7861410359e16a6c60b311f986f1545148 Mon Sep 17 00:00:00 2001 From: "Spruit, Neil R" Date: Mon, 29 Jan 2024 10:44:45 -0800 Subject: [PATCH 1/2] [L0] Cleanup Queue even after failure Signed-off-by: Spruit, Neil R --- source/adapters/level_zero/queue.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index 29f3483089..e4bd6dc0a8 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -407,11 +407,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueRelease( // // It is possible to get to here and still have an open command list // if no wait or finish ever occurred for this queue. - if (auto Res = Queue->executeAllOpenCommandLists()) - return Res; + auto Res = Queue->executeAllOpenCommandLists(); // Make sure all commands get executed. - UR_CALL(Queue->synchronize()); + if (Res == UR_RESULT_SUCCESS) + UR_CALL(Queue->synchronize()); // Destroy all the fences created associated with this queue. for (auto it = Queue->CommandListMap.begin(); From 24066e4aafd64db0b0f75495d4492a41f768ba0f Mon Sep 17 00:00:00 2001 From: "Spruit, Neil R" Date: Thu, 1 Feb 2024 15:50:25 -0800 Subject: [PATCH 2/2] [L0] reset command list and events given execution failure Signed-off-by: Spruit, Neil R --- source/adapters/level_zero/queue.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index e4bd6dc0a8..0178d45d72 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -1207,6 +1207,12 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList, // Turn into a more informative end-user error. return UR_RESULT_ERROR_UNKNOWN; } + // Reset Command List and erase the Fence forcing the user to resubmit + // their commands. + std::vector EventListToCleanup; + resetCommandList(CommandList, true, EventListToCleanup, false); + CleanupEventListFromResetCmdList(EventListToCleanup, + true /* QueueLocked */); return ze2urResult(ZeResult); } }