@@ -198,17 +198,12 @@ struct ur_context_handle_t_ : _ur_object {
198
198
// slot for a host-visible event. The ProfilingEnabled tells is we need a
199
199
// slot for an event with profiling capabilities.
200
200
ur_result_t getFreeSlotInExistingOrNewPool (ze_event_pool_handle_t &, size_t &,
201
- bool HostVisible,
202
- bool ProfilingEnabled,
203
- ur_device_handle_t Device,
204
- bool CounterBasedEventEnabled,
205
- bool UsingImmCmdList);
201
+ ur_event_flags_t Flags,
202
+ ur_device_handle_t Device);
206
203
207
204
// Get ur_event_handle_t from cache.
208
- ur_event_handle_t getEventFromContextCache (bool HostVisible,
209
- bool WithProfiling,
210
- ur_device_handle_t Device,
211
- bool CounterBasedEventEnabled);
205
+ ur_event_handle_t getEventFromContextCache (ur_event_flags_t Flags,
206
+ ur_device_handle_t Device);
212
207
213
208
// Add ur_event_handle_t to cache.
214
209
void addEventToContextCache (ur_event_handle_t );
@@ -223,50 +218,20 @@ struct ur_context_handle_t_ : _ur_object {
223
218
};
224
219
225
220
std::list<ze_event_pool_handle_t > *
226
- getZeEventPoolCache (bool HostVisible, bool WithProfiling,
227
- bool CounterBasedEventEnabled, bool UsingImmediateCmdList,
228
- ze_device_handle_t ZeDevice) {
229
- EventPoolCacheType CacheType;
230
-
231
- calculateCacheIndex (HostVisible, CounterBasedEventEnabled,
232
- UsingImmediateCmdList, CacheType);
221
+ getZeEventPoolCache (ur_event_flags_t Flags, ze_device_handle_t ZeDevice) {
222
+ Flags = static_cast <ur_event_flag_t >(Flags & ~MULTIDEVICE);
233
223
if (ZeDevice) {
234
224
auto ZeEventPoolCacheMap =
235
- WithProfiling ? &ZeEventPoolCacheDeviceMap[CacheType * 2 ]
236
- : &ZeEventPoolCacheDeviceMap[CacheType * 2 + 1 ];
225
+ &ZeEventPoolCacheDeviceMap[static_cast <int >(Flags)];
237
226
if (ZeEventPoolCacheMap->find (ZeDevice) == ZeEventPoolCacheMap->end ()) {
238
227
ZeEventPoolCache.emplace_back ();
239
228
ZeEventPoolCacheMap->insert (
240
229
std::make_pair (ZeDevice, ZeEventPoolCache.size () - 1 ));
241
230
}
242
231
return &ZeEventPoolCache[(*ZeEventPoolCacheMap)[ZeDevice]];
243
232
} else {
244
- return WithProfiling ? &ZeEventPoolCache[CacheType * 2 ]
245
- : &ZeEventPoolCache[CacheType * 2 + 1 ];
246
- }
247
- }
248
-
249
- ur_result_t calculateCacheIndex (bool HostVisible,
250
- bool CounterBasedEventEnabled,
251
- bool UsingImmediateCmdList,
252
- EventPoolCacheType &CacheType) {
253
- if (CounterBasedEventEnabled && HostVisible && !UsingImmediateCmdList) {
254
- CacheType = HostVisibleCounterBasedRegularCacheType;
255
- } else if (CounterBasedEventEnabled && !HostVisible &&
256
- !UsingImmediateCmdList) {
257
- CacheType = HostInvisibleCounterBasedRegularCacheType;
258
- } else if (CounterBasedEventEnabled && HostVisible &&
259
- UsingImmediateCmdList) {
260
- CacheType = HostVisibleCounterBasedImmediateCacheType;
261
- } else if (CounterBasedEventEnabled && !HostVisible &&
262
- UsingImmediateCmdList) {
263
- CacheType = HostInvisibleCounterBasedImmediateCacheType;
264
- } else if (!CounterBasedEventEnabled && HostVisible) {
265
- CacheType = HostVisibleCacheType;
266
- } else {
267
- CacheType = HostInvisibleCacheType;
233
+ return &ZeEventPoolCache[static_cast <int >(Flags)];
268
234
}
269
- return UR_RESULT_SUCCESS;
270
235
}
271
236
272
237
// Decrement number of events living in the pool upon event destroy
@@ -305,33 +270,34 @@ struct ur_context_handle_t_ : _ur_object {
305
270
306
271
private:
307
272
// Get the cache of events for a provided scope and profiling mode.
308
- auto getEventCache (bool HostVisible, bool WithProfiling,
309
- ur_device_handle_t Device) {
310
- if (HostVisible) {
273
+ auto getEventCache (ur_event_flags_t Flags, ur_device_handle_t Device) {
274
+ if (Flags & HOST_VISIBLE) {
311
275
if (Device) {
312
- auto EventCachesMap =
313
- WithProfiling ? &EventCachesDeviceMap[0 ] : &EventCachesDeviceMap[1 ];
276
+ auto EventCachesMap = Flags & ENABLE_PROFILER
277
+ ? &EventCachesDeviceMap[0 ]
278
+ : &EventCachesDeviceMap[1 ];
314
279
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
315
280
EventCaches.emplace_back ();
316
281
EventCachesMap->insert (
317
282
std::make_pair (Device, EventCaches.size () - 1 ));
318
283
}
319
284
return &EventCaches[(*EventCachesMap)[Device]];
320
285
} else {
321
- return WithProfiling ? &EventCaches[0 ] : &EventCaches[1 ];
286
+ return Flags & ENABLE_PROFILER ? &EventCaches[0 ] : &EventCaches[1 ];
322
287
}
323
288
} else {
324
289
if (Device) {
325
- auto EventCachesMap =
326
- WithProfiling ? &EventCachesDeviceMap[2 ] : &EventCachesDeviceMap[3 ];
290
+ auto EventCachesMap = Flags & ENABLE_PROFILER
291
+ ? &EventCachesDeviceMap[2 ]
292
+ : &EventCachesDeviceMap[3 ];
327
293
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
328
294
EventCaches.emplace_back ();
329
295
EventCachesMap->insert (
330
296
std::make_pair (Device, EventCaches.size () - 1 ));
331
297
}
332
298
return &EventCaches[(*EventCachesMap)[Device]];
333
299
} else {
334
- return WithProfiling ? &EventCaches[2 ] : &EventCaches[3 ];
300
+ return Flags & ENABLE_PROFILER ? &EventCaches[2 ] : &EventCaches[3 ];
335
301
}
336
302
}
337
303
}
0 commit comments