Skip to content

Commit ccd73c7

Browse files
committed
[L0] Fix ondemand host and host signal events to append a barrier
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 4c93ce2 commit ccd73c7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

source/adapters/level_zero/event.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,13 @@ ur_result_t ur_event_handle_t_::getOrCreateHostVisibleEvent(
623623
/* IsInternal */ false, /* IsMultiDevice */ false,
624624
/* HostVisible */ true));
625625

626-
ZE2UR_CALL(zeCommandListAppendWaitOnEvents,
627-
(CommandList->first, 1, &ZeEvent));
626+
if (this->IsInnerBatchedEvent) {
627+
ZE2UR_CALL(zeCommandListAppendBarrier,
628+
(CommandList->first, ZeEvent, 0, nullptr));
629+
} else {
630+
ZE2UR_CALL(zeCommandListAppendWaitOnEvents,
631+
(CommandList->first, 1, &ZeEvent));
632+
}
628633
ZE2UR_CALL(zeCommandListAppendSignalEvent,
629634
(CommandList->first, HostVisibleEvent->ZeEvent));
630635

source/adapters/level_zero/queue.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,7 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
13231323
// in the command list is not empty, otherwise we are going to just create
13241324
// and remove proxy event right away and dereference deleted object
13251325
// afterwards.
1326+
bool AppendBarrierNeeded = true;
13261327
if (ZeEventsScope == LastCommandInBatchHostVisible &&
13271328
!CommandList->second.EventList.empty()) {
13281329
// If there are only internal events in the command list then we don't
@@ -1391,6 +1392,7 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
13911392
ZE2UR_CALL(zeCommandListAppendSignalEvent,
13921393
(CommandList->first, HostVisibleEvent->ZeEvent));
13931394
} else {
1395+
AppendBarrierNeeded = false;
13941396
ZE2UR_CALL(
13951397
zeCommandListAppendBarrier,
13961398
(CommandList->first, HostVisibleEvent->ZeEvent, 0, nullptr));
@@ -1404,6 +1406,10 @@ ur_queue_handle_t_::executeCommandList(ur_command_list_ptr_t CommandList,
14041406
this->signalEventFromCmdListIfLastEventDiscarded(CommandList);
14051407
}
14061408
// Append Signalling of the inner events at the end of the batch
1409+
if (CommandList->second.EventList.size() > 0 && AppendBarrierNeeded) {
1410+
ZE2UR_CALL(zeCommandListAppendBarrier,
1411+
(CommandList->first, nullptr, 0, nullptr));
1412+
}
14071413
for (auto &Event : CommandList->second.EventList) {
14081414
if (Event->IsInnerBatchedEvent) {
14091415
ZE2UR_CALL(zeCommandListAppendSignalEvent,

0 commit comments

Comments
 (0)