@@ -311,62 +311,73 @@ struct ur_context_handle_t_ : _ur_object {
311
311
ze_context_handle_t getZeHandle () const ;
312
312
313
313
private:
314
+ enum EventCacheType {
315
+ HostVisibleProfilingCacheType,
316
+ HostVisibleRegularCacheType,
317
+ HostInvisibleProfilingCacheType,
318
+ HostInvisibleRegularCacheType,
319
+ CounterBasedRegularCacheType,
320
+ CounterBasedImmediateCacheType
321
+ };
314
322
// Get the cache of events for a provided scope and profiling mode.
315
323
auto getEventCache (bool HostVisible, bool WithProfiling,
316
324
ur_device_handle_t Device) {
317
325
if (HostVisible) {
318
326
if (Device) {
319
327
auto EventCachesMap =
320
- WithProfiling ? &EventCachesDeviceMap[0 ] : &EventCachesDeviceMap[1 ];
328
+ WithProfiling ? &EventCachesDeviceMap[HostVisibleProfilingCacheType]
329
+ : &EventCachesDeviceMap[HostVisibleRegularCacheType];
321
330
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
322
331
EventCaches.emplace_back ();
323
- EventCachesMap->insert (
324
- std::make_pair (Device, EventCaches.size () - 1 ));
332
+ EventCaches.insert (std::make_pair (Device, EventCaches.size () - 1 ));
325
333
}
326
334
return &EventCaches[(*EventCachesMap)[Device]];
327
335
} else {
328
- return WithProfiling ? &EventCaches[0 ] : &EventCaches[1 ];
336
+ return WithProfiling ? &EventCaches[HostVisibleProfilingCacheType]
337
+ : &EventCaches[HostVisibleRegularCacheType];
329
338
}
330
339
} else {
331
340
if (Device) {
332
341
auto EventCachesMap =
333
- WithProfiling ? &EventCachesDeviceMap[2 ] : &EventCachesDeviceMap[3 ];
342
+ WithProfiling
343
+ ? &EventCachesDeviceMap[HostInvisibleProfilingCacheType]
344
+ : &EventCachesDeviceMap[HostInvisibleRegularCacheType];
334
345
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
335
346
EventCaches.emplace_back ();
336
- EventCachesMap->insert (
337
- std::make_pair (Device, EventCaches.size () - 1 ));
347
+ EventCaches.insert (std::make_pair (Device, EventCaches.size () - 1 ));
338
348
}
339
349
return &EventCaches[(*EventCachesMap)[Device]];
340
350
} else {
341
- return WithProfiling ? &EventCaches[2 ] : &EventCaches[3 ];
351
+ return WithProfiling ? &EventCaches[HostInvisibleProfilingCacheType]
352
+ : &EventCaches[HostInvisibleRegularCacheType];
342
353
}
343
354
}
344
355
};
345
356
auto getCounterBasedEventCache (bool UsingImmediateCmdList,
346
357
ur_device_handle_t Device) {
347
358
if (UsingImmediateCmdList) {
348
359
if (Device) {
349
- auto EventCachesMap = &EventCachesDeviceMap[4 ];
360
+ auto EventCachesMap =
361
+ &EventCachesDeviceMap[CounterBasedImmediateCacheType];
350
362
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
351
363
EventCaches.emplace_back ();
352
- EventCachesMap->insert (
353
- std::make_pair (Device, EventCaches.size () - 1 ));
364
+ EventCaches.insert (std::make_pair (Device, EventCaches.size () - 1 ));
354
365
}
355
366
return &EventCaches[(*EventCachesMap)[Device]];
356
367
} else {
357
- return &EventCaches[4 ];
368
+ return &EventCaches[CounterBasedImmediateCacheType ];
358
369
}
359
370
} else {
360
371
if (Device) {
361
- auto EventCachesMap = &EventCachesDeviceMap[5 ];
372
+ auto EventCachesMap =
373
+ &EventCachesDeviceMap[CounterBasedRegularCacheType];
362
374
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
363
375
EventCaches.emplace_back ();
364
- EventCachesMap->insert (
365
- std::make_pair (Device, EventCaches.size () - 1 ));
376
+ EventCaches.insert (std::make_pair (Device, EventCaches.size () - 1 ));
366
377
}
367
378
return &EventCaches[(*EventCachesMap)[Device]];
368
379
} else {
369
- return &EventCaches[5 ];
380
+ return &EventCaches[CounterBasedRegularCacheType ];
370
381
}
371
382
}
372
383
}
0 commit comments