@@ -33,6 +33,24 @@ struct l0_command_list_cache_info {
3333 bool IsImmediate = false ;
3434};
3535
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+
3654struct ur_context_handle_t_ : _ur_object {
3755 ur_context_handle_t_ (ze_context_handle_t ZeContext, uint32_t NumDevices,
3856 const ur_device_handle_t *Devs, bool OwnZeContext)
@@ -150,9 +168,9 @@ struct ur_context_handle_t_ : _ur_object {
150168 // head.
151169 //
152170 // 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 };
154172 std::vector<std::unordered_map<ze_device_handle_t , size_t >>
155- ZeEventPoolCacheDeviceMap{12 };
173+ ZeEventPoolCacheDeviceMap{30 };
156174
157175 // This map will be used to determine if a pool is full or not
158176 // by storing number of empty slots available in the pool.
@@ -199,13 +217,15 @@ struct ur_context_handle_t_ : _ur_object {
199217 bool ProfilingEnabled,
200218 ur_device_handle_t Device,
201219 bool CounterBasedEventEnabled,
202- bool UsingImmCmdList);
220+ bool UsingImmCmdList,
221+ bool InterruptBasedEventEnabled);
203222
204223 // Get ur_event_handle_t from cache.
205224 ur_event_handle_t getEventFromContextCache (bool HostVisible,
206225 bool WithProfiling,
207226 ur_device_handle_t Device,
208- bool CounterBasedEventEnabled);
227+ bool CounterBasedEventEnabled,
228+ bool InterruptBasedEventEnabled);
209229
210230 // Add ur_event_handle_t to cache.
211231 void addEventToContextCache (ur_event_handle_t );
@@ -216,17 +236,29 @@ struct ur_context_handle_t_ : _ur_object {
216236 HostVisibleCounterBasedRegularCacheType,
217237 HostInvisibleCounterBasedRegularCacheType,
218238 HostVisibleCounterBasedImmediateCacheType,
219- HostInvisibleCounterBasedImmediateCacheType
239+ HostInvisibleCounterBasedImmediateCacheType,
240+
241+ HostVisibleInterruptBasedRegularCacheType,
242+ HostInvisibleInterruptBasedRegularCacheType,
243+ HostVisibleInterruptBasedImmediateCacheType,
244+ HostInvisibleInterruptBasedImmediateCacheType,
245+
246+ HostVisibleInterruptAndCounterBasedRegularCacheType,
247+ HostInvisibleInterruptAndCounterBasedRegularCacheType,
248+ HostVisibleInterruptAndCounterBasedImmediateCacheType,
249+ HostInvisibleInterruptAndCounterBasedImmediateCacheType
220250 };
221251
222252 std::list<ze_event_pool_handle_t > *
223253 getZeEventPoolCache (bool HostVisible, bool WithProfiling,
224254 bool CounterBasedEventEnabled, bool UsingImmediateCmdList,
255+ bool InterruptBasedEventEnabled,
225256 ze_device_handle_t ZeDevice) {
226257 EventPoolCacheType CacheType;
227258
228259 calculateCacheIndex (HostVisible, CounterBasedEventEnabled,
229- UsingImmediateCmdList, CacheType);
260+ UsingImmediateCmdList, InterruptBasedEventEnabled,
261+ CacheType);
230262 if (ZeDevice) {
231263 auto ZeEventPoolCacheMap =
232264 WithProfiling ? &ZeEventPoolCacheDeviceMap[CacheType * 2 ]
@@ -246,23 +278,57 @@ struct ur_context_handle_t_ : _ur_object {
246278 ur_result_t calculateCacheIndex (bool HostVisible,
247279 bool CounterBasedEventEnabled,
248280 bool UsingImmediateCmdList,
281+ bool InterruptBasedEventEnabled,
249282 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+ }
263313 } 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+ }
265330 }
331+
266332 return UR_RESULT_SUCCESS;
267333 }
268334
@@ -308,9 +374,10 @@ struct ur_context_handle_t_ : _ur_object {
308374 EVENT_FLAG_HOST_VISIBLE = UR_BIT (0 ),
309375 EVENT_FLAG_WITH_PROFILING = UR_BIT (1 ),
310376 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
312379 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
314381 };
315382
316383 // Mutex to control operations on event caches.
@@ -322,7 +389,8 @@ struct ur_context_handle_t_ : _ur_object {
322389
323390 // Get the cache of events for a provided scope and profiling mode.
324391 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) {
326394
327395 size_t index = 0 ;
328396 if (HostVisible) {
@@ -334,6 +402,9 @@ struct ur_context_handle_t_ : _ur_object {
334402 if (Counter) {
335403 index |= EVENT_FLAG_COUNTER;
336404 }
405+ if (Interrupt) {
406+ index |= EVENT_FLAG_INTERRUPT;
407+ }
337408 if (Device) {
338409 index |= EVENT_FLAG_DEVICE | (*Device->Id << MAX_EVENT_FLAG_BITS);
339410 }
0 commit comments