@@ -213,19 +213,12 @@ struct ur_context_handle_t_ : _ur_object {
213213 // slot for a host-visible event. The ProfilingEnabled tells is we need a
214214 // slot for an event with profiling capabilities.
215215 ur_result_t getFreeSlotInExistingOrNewPool (ze_event_pool_handle_t &, size_t &,
216- bool HostVisible,
217- bool ProfilingEnabled,
218- ur_device_handle_t Device,
219- bool CounterBasedEventEnabled,
220- bool UsingImmCmdList,
221- bool InterruptBasedEventEnabled);
216+ ur_event_flags_t Flags,
217+ ur_device_handle_t Device);
222218
223219 // Get ur_event_handle_t from cache.
224- ur_event_handle_t getEventFromContextCache (bool HostVisible,
225- bool WithProfiling,
226- ur_device_handle_t Device,
227- bool CounterBasedEventEnabled,
228- bool InterruptBasedEventEnabled);
220+ ur_event_handle_t getEventFromContextCache (ur_event_flags_t Flags,
221+ ur_device_handle_t Device);
229222
230223 // Add ur_event_handle_t to cache.
231224 void addEventToContextCache (ur_event_handle_t );
@@ -250,15 +243,11 @@ struct ur_context_handle_t_ : _ur_object {
250243 };
251244
252245 std::list<ze_event_pool_handle_t > *
253- getZeEventPoolCache (bool HostVisible, bool WithProfiling,
254- bool CounterBasedEventEnabled, bool UsingImmediateCmdList,
255- bool InterruptBasedEventEnabled,
256- ze_device_handle_t ZeDevice) {
246+ getZeEventPoolCache (ur_event_flags_t Flags, ze_device_handle_t ZeDevice) {
257247 EventPoolCacheType CacheType;
248+ bool WithProfiling = Flags & EVENT_FLAG_WITH_PROFILING;
258249
259- calculateCacheIndex (HostVisible, CounterBasedEventEnabled,
260- UsingImmediateCmdList, InterruptBasedEventEnabled,
261- CacheType);
250+ calculateCacheIndex (Flags, CacheType);
262251 if (ZeDevice) {
263252 auto ZeEventPoolCacheMap =
264253 WithProfiling ? &ZeEventPoolCacheDeviceMap[CacheType * 2 ]
@@ -275,61 +264,56 @@ struct ur_context_handle_t_ : _ur_object {
275264 }
276265 }
277266
278- ur_result_t calculateCacheIndex (bool HostVisible,
279- bool CounterBasedEventEnabled,
280- bool UsingImmediateCmdList,
281- bool InterruptBasedEventEnabled,
267+ ur_result_t calculateCacheIndex (ur_event_flags_t Flags,
282268 EventPoolCacheType &CacheType) {
269+ bool InterruptBasedEventEnabled = Flags & EVENT_FLAG_INTERRUPT;
270+ bool CounterBasedEventEnabled = Flags & EVENT_FLAG_COUNTER;
271+ bool HostVisible = Flags & EVENT_FLAG_HOST_VISIBLE;
272+ bool UsingImmediateCmdList = Flags & EVENT_FLAG_IMM_CMDLIST;
273+
283274 if (InterruptBasedEventEnabled) {
284275 if (CounterBasedEventEnabled) {
285276 if (HostVisible) {
286- if (UsingImmediateCmdList) {
287- CacheType = HostVisibleInterruptAndCounterBasedImmediateCacheType;
288- } else {
289- CacheType = HostVisibleInterruptAndCounterBasedRegularCacheType;
290- }
277+ CacheType =
278+ UsingImmediateCmdList
279+ ? HostVisibleInterruptAndCounterBasedImmediateCacheType
280+ : HostVisibleInterruptAndCounterBasedRegularCacheType;
291281 } else {
292- if (UsingImmediateCmdList) {
293- CacheType = HostInvisibleInterruptAndCounterBasedImmediateCacheType;
294- } else {
295- CacheType = HostInvisibleInterruptAndCounterBasedRegularCacheType;
296- }
282+ CacheType =
283+ UsingImmediateCmdList
284+ ? HostInvisibleInterruptAndCounterBasedImmediateCacheType
285+ : HostInvisibleInterruptAndCounterBasedRegularCacheType;
297286 }
298287 } else {
299288 if (HostVisible) {
300- if (UsingImmediateCmdList) {
301- CacheType = HostVisibleInterruptBasedImmediateCacheType;
302- } else {
303- CacheType = HostVisibleInterruptBasedRegularCacheType;
304- }
289+ CacheType = UsingImmediateCmdList
290+ ? HostVisibleInterruptBasedImmediateCacheType
291+ : HostVisibleInterruptBasedRegularCacheType;
305292 } else {
306- if (UsingImmediateCmdList) {
307- CacheType = HostInvisibleInterruptBasedImmediateCacheType;
308- } else {
309- CacheType = HostInvisibleInterruptBasedRegularCacheType;
310- }
293+ CacheType = UsingImmediateCmdList
294+ ? HostInvisibleInterruptBasedImmediateCacheType
295+ : HostInvisibleInterruptBasedRegularCacheType;
311296 }
312297 }
313298 } else {
314- if (CounterBasedEventEnabled && HostVisible && !UsingImmediateCmdList) {
315- CacheType = HostVisibleCounterBasedRegularCacheType;
316- } else if (CounterBasedEventEnabled && !HostVisible &&
317- !UsingImmediateCmdList) {
318- CacheType = HostInvisibleCounterBasedRegularCacheType;
319- } else if (CounterBasedEventEnabled && HostVisible &&
320- UsingImmediateCmdList) {
321- CacheType = HostVisibleCounterBasedImmediateCacheType;
322- } else if (CounterBasedEventEnabled && !HostVisible &&
323- UsingImmediateCmdList) {
324- CacheType = HostInvisibleCounterBasedImmediateCacheType;
325- } else if (!CounterBasedEventEnabled && HostVisible) {
326- CacheType = HostVisibleCacheType;
299+ if (CounterBasedEventEnabled) {
300+ if (HostVisible) {
301+ CacheType = UsingImmediateCmdList
302+ ? HostVisibleCounterBasedImmediateCacheType
303+ : HostVisibleCounterBasedRegularCacheType;
304+ } else {
305+ CacheType = UsingImmediateCmdList
306+ ? HostInvisibleCounterBasedImmediateCacheType
307+ : HostInvisibleCounterBasedRegularCacheType;
308+ }
327309 } else {
328- CacheType = HostInvisibleCacheType;
310+ CacheType = HostVisible ? HostVisibleCacheType : HostInvisibleCacheType;
329311 }
330312 }
331313
332314 return UR_RESULT_SUCCESS;
315+
316+ return UR_RESULT_SUCCESS;
333317 }
334318
335319 // Decrement number of events living in the pool upon event destroy
@@ -370,16 +354,6 @@ struct ur_context_handle_t_ : _ur_object {
370354 ze_context_handle_t getZeHandle () const ;
371355
372356private:
373- enum EventFlags {
374- EVENT_FLAG_HOST_VISIBLE = UR_BIT (0 ),
375- EVENT_FLAG_WITH_PROFILING = UR_BIT (1 ),
376- EVENT_FLAG_COUNTER = UR_BIT (2 ),
377- EVENT_FLAG_INTERRUPT = UR_BIT (3 ),
378- EVENT_FLAG_DEVICE = UR_BIT (4 ), // if set, subsequent bits are device id
379- MAX_EVENT_FLAG_BITS =
380- 5 , // this is used as an offset for embedding device id
381- };
382-
383357 // Mutex to control operations on event caches.
384358 ur_mutex EventCacheMutex;
385359
@@ -388,26 +362,25 @@ struct ur_context_handle_t_ : _ur_object {
388362 std::vector<EventCache> EventCaches;
389363
390364 // Get the cache of events for a provided scope and profiling mode.
391- EventCache *getEventCache (bool HostVisible, bool WithProfiling,
392- ur_device_handle_t Device, bool Counter,
393- bool Interrupt) {
365+ EventCache *getEventCache (ur_event_flags_t Flags, ur_device_handle_t Device) {
394366
395367 size_t index = 0 ;
396- if (HostVisible) {
397- index |= EVENT_FLAG_HOST_VISIBLE;
398- }
399- if (WithProfiling) {
400- index |= EVENT_FLAG_WITH_PROFILING;
401- }
402- if (Counter) {
403- index |= EVENT_FLAG_COUNTER;
404- }
405- if (Interrupt) {
406- index |= EVENT_FLAG_INTERRUPT;
407- }
368+ // if (HostVisible) {
369+ // index |= EVENT_FLAG_HOST_VISIBLE;
370+ // }
371+ // if (WithProfiling) {
372+ // index |= EVENT_FLAG_WITH_PROFILING;
373+ // }
374+ // if (Counter) {
375+ // index |= EVENT_FLAG_COUNTER;
376+ // }
377+ // if (Interrupt) {
378+ // index |= EVENT_FLAG_INTERRUPT;
379+ // }
408380 if (Device) {
409381 index |= EVENT_FLAG_DEVICE | (*Device->Id << MAX_EVENT_FLAG_BITS);
410382 }
383+ index |= Flags;
411384
412385 if (index >= EventCaches.size ()) {
413386 EventCaches.resize (index + 1 );
0 commit comments