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