Skip to content

Commit 5e18167

Browse files
[L0] Rebased off of top of main and addressed comments
Signed-off-by: Zhang, Winston <[email protected]>
1 parent 4d15d9b commit 5e18167

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

source/adapters/level_zero/context.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,9 @@ ur_event_handle_t ur_context_handle_t_::getEventFromContextCache(
574574
bool HostVisible, bool WithProfiling, ur_device_handle_t Device,
575575
bool CounterBasedEventEnabled, bool InterruptBasedEventEnabled) {
576576
std::scoped_lock<ur_mutex> Lock(EventCacheMutex);
577-
auto Cache = getEventCache(HostVisible, WithProfiling, Device,
578-
CounterBasedEventEnabled);
577+
auto Cache =
578+
getEventCache(HostVisible, WithProfiling, Device,
579+
CounterBasedEventEnabled, InterruptBasedEventEnabled);
579580
if (Cache->empty()) {
580581
logger::info("Cache empty (Host Visible: {}, Profiling: {}, Counter: {}, "
581582
"Device: {})",
@@ -611,9 +612,9 @@ void ur_context_handle_t_::addEventToContextCache(ur_event_handle_t Event) {
611612
Device = Event->UrQueue->Device;
612613
}
613614

614-
auto Cache =
615-
getEventCache(Event->isHostVisible(), Event->isProfilingEnabled(), Device,
616-
Event->CounterBasedEventsEnabled);
615+
auto Cache = getEventCache(
616+
Event->isHostVisible(), Event->isProfilingEnabled(), Device,
617+
Event->CounterBasedEventsEnabled, Event->InterruptBasedEventsEnabled);
617618
logger::info("Inserting {} event (Host Visible: {}, Profiling: {}, Counter: "
618619
"{}, Device: {}) into cache {}",
619620
Event, Event->HostVisibleEvent, Event->isProfilingEnabled(),

source/adapters/level_zero/context.hpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,10 @@ struct ur_context_handle_t_ : _ur_object {
374374
EVENT_FLAG_HOST_VISIBLE = UR_BIT(0),
375375
EVENT_FLAG_WITH_PROFILING = UR_BIT(1),
376376
EVENT_FLAG_COUNTER = UR_BIT(2),
377-
EVENT_FLAG_DEVICE = UR_BIT(3), // if set, subsequent bits are device id
377+
EVENT_FLAG_INTERRUPT = UR_BIT(3),
378+
EVENT_FLAG_DEVICE = UR_BIT(5), // if set, subsequent bits are device id
378379
MAX_EVENT_FLAG_BITS =
379-
4, // this is used as an offset for embedding device id
380+
6, // this is used as an offset for embedding device id
380381
};
381382

382383
// Mutex to control operations on event caches.
@@ -388,7 +389,8 @@ struct ur_context_handle_t_ : _ur_object {
388389

389390
// Get the cache of events for a provided scope and profiling mode.
390391
EventCache *getEventCache(bool HostVisible, bool WithProfiling,
391-
ur_device_handle_t Device, bool Counter) {
392+
ur_device_handle_t Device, bool Counter,
393+
bool Interrupt) {
392394

393395
size_t index = 0;
394396
if (HostVisible) {
@@ -400,6 +402,9 @@ struct ur_context_handle_t_ : _ur_object {
400402
if (Counter) {
401403
index |= EVENT_FLAG_COUNTER;
402404
}
405+
if (Interrupt) {
406+
index |= EVENT_FLAG_INTERRUPT;
407+
}
403408
if (Device) {
404409
index |= EVENT_FLAG_DEVICE | (*Device->Id << MAX_EVENT_FLAG_BITS);
405410
}

source/adapters/level_zero/device.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,6 @@ ur_result_t urDeviceGetInfo(
11571157
return ReturnValue(true);
11581158
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
11591159
return ReturnValue(true);
1160-
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
1161-
return ReturnValue(false);
11621160
case UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP: {
11631161
#ifdef ZE_INTEL_DEVICE_BLOCK_ARRAY_EXP_NAME
11641162
const auto ZeDeviceBlockArrayFlags =

source/adapters/level_zero/event.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,9 @@ ur_result_t urEnqueueEventsWaitWithBarrierExt(
457457
///< this particular command instance.
458458
) {
459459
bool InterruptBased =
460-
EnqueueExtProp &&
461-
(EnqueueExtProp->flags & UR_EXP_ENQUEUE_EXT_FLAG_LOW_POWER_EVENTS);
460+
EnqueueExtProp
461+
? (EnqueueExtProp->flags & UR_EXP_ENQUEUE_EXT_FLAG_LOW_POWER_EVENTS)
462+
: false;
462463
if (InterruptBased) {
463464
// Create the event with interrupt-based properties
464465
return static_cast<ur_result_t (*)(
@@ -470,7 +471,7 @@ ur_result_t urEnqueueEventsWaitWithBarrierExt(
470471
ur_queue_handle_t, uint32_t, const ur_event_handle_t *,
471472
ur_event_handle_t *, bool)>(EnqueueEventsWaitWithBarrier)(
472473
Queue, NumEventsInWaitList, EventWaitList, OutEvent,
473-
Queue ? Queue->InterruptBasedEventsEnabled : false);
474+
Queue->InterruptBasedEventsEnabled || false);
474475
}
475476
}
476477

source/adapters/level_zero/queue.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -1192,20 +1192,12 @@ ur_queue_handle_t_::ur_queue_handle_t_(
11921192
}
11931193
return std::atoi(UrRet) != 0;
11941194
}();
1195-
static const bool useInterruptBasedEvents = [] {
1196-
const char *UrRet = std::getenv("UR_L0_USE_INTERRUPT_BASED_EVENTS");
1197-
if (!UrRet) {
1198-
return true;
1199-
}
1200-
return std::atoi(UrRet) != 0;
1201-
}();
12021195
this->CounterBasedEventsEnabled =
12031196
UsingImmCmdLists && isInOrderQueue() && Device->useDriverInOrderLists() &&
12041197
useDriverCounterBasedEvents &&
12051198
Device->Platform->ZeDriverEventPoolCountingEventsExtensionFound;
1206-
this->InterruptBasedEventsEnabled = useInterruptBasedEvents &&
1207-
isLowPowerEvents() && isInOrderQueue() &&
1208-
Device->useDriverInOrderLists();
1199+
this->InterruptBasedEventsEnabled =
1200+
isLowPowerEvents() && isInOrderQueue() && Device->useDriverInOrderLists();
12091201
}
12101202

12111203
void ur_queue_handle_t_::adjustBatchSizeForFullBatch(bool IsCopy) {

0 commit comments

Comments
 (0)