Skip to content

Commit 379f325

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

File tree

2 files changed

+34
-64
lines changed

2 files changed

+34
-64
lines changed

source/adapters/level_zero/event.cpp

Lines changed: 34 additions & 58 deletions
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,39 @@ 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::urEnqueueEventsWaitWithBarrier(
173+
Queue, nullptr, NumEventsInWaitList, EventWaitList, OutEvent);
174+
175+
return static_cast<ur_result_t (*)(
176+
ur_queue_handle_t, uint32_t, const ur_event_handle_t *,
177+
ur_event_handle_t *, bool)>(EnqueueEventsWaitWithBarrier)(
178+
Queue, NumEventsInWaitList, EventWaitList, OutEvent,
179+
Queue == nullptr ? false : Queue->InterruptBasedEventsEnabled);
180+
}
181+
182+
ur_result_t urEnqueueEventsWaitWithBarrierExt(
183+
ur_queue_handle_t Queue, ///< [in] handle of the queue object
184+
const ur_exp_enqueue_ext_properties_t
185+
*EnqueueExtProp, ///< [in][optional] pointer to the extended enqueue
186+
uint32_t NumEventsInWaitList, ///< [in] size of the event wait list
187+
const ur_event_handle_t
188+
*EventWaitList, ///< [in][optional][range(0, numEventsInWaitList)]
189+
///< pointer to a list of events that must be complete
190+
///< before this command can be executed. If nullptr,
191+
///< the numEventsInWaitList must be 0, indicating that
192+
///< all previously enqueued commands must be complete.
193+
ur_event_handle_t
194+
*OutEvent ///< [in,out][optional] return an event object that identifies
195+
///< this particular command instance.
196+
) {
197+
bool InterruptBasedEventsEnabled =
198+
EnqueueExtProp
199+
? (EnqueueExtProp->flags & UR_EXP_ENQUEUE_EXT_FLAG_LOW_POWER_EVENTS) |
200+
Queue->InterruptBasedEventsEnabled
201+
: Queue->InterruptBasedEventsEnabled;
172202
// Lock automatically releases when this goes out of scope.
173203
std::scoped_lock<ur_shared_mutex> lock(Queue->Mutex);
174204

@@ -421,60 +451,6 @@ ur_result_t EnqueueEventsWaitWithBarrier(
421451
return UR_RESULT_SUCCESS;
422452
}
423453

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-
478454
ur_result_t urEventGetInfo(
479455
ur_event_handle_t Event, ///< [in] handle of the event object
480456
ur_event_info_t PropName, ///< [in] the name of the event property to query

source/adapters/level_zero/event.hpp

Lines changed: 0 additions & 6 deletions
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)