From 94c0408b0e33b7eaad3674dc633070a7767273dd Mon Sep 17 00:00:00 2001 From: Radoslaw Jablonski Date: Thu, 30 Jul 2026 05:38:45 +0200 Subject: [PATCH] [UR][L0] Don't batch external semaphore operations External semaphore operations must not be deferred in a batch. With regular (non-immediate) command lists, batching leaves the append sitting in the queue's open command list until some unrelated event flushes it. For a signal that means the external consumer may never observe it; for a wait it means the external producer's signal cannot release a command list that was never submitted, which can deadlock. --- .../source/adapters/level_zero/image.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/unified-runtime/source/adapters/level_zero/image.cpp b/unified-runtime/source/adapters/level_zero/image.cpp index b21a61e678609..979b547435588 100644 --- a/unified-runtime/source/adapters/level_zero/image.cpp +++ b/unified-runtime/source/adapters/level_zero/image.cpp @@ -118,8 +118,13 @@ ur_result_t urBindlessImagesWaitExternalSemaphoreExp( bool UseCopyEngine = false; - // We want to batch these commands to avoid extra submissions (costly) - bool OkToBatch = true; + // External semaphore operations must not be deferred in a batch. With + // regular (non-immediate) command lists, batching leaves the append sitting + // in the queue's open command list until some unrelated event flushes it. + // For a signal that means the external consumer may never observe it; for a + // wait it means the external producer's signal cannot release a command + // list that was never submitted, which can deadlock. + bool OkToBatch = false; ur_ze_event_list_t TmpWaitList; UR_CALL(TmpWaitList.createAndRetainUrZeEventList( @@ -176,8 +181,13 @@ ur_result_t urBindlessImagesSignalExternalSemaphoreExp( bool UseCopyEngine = false; - // We want to batch these commands to avoid extra submissions (costly) - bool OkToBatch = true; + // External semaphore operations must not be deferred in a batch. With + // regular (non-immediate) command lists, batching leaves the append sitting + // in the queue's open command list until some unrelated event flushes it. + // For a signal that means the external consumer may never observe it; for a + // wait it means the external producer's signal cannot release a command + // list that was never submitted, which can deadlock. + bool OkToBatch = false; ur_ze_event_list_t TmpWaitList; UR_CALL(TmpWaitList.createAndRetainUrZeEventList(