@@ -33,6 +33,24 @@ struct l0_command_list_cache_info {
33
33
bool IsImmediate = false ;
34
34
};
35
35
36
+ typedef uint32_t ze_intel_event_sync_mode_exp_flags_t ;
37
+ typedef enum _ze_intel_event_sync_mode_exp_flag_t {
38
+ ZE_INTEL_EVENT_SYNC_MODE_EXP_FLAG_LOW_POWER_WAIT = ZE_BIT (0 ),
39
+ ZE_INTEL_EVENT_SYNC_MODE_EXP_FLAG_SIGNAL_INTERRUPT = ZE_BIT (1 ),
40
+ ZE_INTEL_EVENT_SYNC_MODE_EXP_EXP_FLAG_FORCE_UINT32 = 0x7fffffff
41
+
42
+ } ze_intel_event_sync_mode_exp_flag_t ;
43
+
44
+ #define ZE_INTEL_STRUCTURE_TYPE_EVENT_SYNC_MODE_EXP_DESC \
45
+ (ze_structure_type_t )0x00030016
46
+
47
+ typedef struct _ze_intel_event_sync_mode_exp_desc_t {
48
+ ze_structure_type_t stype;
49
+ const void *pNext;
50
+
51
+ ze_intel_event_sync_mode_exp_flags_t syncModeFlags;
52
+ } ze_intel_event_sync_mode_exp_desc_t ;
53
+
36
54
struct ur_context_handle_t_ : _ur_object {
37
55
ur_context_handle_t_ (ze_context_handle_t ZeContext, uint32_t NumDevices,
38
56
const ur_device_handle_t *Devs, bool OwnZeContext)
@@ -150,9 +168,9 @@ struct ur_context_handle_t_ : _ur_object {
150
168
// head.
151
169
//
152
170
// Cache of event pools to which host-visible events are added to.
153
- std::vector<std::list<ze_event_pool_handle_t >> ZeEventPoolCache{12 };
171
+ std::vector<std::list<ze_event_pool_handle_t >> ZeEventPoolCache{30 };
154
172
std::vector<std::unordered_map<ze_device_handle_t , size_t >>
155
- ZeEventPoolCacheDeviceMap{12 };
173
+ ZeEventPoolCacheDeviceMap{30 };
156
174
157
175
// This map will be used to determine if a pool is full or not
158
176
// by storing number of empty slots available in the pool.
@@ -199,13 +217,15 @@ struct ur_context_handle_t_ : _ur_object {
199
217
bool ProfilingEnabled,
200
218
ur_device_handle_t Device,
201
219
bool CounterBasedEventEnabled,
202
- bool UsingImmCmdList);
220
+ bool UsingImmCmdList,
221
+ bool InterruptBasedEventEnabled);
203
222
204
223
// Get ur_event_handle_t from cache.
205
224
ur_event_handle_t getEventFromContextCache (bool HostVisible,
206
225
bool WithProfiling,
207
226
ur_device_handle_t Device,
208
- bool CounterBasedEventEnabled);
227
+ bool CounterBasedEventEnabled,
228
+ bool InterruptBasedEventEnabled);
209
229
210
230
// Add ur_event_handle_t to cache.
211
231
void addEventToContextCache (ur_event_handle_t );
@@ -216,17 +236,29 @@ struct ur_context_handle_t_ : _ur_object {
216
236
HostVisibleCounterBasedRegularCacheType,
217
237
HostInvisibleCounterBasedRegularCacheType,
218
238
HostVisibleCounterBasedImmediateCacheType,
219
- HostInvisibleCounterBasedImmediateCacheType
239
+ HostInvisibleCounterBasedImmediateCacheType,
240
+
241
+ HostVisibleInterruptBasedRegularCacheType,
242
+ HostInvisibleInterruptBasedRegularCacheType,
243
+ HostVisibleInterruptBasedImmediateCacheType,
244
+ HostInvisibleInterruptBasedImmediateCacheType,
245
+
246
+ HostVisibleInterruptAndCounterBasedRegularCacheType,
247
+ HostInvisibleInterruptAndCounterBasedRegularCacheType,
248
+ HostVisibleInterruptAndCounterBasedImmediateCacheType,
249
+ HostInvisibleInterruptAndCounterBasedImmediateCacheType
220
250
};
221
251
222
252
std::list<ze_event_pool_handle_t > *
223
253
getZeEventPoolCache (bool HostVisible, bool WithProfiling,
224
254
bool CounterBasedEventEnabled, bool UsingImmediateCmdList,
255
+ bool InterruptBasedEventEnabled,
225
256
ze_device_handle_t ZeDevice) {
226
257
EventPoolCacheType CacheType;
227
258
228
259
calculateCacheIndex (HostVisible, CounterBasedEventEnabled,
229
- UsingImmediateCmdList, CacheType);
260
+ UsingImmediateCmdList, InterruptBasedEventEnabled,
261
+ CacheType);
230
262
if (ZeDevice) {
231
263
auto ZeEventPoolCacheMap =
232
264
WithProfiling ? &ZeEventPoolCacheDeviceMap[CacheType * 2 ]
@@ -246,23 +278,57 @@ struct ur_context_handle_t_ : _ur_object {
246
278
ur_result_t calculateCacheIndex (bool HostVisible,
247
279
bool CounterBasedEventEnabled,
248
280
bool UsingImmediateCmdList,
281
+ bool InterruptBasedEventEnabled,
249
282
EventPoolCacheType &CacheType) {
250
- if (CounterBasedEventEnabled && HostVisible && !UsingImmediateCmdList) {
251
- CacheType = HostVisibleCounterBasedRegularCacheType;
252
- } else if (CounterBasedEventEnabled && !HostVisible &&
253
- !UsingImmediateCmdList) {
254
- CacheType = HostInvisibleCounterBasedRegularCacheType;
255
- } else if (CounterBasedEventEnabled && HostVisible &&
256
- UsingImmediateCmdList) {
257
- CacheType = HostVisibleCounterBasedImmediateCacheType;
258
- } else if (CounterBasedEventEnabled && !HostVisible &&
259
- UsingImmediateCmdList) {
260
- CacheType = HostInvisibleCounterBasedImmediateCacheType;
261
- } else if (!CounterBasedEventEnabled && HostVisible) {
262
- CacheType = HostVisibleCacheType;
283
+ if (InterruptBasedEventEnabled) {
284
+ if (CounterBasedEventEnabled) {
285
+ if (HostVisible) {
286
+ if (UsingImmediateCmdList) {
287
+ CacheType = HostVisibleInterruptAndCounterBasedImmediateCacheType;
288
+ } else {
289
+ CacheType = HostVisibleInterruptAndCounterBasedRegularCacheType;
290
+ }
291
+ } else {
292
+ if (UsingImmediateCmdList) {
293
+ CacheType = HostInvisibleInterruptAndCounterBasedImmediateCacheType;
294
+ } else {
295
+ CacheType = HostInvisibleInterruptAndCounterBasedRegularCacheType;
296
+ }
297
+ }
298
+ } else {
299
+ if (HostVisible) {
300
+ if (UsingImmediateCmdList) {
301
+ CacheType = HostVisibleInterruptBasedImmediateCacheType;
302
+ } else {
303
+ CacheType = HostVisibleInterruptBasedRegularCacheType;
304
+ }
305
+ } else {
306
+ if (UsingImmediateCmdList) {
307
+ CacheType = HostInvisibleInterruptBasedImmediateCacheType;
308
+ } else {
309
+ CacheType = HostInvisibleInterruptBasedRegularCacheType;
310
+ }
311
+ }
312
+ }
263
313
} else {
264
- CacheType = HostInvisibleCacheType;
314
+ if (CounterBasedEventEnabled && HostVisible && !UsingImmediateCmdList) {
315
+ CacheType = HostVisibleCounterBasedRegularCacheType;
316
+ } else if (CounterBasedEventEnabled && !HostVisible &&
317
+ !UsingImmediateCmdList) {
318
+ CacheType = HostInvisibleCounterBasedRegularCacheType;
319
+ } else if (CounterBasedEventEnabled && HostVisible &&
320
+ UsingImmediateCmdList) {
321
+ CacheType = HostVisibleCounterBasedImmediateCacheType;
322
+ } else if (CounterBasedEventEnabled && !HostVisible &&
323
+ UsingImmediateCmdList) {
324
+ CacheType = HostInvisibleCounterBasedImmediateCacheType;
325
+ } else if (!CounterBasedEventEnabled && HostVisible) {
326
+ CacheType = HostVisibleCacheType;
327
+ } else {
328
+ CacheType = HostInvisibleCacheType;
329
+ }
265
330
}
331
+
266
332
return UR_RESULT_SUCCESS;
267
333
}
268
334
@@ -308,9 +374,10 @@ struct ur_context_handle_t_ : _ur_object {
308
374
EVENT_FLAG_HOST_VISIBLE = UR_BIT (0 ),
309
375
EVENT_FLAG_WITH_PROFILING = UR_BIT (1 ),
310
376
EVENT_FLAG_COUNTER = UR_BIT (2 ),
311
- EVENT_FLAG_DEVICE = UR_BIT (3 ), // if set, subsequent bits are device id
377
+ EVENT_FLAG_INTERRUPT = UR_BIT (3 ),
378
+ EVENT_FLAG_DEVICE = UR_BIT (4 ), // if set, subsequent bits are device id
312
379
MAX_EVENT_FLAG_BITS =
313
- 4 , // this is used as an offset for embedding device id
380
+ 5 , // this is used as an offset for embedding device id
314
381
};
315
382
316
383
// Mutex to control operations on event caches.
@@ -322,7 +389,8 @@ struct ur_context_handle_t_ : _ur_object {
322
389
323
390
// Get the cache of events for a provided scope and profiling mode.
324
391
EventCache *getEventCache (bool HostVisible, bool WithProfiling,
325
- ur_device_handle_t Device, bool Counter) {
392
+ ur_device_handle_t Device, bool Counter,
393
+ bool Interrupt) {
326
394
327
395
size_t index = 0 ;
328
396
if (HostVisible) {
@@ -334,6 +402,9 @@ struct ur_context_handle_t_ : _ur_object {
334
402
if (Counter) {
335
403
index |= EVENT_FLAG_COUNTER;
336
404
}
405
+ if (Interrupt) {
406
+ index |= EVENT_FLAG_INTERRUPT;
407
+ }
337
408
if (Device) {
338
409
index |= EVENT_FLAG_DEVICE | (*Device->Id << MAX_EVENT_FLAG_BITS);
339
410
}
0 commit comments