Skip to content

Commit e69ed21

Browse files
authored
Merge pull request #962 from jandres742/fixwaitbarrierwithevent
[UR][L0] Correctly wait on barrier on urEnqueueEventsWaitWithBarrier
2 parents 20fa0b5 + 7fd9daf commit e69ed21

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

source/adapters/level_zero/event.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
165165
// event signal because it is already guaranteed that previous commands
166166
// in this queue are completed when the signal is started.
167167
//
168+
// Only consideration here is that when profiling is used, signalEvent
169+
// cannot be used if EventWaitList.Lenght == 0. In those cases, we need
170+
// to fallback directly to barrier to have correct timestamps. See here:
171+
// https://spec.oneapi.io/level-zero/latest/core/api.html?highlight=appendsignalevent#_CPPv430zeCommandListAppendSignalEvent24ze_command_list_handle_t17ze_event_handle_t
172+
//
168173
// TODO: this and other special handling of in-order queues to be
169174
// updated when/if Level Zero adds native support for in-order queues.
170175
//
171-
if (Queue->isInOrderQueue() && InOrderBarrierBySignal) {
176+
if (Queue->isInOrderQueue() && InOrderBarrierBySignal &&
177+
!Queue->isProfilingEnabled()) {
172178
if (EventWaitList.Length) {
173179
ZE2UR_CALL(zeCommandListAppendWaitOnEvents,
174180
(CmdList->first, EventWaitList.Length,
@@ -181,6 +187,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
181187
(CmdList->first, Event->ZeEvent, EventWaitList.Length,
182188
EventWaitList.ZeEventList));
183189
}
190+
184191
return UR_RESULT_SUCCESS;
185192
};
186193

@@ -964,8 +971,7 @@ ur_result_t CleanupCompletedEvent(ur_event_handle_t Event, bool QueueLocked,
964971
ur_result_t EventCreate(ur_context_handle_t Context, ur_queue_handle_t Queue,
965972
bool HostVisible, ur_event_handle_t *RetEvent) {
966973

967-
bool ProfilingEnabled =
968-
!Queue || (Queue->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0;
974+
bool ProfilingEnabled = !Queue || Queue->isProfilingEnabled();
969975

970976
if (auto CachedEvent =
971977
Context->getEventFromContextCache(HostVisible, ProfilingEnabled)) {

source/adapters/level_zero/queue.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ struct ur_queue_handle_t_ : _ur_object {
515515
// lists in the queue.
516516
ur_result_t
517517
insertStartBarrierIfDiscardEventsMode(ur_command_list_ptr_t &CmdList);
518+
519+
// returns true if queue has profiling enabled
520+
bool isProfilingEnabled() {
521+
return ((this->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0);
522+
}
518523
};
519524

520525
// This helper function creates a ur_event_handle_t and associate a

0 commit comments

Comments
 (0)