Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions unified-runtime/source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ 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. Batching
// leaves the append sitting in the queue's open regular command list until
// some unrelated event flushes it, which means the external producer's
// signal cannot release a command list that was never submitted and can
// deadlock.
bool OkToBatch = false;

auto phEventWaitListInternal = v1_cast(phEventWaitListOpque);
auto phEventInternal = v1_cast(phEventOpque);
Expand Down Expand Up @@ -191,8 +195,11 @@ 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. Batching
// leaves the append sitting in the queue's open regular command list until
// some unrelated event flushes it, which means the external consumer may
// never observe the signal.
bool OkToBatch = false;

auto phEventWaitListInternal = v1_cast(phEventWaitListOpque);
auto phEventInternal = v1_cast(phEventOpque);
Expand Down
24 changes: 19 additions & 5 deletions unified-runtime/source/adapters/level_zero/v2/queue_batched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,16 @@ ur_result_t ur_queue_batched_t::bindlessImagesWaitExternalSemaphoreExp(
auto lockedBatch = currentCmdLists.lock();
markIssuedCommandInBatch(lockedBatch);

return lockedBatch->getListManager().bindlessImagesWaitExternalSemaphoreExp(
UR_CALL(lockedBatch->getListManager().bindlessImagesWaitExternalSemaphoreExp(
hSemaphore, hasWaitValue, waitValue, waitListView,
getEvent(lockedBatch, phEvent));
getEvent(lockedBatch, phEvent)));

// External semaphore operations must not be deferred in a batch. Batching
// leaves the append sitting in the queue's open regular command list until
// some unrelated event flushes it, which means the external producer's
// signal cannot release a command list that was never submitted and can
// deadlock.
return renewBatchUnlocked(lockedBatch);
}

ur_result_t ur_queue_batched_t::bindlessImagesSignalExternalSemaphoreExp(
Expand All @@ -858,9 +865,16 @@ ur_result_t ur_queue_batched_t::bindlessImagesSignalExternalSemaphoreExp(
auto lockedBatch = currentCmdLists.lock();
markIssuedCommandInBatch(lockedBatch);

return lockedBatch->getListManager().bindlessImagesSignalExternalSemaphoreExp(
hSemaphore, hasSignalValue, signalValue, waitListView,
getEvent(lockedBatch, phEvent));
UR_CALL(
lockedBatch->getListManager().bindlessImagesSignalExternalSemaphoreExp(
hSemaphore, hasSignalValue, signalValue, waitListView,
getEvent(lockedBatch, phEvent)));

// External semaphore operations must not be deferred in a batch. Batching
// leaves the append sitting in the queue's open regular command list until
// some unrelated event flushes it, which means the external consumer may
// never observe the signal.
return renewBatchUnlocked(lockedBatch);
}

// In case of queues with batched submissions, which use regular command lists
Expand Down
Loading