Skip to content

Commit b67162f

Browse files
Merge pull request #553 from IntelPython/refactor/SyclEvent
Refactor/sycl event
2 parents 4e1c92b + b9f4fe7 commit b67162f

File tree

8 files changed

+631
-27
lines changed

8 files changed

+631
-27
lines changed

dpctl/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
)
6666

6767
from ._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",
@@ -88,6 +88,7 @@
8888
]
8989
__all__ += [
9090
"SyclEvent",
91+
"SyclEventRaw",
9192
]
9293
__all__ += [
9394
"get_platforms",
@@ -112,6 +113,7 @@
112113
__all__ += [
113114
"device_type",
114115
"backend_type",
116+
"event_status_type",
115117
]
116118
__all__ += [
117119
"get_include",

dpctl/_backend.pxd

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
types defined by dpctl's C API.
2222
"""
2323

24-
from libc.stdint cimport int64_t, uint32_t
24+
from libc.stdint cimport int64_t, uint32_t, uint64_t
2525
from libcpp cimport bool
2626

2727

@@ -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

108114
cdef extern from "dpctl_sycl_types.h":
109115
cdef struct DPCTLOpaqueSyclContext
@@ -217,8 +223,25 @@ cdef extern from "dpctl_sycl_device_selector_interface.h":
217223

218224

219225
cdef extern from "dpctl_sycl_event_interface.h":
226+
cdef DPCTLSyclEventRef DPCTLEvent_Create()
227+
cdef DPCTLSyclEventRef DPCTLEvent_Copy(const DPCTLSyclEventRef ERef)
220228
cdef void DPCTLEvent_Wait(DPCTLSyclEventRef ERef)
229+
cdef void DPCTLEvent_WaitAndThrow(DPCTLSyclEventRef ERef)
221230
cdef void DPCTLEvent_Delete(DPCTLSyclEventRef ERef)
231+
cdef _event_status_type DPCTLEvent_GetCommandExecutionStatus(DPCTLSyclEventRef ERef)
232+
cdef _backend_type DPCTLEvent_GetBackend(DPCTLSyclEventRef ERef)
233+
cdef struct DPCTLEventVector
234+
ctypedef DPCTLEventVector *DPCTLEventVectorRef
235+
cdef void DPCTLEventVector_Delete(DPCTLEventVectorRef EVRef)
236+
cdef size_t DPCTLEventVector_Size(DPCTLEventVectorRef EVRef)
237+
cdef DPCTLSyclEventRef DPCTLEventVector_GetAt(
238+
DPCTLEventVectorRef EVRef,
239+
size_t index)
240+
cdef DPCTLEventVectorRef DPCTLEvent_GetWaitList(
241+
DPCTLSyclEventRef ERef)
242+
cdef uint64_t DPCTLEvent_GetProfilingInfoSubmit(DPCTLSyclEventRef ERef)
243+
cdef uint64_t DPCTLEvent_GetProfilingInfoStart(DPCTLSyclEventRef ERef)
244+
cdef uint64_t DPCTLEvent_GetProfilingInfoEnd(DPCTLSyclEventRef ERef)
222245

223246

224247
cdef extern from "dpctl_sycl_kernel_interface.h":

dpctl/_sycl_event.pxd

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,27 @@
2323
from ._backend cimport DPCTLSyclEventRef
2424

2525

26-
cdef public api class SyclEvent [object PySyclEventObject, type PySyclEventType]:
27-
''' Wrapper class for a Sycl Event
28-
'''
29-
cdef DPCTLSyclEventRef _event_ref
30-
cdef list _args
26+
cdef public api class _SyclEvent [
27+
object Py_SyclEventObject,
28+
type Py_SyclEventType
29+
]:
30+
""" Data owner for SyclEvent
31+
"""
32+
cdef DPCTLSyclEventRef _event_ref
33+
cdef object args
3134

35+
36+
cdef public api class SyclEvent(_SyclEvent) [
37+
object PySyclEventObject,
38+
type PySyclEventType
39+
]:
40+
""" Python wrapper class for a ``cl::sycl::event``
41+
"""
3242
@staticmethod
33-
cdef SyclEvent _create (DPCTLSyclEventRef e, list args)
34-
cdef DPCTLSyclEventRef get_event_ref (self)
43+
cdef SyclEvent _create (DPCTLSyclEventRef event, object args=*)
44+
cdef int _init_event_default(self)
45+
cdef int _init_event_from__SyclEvent(self, _SyclEvent other)
46+
cdef int _init_event_from_capsule(self, object caps)
47+
cdef DPCTLSyclEventRef get_event_ref (self)
48+
cdef void _wait (SyclEvent event)
3549
cpdef void wait (self)

0 commit comments

Comments
 (0)