From 3a6390feb96ad654cab71cbf08754323277a718c Mon Sep 17 00:00:00 2001 From: Adam Fidel Date: Sun, 5 Oct 2025 19:28:56 -0700 Subject: [PATCH 1/2] [SYCL][Graph][UR] Elide second barrier in graph finalize if possible --- .../source/adapters/level_zero/v2/command_buffer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp b/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp index b4c2674bd3364..72782b56944d5 100644 --- a/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp @@ -131,6 +131,8 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() { auto commandListLocked = commandListManager.lock(); UR_ASSERT(!isFinalized, UR_RESULT_ERROR_INVALID_OPERATION); + size_t numEventResets = 0; + if (!isInOrder) { ZE2UR_CALL(zeCommandListAppendBarrier, (commandListLocked->getZeCommandList(), nullptr, 0, nullptr)); @@ -138,12 +140,15 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() { if (!usedSyncPoints[i]) { continue; } + ++numEventResets; ZE2UR_CALL( zeCommandListAppendEventReset, (commandListLocked->getZeCommandList(), syncPoints[i]->getZeEvent())); } - ZE2UR_CALL(zeCommandListAppendBarrier, - (commandListLocked->getZeCommandList(), nullptr, 0, nullptr)); + + if (numEventResets) + ZE2UR_CALL(zeCommandListAppendBarrier, + (commandListLocked->getZeCommandList(), nullptr, 0, nullptr)); } // Close the command lists and have them ready for dispatch. ZE2UR_CALL(zeCommandListClose, (commandListLocked->getZeCommandList())); From a884f3a491df05c375863659600d0eb9bcb00f40 Mon Sep 17 00:00:00 2001 From: Pablo Reble Date: Mon, 6 Oct 2025 08:12:57 -0700 Subject: [PATCH 2/2] fix formatting --- .../source/adapters/level_zero/v2/command_buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp b/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp index 72782b56944d5..9e80e170c3916 100644 --- a/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp @@ -148,7 +148,7 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() { if (numEventResets) ZE2UR_CALL(zeCommandListAppendBarrier, - (commandListLocked->getZeCommandList(), nullptr, 0, nullptr)); + (commandListLocked->getZeCommandList(), nullptr, 0, nullptr)); } // Close the command lists and have them ready for dispatch. ZE2UR_CALL(zeCommandListClose, (commandListLocked->getZeCommandList()));