@@ -201,75 +201,38 @@ 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 );
218
213
219
- enum EventPoolCacheType {
220
- HostVisibleCacheType,
221
- HostInvisibleCacheType,
222
- HostVisibleCounterBasedRegularCacheType,
223
- HostInvisibleCounterBasedRegularCacheType,
224
- HostVisibleCounterBasedImmediateCacheType,
225
- HostInvisibleCounterBasedImmediateCacheType
226
- };
227
-
228
214
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;
215
+ getZeEventPoolCache (ur_event_flags_t Flags, ze_device_handle_t ZeDevice) {
216
+ bool WithProfiling = Flags & ENABLE_PROFILER;
217
+ Flags &= ~ENABLE_PROFILER;
218
+ Flags &= ~MULTIDEVICE;
219
+ int index = static_cast <int >(Flags);
220
+ (Flags & COUNTER_BASED) ? index /= 2 : (index - 2 );
233
221
234
- calculateCacheIndex (HostVisible, CounterBasedEventEnabled,
235
- UsingImmediateCmdList, CacheType);
236
222
if (ZeDevice) {
237
223
auto ZeEventPoolCacheMap =
238
- WithProfiling ? &ZeEventPoolCacheDeviceMap[CacheType * 2 ]
239
- : &ZeEventPoolCacheDeviceMap[CacheType * 2 + 1 ];
224
+ WithProfiling ? &ZeEventPoolCacheDeviceMap[index * 2 ]
225
+ : &ZeEventPoolCacheDeviceMap[index * 2 + 1 ];
240
226
if (ZeEventPoolCacheMap->find (ZeDevice) == ZeEventPoolCacheMap->end ()) {
241
227
ZeEventPoolCache.emplace_back ();
242
228
ZeEventPoolCacheMap->insert (
243
229
std::make_pair (ZeDevice, ZeEventPoolCache.size () - 1 ));
244
230
}
245
231
return &ZeEventPoolCache[(*ZeEventPoolCacheMap)[ZeDevice]];
246
232
} 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;
233
+ return WithProfiling ? &ZeEventPoolCache[index * 2 ]
234
+ : &ZeEventPoolCache[index * 2 + 1 ];
271
235
}
272
- return UR_RESULT_SUCCESS;
273
236
}
274
237
275
238
// Decrement number of events living in the pool upon event destroy
@@ -311,33 +274,34 @@ struct ur_context_handle_t_ : _ur_object {
311
274
312
275
private:
313
276
// 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) {
277
+ auto getEventCache (ur_event_flags_t Flags, ur_device_handle_t Device) {
278
+ if (Flags & HOST_VISIBLE) {
317
279
if (Device) {
318
- auto EventCachesMap =
319
- WithProfiling ? &EventCachesDeviceMap[0 ] : &EventCachesDeviceMap[1 ];
280
+ auto EventCachesMap = (Flags & ENABLE_PROFILER)
281
+ ? &EventCachesDeviceMap[0 ]
282
+ : &EventCachesDeviceMap[1 ];
320
283
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
321
284
EventCaches.emplace_back ();
322
285
EventCachesMap->insert (
323
286
std::make_pair (Device, EventCaches.size () - 1 ));
324
287
}
325
288
return &EventCaches[(*EventCachesMap)[Device]];
326
289
} else {
327
- return WithProfiling ? &EventCaches[0 ] : &EventCaches[1 ];
290
+ return (Flags & ENABLE_PROFILER) ? &EventCaches[0 ] : &EventCaches[1 ];
328
291
}
329
292
} else {
330
293
if (Device) {
331
- auto EventCachesMap =
332
- WithProfiling ? &EventCachesDeviceMap[2 ] : &EventCachesDeviceMap[3 ];
294
+ auto EventCachesMap = (Flags & ENABLE_PROFILER)
295
+ ? &EventCachesDeviceMap[2 ]
296
+ : &EventCachesDeviceMap[3 ];
333
297
if (EventCachesMap->find (Device) == EventCachesMap->end ()) {
334
298
EventCaches.emplace_back ();
335
299
EventCachesMap->insert (
336
300
std::make_pair (Device, EventCaches.size () - 1 ));
337
301
}
338
302
return &EventCaches[(*EventCachesMap)[Device]];
339
303
} else {
340
- return WithProfiling ? &EventCaches[2 ] : &EventCaches[3 ];
304
+ return (Flags & ENABLE_PROFILER) ? &EventCaches[2 ] : &EventCaches[3 ];
341
305
}
342
306
}
343
307
}
0 commit comments