Skip to content

Commit d353943

Browse files
[L0] reverted getEventCache due to test failure
Signed-off-by: Zhang, Winston <[email protected]>
1 parent 3dcd73f commit d353943

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

source/adapters/level_zero/context.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,12 @@ ur_event_handle_t
596596
ur_context_handle_t_::getEventFromContextCache(v2::event_flags_t Flags,
597597
ur_device_handle_t Device) {
598598
std::scoped_lock<ur_mutex> Lock(EventCacheMutex);
599-
auto Cache = getEventCache(Flags, Device);
599+
600+
auto Cache = getEventCache(Flags & v2::EVENT_FLAGS_HOST_VISIBLE,
601+
Flags & v2::EVENT_FLAGS_PROFILING_ENABLED, Device,
602+
Flags & v2::EVENT_FLAGS_COUNTER,
603+
Flags & v2::EVENT_FLAGS_INTERRUPT);
604+
600605
if (Cache->empty()) {
601606
logger::info("Cache empty (Host Visible: {}, Profiling: {}, Counter: {}, "
602607
"Interrupt: {}, Device: {})",
@@ -631,16 +636,9 @@ void ur_context_handle_t_::addEventToContextCache(ur_event_handle_t Event) {
631636
Device = Event->UrQueue->Device;
632637
}
633638

634-
v2::event_flags_t Flags = 0;
635-
if (Event->HostVisibleEvent)
636-
Flags |= v2::EVENT_FLAGS_HOST_VISIBLE;
637-
if (Event->isProfilingEnabled())
638-
Flags |= v2::EVENT_FLAGS_PROFILING_ENABLED;
639-
if (Event->CounterBasedEventsEnabled)
640-
Flags |= v2::EVENT_FLAGS_COUNTER;
641-
if (Event->InterruptBasedEventsEnabled)
642-
Flags |= v2::EVENT_FLAGS_INTERRUPT;
643-
auto Cache = getEventCache(Flags, Device);
639+
auto Cache = getEventCache(
640+
Event->HostVisibleEvent, Event->isProfilingEnabled(), Device,
641+
Event->CounterBasedEventsEnabled, Event->InterruptBasedEventsEnabled);
644642
logger::info("Inserting {} event (Host Visible: {}, Profiling: {}, Counter: "
645643
"{}, Device: {}) into cache {}",
646644
Event, Event->HostVisibleEvent, Event->isProfilingEnabled(),

source/adapters/level_zero/context.hpp

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