Skip to content

Commit bd1ed6a

Browse files
[SYCL] Allow batching for wait with a barrier commands (#5307)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 912572f commit bd1ed6a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5379,6 +5379,22 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
53795379
PI_ASSERT(Queue, PI_INVALID_QUEUE);
53805380
PI_ASSERT(Event, PI_INVALID_EVENT);
53815381

5382+
// Submit dependent open command lists for execution, if any
5383+
// Only do it for queues other than the current, since the barrier
5384+
// will go into current queue submission together with the waited event.
5385+
for (uint32_t I = 0; I < NumEventsInWaitList; I++) {
5386+
auto EventQueue = EventWaitList[I]->Queue;
5387+
if (EventQueue && EventQueue != Queue) {
5388+
// Lock automatically releases when this goes out of scope.
5389+
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
5390+
5391+
if (EventQueue->RefCount > 0) {
5392+
if (auto Res = EventQueue->executeAllOpenCommandLists())
5393+
return Res;
5394+
}
5395+
}
5396+
}
5397+
53825398
// Lock automatically releases when this goes out of scope.
53835399
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
53845400

@@ -5388,8 +5404,10 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
53885404
return Res;
53895405

53905406
// Get a new command list to be used on this call
5407+
bool OkToBatch = true;
53915408
pi_command_list_ptr_t CommandList{};
5392-
if (auto Res = Queue->Context->getAvailableCommandList(Queue, CommandList))
5409+
if (auto Res = Queue->Context->getAvailableCommandList(
5410+
Queue, CommandList, false /*copy*/, OkToBatch))
53935411
return Res;
53945412

53955413
ze_event_handle_t ZeEvent = nullptr;
@@ -5406,7 +5424,7 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
54065424

54075425
// Execute command list asynchronously as the event will be used
54085426
// to track down its completion.
5409-
return Queue->executeCommandList(CommandList);
5427+
return Queue->executeCommandList(CommandList, false, OkToBatch);
54105428
}
54115429

54125430
pi_result piEnqueueMemBufferRead(pi_queue Queue, pi_mem Src,

0 commit comments

Comments
 (0)