Skip to content

Commit

Permalink
Merge pull request #962 from jandres742/fixwaitbarrierwithevent
Browse files Browse the repository at this point in the history
[UR][L0] Correctly wait on barrier on urEnqueueEventsWaitWithBarrier
  • Loading branch information
kbenzie authored Dec 8, 2023
2 parents 20fa0b5 + 7fd9daf commit e69ed21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
// event signal because it is already guaranteed that previous commands
// in this queue are completed when the signal is started.
//
// Only consideration here is that when profiling is used, signalEvent
// cannot be used if EventWaitList.Lenght == 0. In those cases, we need
// to fallback directly to barrier to have correct timestamps. See here:
// https://spec.oneapi.io/level-zero/latest/core/api.html?highlight=appendsignalevent#_CPPv430zeCommandListAppendSignalEvent24ze_command_list_handle_t17ze_event_handle_t
//
// TODO: this and other special handling of in-order queues to be
// updated when/if Level Zero adds native support for in-order queues.
//
if (Queue->isInOrderQueue() && InOrderBarrierBySignal) {
if (Queue->isInOrderQueue() && InOrderBarrierBySignal &&
!Queue->isProfilingEnabled()) {
if (EventWaitList.Length) {
ZE2UR_CALL(zeCommandListAppendWaitOnEvents,
(CmdList->first, EventWaitList.Length,
Expand All @@ -181,6 +187,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
(CmdList->first, Event->ZeEvent, EventWaitList.Length,
EventWaitList.ZeEventList));
}

return UR_RESULT_SUCCESS;
};

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

bool ProfilingEnabled =
!Queue || (Queue->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0;
bool ProfilingEnabled = !Queue || Queue->isProfilingEnabled();

if (auto CachedEvent =
Context->getEventFromContextCache(HostVisible, ProfilingEnabled)) {
Expand Down
5 changes: 5 additions & 0 deletions source/adapters/level_zero/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ struct ur_queue_handle_t_ : _ur_object {
// lists in the queue.
ur_result_t
insertStartBarrierIfDiscardEventsMode(ur_command_list_ptr_t &CmdList);

// returns true if queue has profiling enabled
bool isProfilingEnabled() {
return ((this->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0);
}
};

// This helper function creates a ur_event_handle_t and associate a
Expand Down

0 comments on commit e69ed21

Please sign in to comment.