Skip to content

Commit 3a3bc06

Browse files
[L0] moved the implementation of EnqueueEventsWaitWithBarrier to EnqueueEventsWaitWithBarrierExt
Signed-off-by: Zhang, Winston <[email protected]>
1 parent 5e18167 commit 3a3bc06

File tree

2 files changed

+28
-64
lines changed

2 files changed

+28
-64
lines changed

source/adapters/level_zero/event.cpp

+28-58
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static const bool InOrderBarrierBySignal = [] {
156156
return (UrRet ? std::atoi(UrRet) : true);
157157
}();
158158

159-
ur_result_t EnqueueEventsWaitWithBarrier(
159+
ur_result_t urEnqueueEventsWaitWithBarrier(
160160
ur_queue_handle_t Queue, ///< [in] handle of the queue object
161161
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
162162
const ur_event_handle_t
@@ -166,9 +166,33 @@ ur_result_t EnqueueEventsWaitWithBarrier(
166166
///< the numEventsInWaitList must be 0, indicating that
167167
///< all previously enqueued commands must be complete.
168168
ur_event_handle_t
169-
*OutEvent, ///< [in,out][optional] return an event object that
170-
///< identifies this particular command instance.
171-
bool InterruptBasedEventsEnabled) {
169+
*OutEvent ///< [in,out][optional] return an event object that identifies
170+
///< this particular command instance.
171+
) {
172+
return ur::level_zero::urEnqueueEventsWaitWithBarrierExt(
173+
Queue, nullptr, NumEventsInWaitList, EventWaitList, OutEvent);
174+
}
175+
176+
ur_result_t urEnqueueEventsWaitWithBarrierExt(
177+
ur_queue_handle_t Queue, ///< [in] handle of the queue object
178+
const ur_exp_enqueue_ext_properties_t
179+
*EnqueueExtProp, ///< [in][optional] pointer to the extended enqueue
180+
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
181+
const ur_event_handle_t
182+
*EventWaitList, ///< [in][optional][range(0, numEventsInWaitList)]
183+
///< pointer to a list of events that must be complete
184+
///< before this command can be executed. If nullptr,
185+
///< the numEventsInWaitList must be 0, indicating that
186+
///< all previously enqueued commands must be complete.
187+
ur_event_handle_t
188+
*OutEvent ///< [in,out][optional] return an event object that identifies
189+
///< this particular command instance.
190+
) {
191+
bool InterruptBasedEventsEnabled =
192+
EnqueueExtProp
193+
? (EnqueueExtProp->flags & UR_EXP_ENQUEUE_EXT_FLAG_LOW_POWER_EVENTS) |
194+
Queue->InterruptBasedEventsEnabled
195+
: Queue->InterruptBasedEventsEnabled;
172196
// Lock automatically releases when this goes out of scope.
173197
std::scoped_lock<ur_shared_mutex> lock(Queue->Mutex);
174198

@@ -421,60 +445,6 @@ ur_result_t EnqueueEventsWaitWithBarrier(
421445
return UR_RESULT_SUCCESS;
422446
}
423447

424-
ur_result_t urEnqueueEventsWaitWithBarrier(
425-
ur_queue_handle_t Queue, ///< [in] handle of the queue object
426-
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
427-
const ur_event_handle_t
428-
*EventWaitList, ///< [in][optional][range(0, numEventsInWaitList)]
429-
///< pointer to a list of events that must be complete
430-
///< before this command can be executed. If nullptr,
431-
///< the numEventsInWaitList must be 0, indicating that
432-
///< all previously enqueued commands must be complete.
433-
ur_event_handle_t
434-
*OutEvent ///< [in,out][optional] return an event object that identifies
435-
///< this particular command instance.
436-
) {
437-
return static_cast<ur_result_t (*)(
438-
ur_queue_handle_t, uint32_t, const ur_event_handle_t *,
439-
ur_event_handle_t *, bool)>(EnqueueEventsWaitWithBarrier)(
440-
Queue, NumEventsInWaitList, EventWaitList, OutEvent,
441-
Queue == nullptr ? false : Queue->InterruptBasedEventsEnabled);
442-
}
443-
444-
ur_result_t urEnqueueEventsWaitWithBarrierExt(
445-
ur_queue_handle_t Queue, ///< [in] handle of the queue object
446-
const ur_exp_enqueue_ext_properties_t
447-
*EnqueueExtProp, ///< [in][optional] pointer to the extended enqueue
448-
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
449-
const ur_event_handle_t
450-
*EventWaitList, ///< [in][optional][range(0, numEventsInWaitList)]
451-
///< pointer to a list of events that must be complete
452-
///< before this command can be executed. If nullptr,
453-
///< the numEventsInWaitList must be 0, indicating that
454-
///< all previously enqueued commands must be complete.
455-
ur_event_handle_t
456-
*OutEvent ///< [in,out][optional] return an event object that identifies
457-
///< this particular command instance.
458-
) {
459-
bool InterruptBased =
460-
EnqueueExtProp
461-
? (EnqueueExtProp->flags & UR_EXP_ENQUEUE_EXT_FLAG_LOW_POWER_EVENTS)
462-
: false;
463-
if (InterruptBased) {
464-
// Create the event with interrupt-based properties
465-
return static_cast<ur_result_t (*)(
466-
ur_queue_handle_t, uint32_t, const ur_event_handle_t *,
467-
ur_event_handle_t *, bool)>(EnqueueEventsWaitWithBarrier)(
468-
Queue, NumEventsInWaitList, EventWaitList, OutEvent, true);
469-
} else {
470-
return static_cast<ur_result_t (*)(
471-
ur_queue_handle_t, uint32_t, const ur_event_handle_t *,
472-
ur_event_handle_t *, bool)>(EnqueueEventsWaitWithBarrier)(
473-
Queue, NumEventsInWaitList, EventWaitList, OutEvent,
474-
Queue->InterruptBasedEventsEnabled || false);
475-
}
476-
}
477-
478448
ur_result_t urEventGetInfo(
479449
ur_event_handle_t Event, ///< [in] handle of the event object
480450
ur_event_info_t PropName, ///< [in] the name of the event property to query

source/adapters/level_zero/event.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,6 @@ template <> ze_result_t zeHostSynchronize(ze_command_queue_handle_t Handle);
279279
ur_result_t CleanupCompletedEvent(ur_event_handle_t Event, bool QueueLocked,
280280
bool SetEventCompleted);
281281

282-
ur_result_t EnqueueEventsWaitWithBarrier(ur_queue_handle_t Queue,
283-
uint32_t NumEventsInWaitList,
284-
const ur_event_handle_t *EventList,
285-
ur_event_handle_t *OutEvent,
286-
bool InterruptBasedEventsEnabled);
287-
288282
// Get value of device scope events env var setting or default setting
289283
static const EventsScope DeviceEventsSetting = [] {
290284
char *UrRet = std::getenv("UR_L0_DEVICE_SCOPE_EVENTS");

0 commit comments

Comments
 (0)