@@ -5379,6 +5379,22 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
5379
5379
PI_ASSERT (Queue, PI_INVALID_QUEUE);
5380
5380
PI_ASSERT (Event, PI_INVALID_EVENT);
5381
5381
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
+
5382
5398
// Lock automatically releases when this goes out of scope.
5383
5399
std::lock_guard<std::mutex> lock (Queue->PiQueueMutex );
5384
5400
@@ -5388,8 +5404,10 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
5388
5404
return Res;
5389
5405
5390
5406
// Get a new command list to be used on this call
5407
+ bool OkToBatch = true ;
5391
5408
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))
5393
5411
return Res;
5394
5412
5395
5413
ze_event_handle_t ZeEvent = nullptr ;
@@ -5406,7 +5424,7 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
5406
5424
5407
5425
// Execute command list asynchronously as the event will be used
5408
5426
// to track down its completion.
5409
- return Queue->executeCommandList (CommandList);
5427
+ return Queue->executeCommandList (CommandList, false , OkToBatch );
5410
5428
}
5411
5429
5412
5430
pi_result piEnqueueMemBufferRead (pi_queue Queue, pi_mem Src,
0 commit comments