Skip to content

Commit

Permalink
[L0] changed counting event check consistency & removed unecessary check
Browse files Browse the repository at this point in the history
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
  • Loading branch information
nrspruit committed Mar 27, 2024
1 parent 4ef258c commit 6a817d3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 17 deletions.
5 changes: 3 additions & 2 deletions source/adapters/level_zero/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp(
MustSignalWaitEvent = false;
}
}
if (MustSignalWaitEvent &&
!CommandBuffer->WaitEvent->CounterBasedEventsEnabled) {
// Given WaitEvent was created without specifying Counting Events, then this
// event can be signalled on the host.
if (MustSignalWaitEvent) {
ZE2UR_CALL(zeEventHostSignal, (CommandBuffer->WaitEvent->ZeEvent));
}

Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ ur_context_handle_t_::decrementUnreleasedEventsInPool(ur_event_handle_t Event) {

std::list<ze_event_pool_handle_t> *ZePoolCache = getZeEventPoolCache(
Event->isHostVisible(), Event->isProfilingEnabled(),
Event->usingCounterBasedEvents(), UsingImmediateCommandlists, ZeDevice);
Event->CounterBasedEventsEnabled, UsingImmediateCommandlists, ZeDevice);

// Put the empty pool to the cache of the pools.
if (NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0)
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ ur_result_t ur_event_handle_t_::reset() {

if (!isHostVisible())
HostVisibleEvent = nullptr;
if (!usingCounterBasedEvents())
if (!CounterBasedEventsEnabled)
ZE2UR_CALL(zeEventHostReset, (ZeEvent));
return UR_RESULT_SUCCESS;
}
Expand Down
2 changes: 0 additions & 2 deletions source/adapters/level_zero/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ struct ur_event_handle_t_ : _ur_object {

// Keeps track of whether we are using Counter-based Events.
bool CounterBasedEventsEnabled = false;

bool usingCounterBasedEvents() const { return CounterBasedEventsEnabled; }
};

// Helper function to implement zeHostSynchronize.
Expand Down
12 changes: 4 additions & 8 deletions source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ ur_queue_handle_t_::ur_queue_handle_t_(
return true;
return std::atoi(UrRet) != 0;
}();
this->counterBasedEventsEnabled =
this->CounterBasedEventsEnabled =
isInOrderQueue() && Device->useDriverInOrderLists() &&
useDriverCounterBasedEvents &&
Device->Platform->ZeDriverEventPoolCountingEventsExtensionFound;
Expand Down Expand Up @@ -1247,7 +1247,7 @@ bool ur_queue_handle_t_::doReuseDiscardedEvents() {

ur_result_t
ur_queue_handle_t_::resetDiscardedEvent(ur_command_list_ptr_t CommandList) {
if (!usingCounterBasedEvents() && LastCommandEvent &&
if (!CounterBasedEventsEnabled && LastCommandEvent &&
LastCommandEvent->IsDiscarded) {
ZE2UR_CALL(zeCommandListAppendBarrier,
(CommandList->first, nullptr, 1, &(LastCommandEvent->ZeEvent)));
Expand Down Expand Up @@ -1378,10 +1378,6 @@ bool ur_queue_handle_t_::isInOrderQueue() const {
0);
}

bool ur_queue_handle_t_::usingCounterBasedEvents() const {
return this->counterBasedEventsEnabled;
}

// Helper function to perform the necessary cleanup of the events from reset cmd
// list.
ur_result_t CleanupEventListFromResetCmdList(
Expand Down Expand Up @@ -1536,7 +1532,7 @@ ur_result_t createEventAndAssociateQueue(ur_queue_handle_t Queue,
if (*Event == nullptr)
UR_CALL(EventCreate(Queue->Context, Queue, IsMultiDevice,
HostVisible.value(), Event,
Queue->usingCounterBasedEvents()));
Queue->CounterBasedEventsEnabled));

(*Event)->UrQueue = Queue;
(*Event)->CommandType = CommandType;
Expand Down Expand Up @@ -1900,7 +1896,7 @@ ur_result_t ur_queue_handle_t_::createCommandList(
std::tie(CommandList, std::ignore) = CommandListMap.insert(
std::pair<ze_command_list_handle_t, ur_command_list_info_t>(
ZeCommandList, {ZeFence, false, false, ZeCommandQueue, ZeQueueDesc}));
if (!usingCounterBasedEvents()) {
if (!CounterBasedEventsEnabled) {
UR_CALL(insertStartBarrierIfDiscardEventsMode(CommandList));
UR_CALL(insertActiveBarriers(CommandList, UseCopyEngine));
}
Expand Down
4 changes: 1 addition & 3 deletions source/adapters/level_zero/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ struct ur_queue_handle_t_ : _ur_object {
ur_queue_flags_t Properties;

// Keeps track of whether we are using Counter-based Events
bool counterBasedEventsEnabled = false;
bool CounterBasedEventsEnabled = false;

// Map of all command lists used in this queue.
ur_command_list_map_t CommandListMap;
Expand Down Expand Up @@ -401,8 +401,6 @@ struct ur_queue_handle_t_ : _ur_object {
// Returns true if the queue is a in-order queue.
bool isInOrderQueue() const;

bool usingCounterBasedEvents() const;

// Returns true if the queue has discard events property.
bool isDiscardEvents() const;

Expand Down

0 comments on commit 6a817d3

Please sign in to comment.