File tree Expand file tree Collapse file tree 5 files changed +48
-1
lines changed
Expand file tree Collapse file tree 5 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 6565)
6666
6767from ._version import get_versions
68- from .enum_types import backend_type , device_type
68+ from .enum_types import backend_type , device_type , event_status_type
6969
7070__all__ = [
7171 "SyclContext" ,
113113__all__ += [
114114 "device_type" ,
115115 "backend_type" ,
116+ "event_status_type" ,
116117]
117118__all__ += [
118119 "get_include" ,
Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ cdef extern from "dpctl_sycl_enum_types.h":
104104 _L1_cache ' L1_cache' ,
105105 _next_partitionable ' next_partitionable' ,
106106
107+ ctypedef enum _event_status_type ' DPCTLSyclEventStatusType' :
108+ _UNKNOWN_STATUS ' DPCTL_UNKNOWN_STATUS'
109+ _SUBMITTED ' DPCTL_SUBMITTED'
110+ _RUNNING ' DPCTL_RUNNING'
111+ _COMPLETE ' DPCTL_COMPLETE'
112+
107113
108114cdef extern from " dpctl_sycl_types.h" :
109115 cdef struct DPCTLOpaqueSyclContext
@@ -221,6 +227,7 @@ cdef extern from "dpctl_sycl_event_interface.h":
221227 cdef DPCTLSyclEventRef DPCTLEvent_Copy(const DPCTLSyclEventRef ERef)
222228 cdef void DPCTLEvent_Wait(DPCTLSyclEventRef ERef)
223229 cdef void DPCTLEvent_Delete(DPCTLSyclEventRef ERef)
230+ cdef _event_status_type DPCTLEvent_GetCommandExecutionStatus(DPCTLSyclEventRef ERef)
224231
225232
226233cdef extern from " dpctl_sycl_kernel_interface.h" :
Original file line number Diff line number Diff line change @@ -29,10 +29,14 @@ from ._backend cimport ( # noqa: E211
2929 DPCTLEvent_Copy,
3030 DPCTLEvent_Create,
3131 DPCTLEvent_Delete,
32+ DPCTLEvent_GetCommandExecutionStatus,
3233 DPCTLEvent_Wait,
3334 DPCTLSyclEventRef,
35+ _event_status_type,
3436)
3537
38+ from .enum_types import backend_type, event_status_type
39+
3640__all__ = [
3741 " SyclEvent" ,
3842 " SyclEventRaw" ,
@@ -209,3 +213,19 @@ cdef class SyclEventRaw(_SyclEventRaw):
209213 " SyclEventRef" ,
210214 & _event_capsule_deleter
211215 )
216+
217+ @property
218+ def execution_status (self ):
219+ """ Returns the event status.
220+ """
221+ cdef _event_status_type ESTy = DPCTLEvent_GetCommandExecutionStatus(
222+ self ._event_ref
223+ )
224+ if ESTy == _event_status_type._SUBMITTED:
225+ return event_status_type.submitted
226+ elif ESTy == _event_status_type._RUNNING:
227+ return event_status_type.running
228+ elif ESTy == _event_status_type._COMPLETE:
229+ return event_status_type.complete
230+ else :
231+ raise ValueError (" Unknown event status." )
Original file line number Diff line number Diff line change 2525__all__ = [
2626 "device_type" ,
2727 "backend_type" ,
28+ "event_status_type" ,
2829]
2930
3031
@@ -71,3 +72,11 @@ class backend_type(Enum):
7172 host = auto ()
7273 level_zero = auto ()
7374 opencl = auto ()
75+
76+
77+ class event_status_type (Enum ):
78+
79+ unknown_status = auto ()
80+ submitted = auto ()
81+ running = auto ()
82+ complete = auto ()
Original file line number Diff line number Diff line change 2323import dpctl
2424import dpctl .memory as dpctl_mem
2525import dpctl .program as dpctl_prog
26+ from dpctl import event_status_type as esty
2627
2728from ._helper import has_cpu
2829
@@ -70,3 +71,12 @@ def test_create_event_raw_from_capsule():
7071 dpctl .SyclEventRaw (event_capsule )
7172 except ValueError :
7273 pytest .fail ("Failed to create an event from capsule" )
74+
75+
76+ def test_execution_status ():
77+ event = dpctl .SyclEventRaw ()
78+ try :
79+ event_status = event .execution_status
80+ except ValueError :
81+ pytest .fail ("Failed to get an event status" )
82+ assert event_status == esty .complete
You can’t perform that action at this time.
0 commit comments