@@ -213,19 +213,12 @@ struct ur_context_handle_t_ : _ur_object {
213
213
// slot for a host-visible event. The ProfilingEnabled tells is we need a
214
214
// slot for an event with profiling capabilities.
215
215
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);
222
218
223
219
// 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);
229
222
230
223
// Add ur_event_handle_t to cache.
231
224
void addEventToContextCache (ur_event_handle_t );
@@ -250,15 +243,11 @@ struct ur_context_handle_t_ : _ur_object {
250
243
};
251
244
252
245
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) {
257
247
EventPoolCacheType CacheType;
248
+ bool WithProfiling = Flags & EVENT_FLAG_WITH_PROFILING;
258
249
259
- calculateCacheIndex (HostVisible, CounterBasedEventEnabled,
260
- UsingImmediateCmdList, InterruptBasedEventEnabled,
261
- CacheType);
250
+ calculateCacheIndex (Flags, CacheType);
262
251
if (ZeDevice) {
263
252
auto ZeEventPoolCacheMap =
264
253
WithProfiling ? &ZeEventPoolCacheDeviceMap[CacheType * 2 ]
@@ -275,61 +264,56 @@ struct ur_context_handle_t_ : _ur_object {
275
264
}
276
265
}
277
266
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,
282
268
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
+
283
274
if (InterruptBasedEventEnabled) {
284
275
if (CounterBasedEventEnabled) {
285
276
if (HostVisible) {
286
- if (UsingImmediateCmdList) {
287
- CacheType = HostVisibleInterruptAndCounterBasedImmediateCacheType;
288
- } else {
289
- CacheType = HostVisibleInterruptAndCounterBasedRegularCacheType;
290
- }
277
+ CacheType =
278
+ UsingImmediateCmdList
279
+ ? HostVisibleInterruptAndCounterBasedImmediateCacheType
280
+ : HostVisibleInterruptAndCounterBasedRegularCacheType;
291
281
} else {
292
- if (UsingImmediateCmdList) {
293
- CacheType = HostInvisibleInterruptAndCounterBasedImmediateCacheType;
294
- } else {
295
- CacheType = HostInvisibleInterruptAndCounterBasedRegularCacheType;
296
- }
282
+ CacheType =
283
+ UsingImmediateCmdList
284
+ ? HostInvisibleInterruptAndCounterBasedImmediateCacheType
285
+ : HostInvisibleInterruptAndCounterBasedRegularCacheType;
297
286
}
298
287
} else {
299
288
if (HostVisible) {
300
- if (UsingImmediateCmdList) {
301
- CacheType = HostVisibleInterruptBasedImmediateCacheType;
302
- } else {
303
- CacheType = HostVisibleInterruptBasedRegularCacheType;
304
- }
289
+ CacheType = UsingImmediateCmdList
290
+ ? HostVisibleInterruptBasedImmediateCacheType
291
+ : HostVisibleInterruptBasedRegularCacheType;
305
292
} else {
306
- if (UsingImmediateCmdList) {
307
- CacheType = HostInvisibleInterruptBasedImmediateCacheType;
308
- } else {
309
- CacheType = HostInvisibleInterruptBasedRegularCacheType;
310
- }
293
+ CacheType = UsingImmediateCmdList
294
+ ? HostInvisibleInterruptBasedImmediateCacheType
295
+ : HostInvisibleInterruptBasedRegularCacheType;
311
296
}
312
297
}
313
298
} 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
+ }
327
309
} else {
328
- CacheType = HostInvisibleCacheType;
310
+ CacheType = HostVisible ? HostVisibleCacheType : HostInvisibleCacheType;
329
311
}
330
312
}
331
313
332
314
return UR_RESULT_SUCCESS;
315
+
316
+ return UR_RESULT_SUCCESS;
333
317
}
334
318
335
319
// Decrement number of events living in the pool upon event destroy
@@ -370,16 +354,6 @@ struct ur_context_handle_t_ : _ur_object {
370
354
ze_context_handle_t getZeHandle () const ;
371
355
372
356
private:
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
-
383
357
// Mutex to control operations on event caches.
384
358
ur_mutex EventCacheMutex;
385
359
@@ -388,26 +362,25 @@ struct ur_context_handle_t_ : _ur_object {
388
362
std::vector<EventCache> EventCaches;
389
363
390
364
// 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) {
394
366
395
367
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
+ // }
408
380
if (Device) {
409
381
index |= EVENT_FLAG_DEVICE | (*Device->Id << MAX_EVENT_FLAG_BITS);
410
382
}
383
+ index |= Flags;
411
384
412
385
if (index >= EventCaches.size ()) {
413
386
EventCaches.resize (index + 1 );
0 commit comments