@@ -39,6 +39,13 @@ struct ur_context_handle_t_ : _ur_object {
39
39
: ZeContext{ZeContext}, Devices{Devs, Devs + NumDevices},
40
40
NumDevices{NumDevices} {
41
41
OwnNativeHandle = OwnZeContext;
42
+ for (const auto &Device : Devices) {
43
+ for (int i = 0 ; i < EventCacheTypeCount; i++) {
44
+ EventCaches.emplace_back ();
45
+ EventCachesDeviceMap[i].insert (
46
+ std::make_pair (Device, EventCaches.size () - 1 ));
47
+ }
48
+ }
42
49
}
43
50
44
51
ur_context_handle_t_ (ze_context_handle_t ZeContext) : ZeContext{ZeContext} {}
@@ -333,11 +340,6 @@ struct ur_context_handle_t_ : _ur_object {
333
340
auto EventCachesMap =
334
341
WithProfiling ? &EventCachesDeviceMap[HostVisibleProfilingCacheType]
335
342
: &EventCachesDeviceMap[HostVisibleRegularCacheType];
336
- if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
337
- EventCaches.emplace_back ();
338
- EventCachesMap->insert (
339
- std::make_pair (Device, EventCaches.size () - 1 ));
340
- }
341
343
return &EventCaches[(*EventCachesMap)[Device]];
342
344
} else {
343
345
return WithProfiling ? &EventCaches[HostVisibleProfilingCacheType]
@@ -349,11 +351,6 @@ struct ur_context_handle_t_ : _ur_object {
349
351
WithProfiling
350
352
? &EventCachesDeviceMap[HostInvisibleProfilingCacheType]
351
353
: &EventCachesDeviceMap[HostInvisibleRegularCacheType];
352
- if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
353
- EventCaches.emplace_back ();
354
- EventCachesMap->insert (
355
- std::make_pair (Device, EventCaches.size () - 1 ));
356
- }
357
354
return &EventCaches[(*EventCachesMap)[Device]];
358
355
} else {
359
356
return WithProfiling ? &EventCaches[HostInvisibleProfilingCacheType]
@@ -369,11 +366,6 @@ struct ur_context_handle_t_ : _ur_object {
369
366
WithProfiling
370
367
? &EventCachesDeviceMap[CounterBasedImmediateProfilingCacheType]
371
368
: &EventCachesDeviceMap[CounterBasedImmediateCacheType];
372
- if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
373
- EventCaches.emplace_back ();
374
- EventCachesMap->insert (
375
- std::make_pair (Device, EventCaches.size () - 1 ));
376
- }
377
369
return &EventCaches[(*EventCachesMap)[Device]];
378
370
} else {
379
371
return WithProfiling
@@ -386,11 +378,6 @@ struct ur_context_handle_t_ : _ur_object {
386
378
WithProfiling
387
379
? &EventCachesDeviceMap[CounterBasedRegularProfilingCacheType]
388
380
: &EventCachesDeviceMap[CounterBasedRegularCacheType];
389
- if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
390
- EventCaches.emplace_back ();
391
- EventCachesMap->insert (
392
- std::make_pair (Device, EventCaches.size () - 1 ));
393
- }
394
381
return &EventCaches[(*EventCachesMap)[Device]];
395
382
} else {
396
383
return WithProfiling
0 commit comments