Skip to content

Commit dd212f3

Browse files
authored
Merge pull request #1585 from pbalcer/queue-barrier-fix-v2
fix queue-wide barriers with multiple active command queues
2 parents 6d5d84c + ccfc508 commit dd212f3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

source/adapters/level_zero/context.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,11 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
679679
if (Queue->hasOpenCommandList(UseCopyEngine)) {
680680
if (AllowBatching) {
681681
bool batchingAllowed = true;
682+
if (ForcedCmdQueue &&
683+
CommandBatch.OpenCommandList->second.ZeQueue != *ForcedCmdQueue) {
684+
// Current open batch doesn't match the forced command queue
685+
batchingAllowed = false;
686+
}
682687
if (!UrL0OutOfOrderIntegratedSignalEvent &&
683688
Queue->Device->isIntegrated()) {
684689
batchingAllowed = eventCanBeBatched(Queue, UseCopyEngine,

source/adapters/level_zero/event.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
368368
}
369369

370370
// Execute each command list so the barriers can be encountered.
371-
for (ur_command_list_ptr_t &CmdList : CmdLists)
371+
for (ur_command_list_ptr_t &CmdList : CmdLists) {
372+
bool IsCopy =
373+
CmdList->second.isCopy(reinterpret_cast<ur_queue_handle_t>(Queue));
374+
const auto &CommandBatch =
375+
(IsCopy) ? Queue->CopyCommandBatch : Queue->ComputeCommandBatch;
376+
// Only batch if the matching CmdList is already open.
377+
OkToBatch = CommandBatch.OpenCommandList == CmdList;
378+
372379
UR_CALL(Queue->executeCommandList(CmdList, false, OkToBatch));
380+
}
373381

374382
UR_CALL(Queue->ActiveBarriers.clear());
375383
auto UREvent = reinterpret_cast<ur_event_handle_t>(*Event);

0 commit comments

Comments
 (0)