File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,7 @@ cdef extern from "dpctl_sycl_event_interface.h":
228
228
cdef void DPCTLEvent_Wait(DPCTLSyclEventRef ERef)
229
229
cdef void DPCTLEvent_Delete(DPCTLSyclEventRef ERef)
230
230
cdef _event_status_type DPCTLEvent_GetCommandExecutionStatus(DPCTLSyclEventRef ERef)
231
+ cdef _backend_type DPCTLEvent_GetBackend(DPCTLSyclEventRef ERef)
231
232
232
233
233
234
cdef extern from " dpctl_sycl_kernel_interface.h" :
Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ from ._backend cimport ( # noqa: E211
29
29
DPCTLEvent_Copy,
30
30
DPCTLEvent_Create,
31
31
DPCTLEvent_Delete,
32
+ DPCTLEvent_GetBackend,
32
33
DPCTLEvent_GetCommandExecutionStatus,
33
34
DPCTLEvent_Wait,
34
35
DPCTLSyclEventRef,
36
+ _backend_type,
35
37
_event_status_type,
36
38
)
37
39
@@ -229,3 +231,19 @@ cdef class SyclEventRaw(_SyclEventRaw):
229
231
return event_status_type.complete
230
232
else :
231
233
raise ValueError (" Unknown event status." )
234
+
235
+ @property
236
+ def backend (self ):
237
+ """ Returns the Sycl backend associated with the event.
238
+ """
239
+ cdef _backend_type BE = DPCTLEvent_GetBackend(self ._event_ref)
240
+ if BE == _backend_type._OPENCL:
241
+ return backend_type.opencl
242
+ elif BE == _backend_type._LEVEL_ZERO:
243
+ return backend_type.level_zero
244
+ elif BE == _backend_type._HOST:
245
+ return backend_type.host
246
+ elif BE == _backend_type._CUDA:
247
+ return backend_type.cuda
248
+ else :
249
+ raise ValueError (" Unknown backend type." )
Original file line number Diff line number Diff line change @@ -80,3 +80,10 @@ def test_execution_status():
80
80
except ValueError :
81
81
pytest .fail ("Failed to get an event status" )
82
82
assert event_status == esty .complete
83
+
84
+
85
+ def test_backend ():
86
+ try :
87
+ dpctl .SyclEventRaw ().backend
88
+ except ValueError :
89
+ pytest .fail ("Failed to get backend from event" )
You can’t perform that action at this time.
0 commit comments