Skip to content

Commit 71de63d

Browse files
[L0] reverted getEventCache due to test failure
Signed-off-by: Zhang, Winston <[email protected]>
1 parent 804b3f4 commit 71de63d

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

source/adapters/level_zero/context.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,12 @@ ur_event_handle_t
590590
ur_context_handle_t_::getEventFromContextCache(v2::event_flags_t Flags,
591591
ur_device_handle_t Device) {
592592
std::scoped_lock<ur_mutex> Lock(EventCacheMutex);
593-
auto Cache = getEventCache(Flags, Device);
593+
594+
auto Cache = getEventCache(Flags & v2::EVENT_FLAGS_HOST_VISIBLE,
595+
Flags & v2::EVENT_FLAGS_PROFILING_ENABLED, Device,
596+
Flags & v2::EVENT_FLAGS_COUNTER,
597+
Flags & v2::EVENT_FLAGS_INTERRUPT);
598+
594599
if (Cache->empty()) {
595600
logger::info("Cache empty (Host Visible: {}, Profiling: {}, Counter: {}, "
596601
"Interrupt: {}, Device: {})",
@@ -625,16 +630,9 @@ void ur_context_handle_t_::addEventToContextCache(ur_event_handle_t Event) {
625630
Device = Event->UrQueue->Device;
626631
}
627632

628-
v2::event_flags_t Flags = 0;
629-
if (Event->HostVisibleEvent)
630-
Flags |= v2::EVENT_FLAGS_HOST_VISIBLE;
631-
if (Event->isProfilingEnabled())
632-
Flags |= v2::EVENT_FLAGS_PROFILING_ENABLED;
633-
if (Event->CounterBasedEventsEnabled)
634-
Flags |= v2::EVENT_FLAGS_COUNTER;
635-
if (Event->InterruptBasedEventsEnabled)
636-
Flags |= v2::EVENT_FLAGS_INTERRUPT;
637-
auto Cache = getEventCache(Flags, Device);
633+
auto Cache = getEventCache(
634+
Event->HostVisibleEvent, Event->isProfilingEnabled(), Device,
635+
Event->CounterBasedEventsEnabled, Event->InterruptBasedEventsEnabled);
638636
logger::info("Inserting {} event (Host Visible: {}, Profiling: {}, Counter: "
639637
"{}, Device: {}) into cache {}",
640638
Event, Event->HostVisibleEvent, Event->isProfilingEnabled(),

source/adapters/level_zero/context.hpp

+25-6
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ struct ur_context_handle_t_ : _ur_object {
300300
ze_context_handle_t getZeHandle() const;
301301

302302
private:
303+
enum EventFlags {
304+
EVENT_FLAG_HOST_VISIBLE = UR_BIT(0),
305+
EVENT_FLAG_WITH_PROFILING = UR_BIT(1),
306+
EVENT_FLAG_COUNTER = UR_BIT(2),
307+
EVENT_FLAG_INTERRUPT = UR_BIT(3),
308+
EVENT_FLAG_DEVICE = UR_BIT(4), // if set, subsequent bits are device id
309+
MAX_EVENT_FLAG_BITS =
310+
5, // this is used as an offset for embedding device id
311+
};
303312
// Mutex to control operations on event caches.
304313
ur_mutex EventCacheMutex;
305314

@@ -308,20 +317,30 @@ struct ur_context_handle_t_ : _ur_object {
308317
std::vector<EventCache> EventCaches;
309318

310319
// Get the cache of events for a provided scope and profiling mode.
311-
EventCache *getEventCache(v2::event_flags_t Flags,
312-
ur_device_handle_t Device) {
320+
EventCache *getEventCache(bool HostVisible, bool WithProfiling,
321+
ur_device_handle_t Device, bool Counter,
322+
bool Interrupt) {
313323

314324
size_t index = 0;
315-
index |= Flags;
325+
if (HostVisible) {
326+
index |= EVENT_FLAG_HOST_VISIBLE;
327+
}
328+
if (WithProfiling) {
329+
index |= EVENT_FLAG_WITH_PROFILING;
330+
}
331+
if (Counter) {
332+
index |= EVENT_FLAG_COUNTER;
333+
}
334+
if (Interrupt) {
335+
index |= EVENT_FLAG_INTERRUPT;
336+
}
316337
if (Device) {
317-
index |=
318-
v2::EVENT_FLAGS_DEVICE | (*Device->Id << v2::MAX_EVENT_FLAG_BITS);
338+
index |= EVENT_FLAG_DEVICE | (*Device->Id << MAX_EVENT_FLAG_BITS);
319339
}
320340

321341
if (index >= EventCaches.size()) {
322342
EventCaches.resize(index + 1);
323343
}
324-
325344
return &EventCaches[index];
326345
}
327346
};

0 commit comments

Comments
 (0)