Skip to content

Commit

Permalink
[UR][L0] Correctly wait on barrier on urEnqueueEventsWaitWithBarrier
Browse files Browse the repository at this point in the history
When event list is null, a barrier is still needed for all
previous commands if profiling is enabled, so fix it.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
  • Loading branch information
Jaime Arteaga committed Nov 8, 2023
1 parent ec7982b commit eee9ef5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueEventsWaitWithBarrier(
// 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 +182,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 +966,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 eee9ef5

Please sign in to comment.