@@ -52,7 +52,6 @@ from .enum_types import backend_type, event_status_type
5252
5353__all__ = [
5454 " SyclEvent" ,
55- " SyclEventRaw" ,
5655]
5756
5857_logger = logging.getLogger(__name__ )
@@ -65,39 +64,6 @@ cdef api DPCTLSyclEventRef get_event_ref(SyclEvent ev):
6564 return ev.get_event_ref()
6665
6766
68- cdef class SyclEvent:
69- """ Python wrapper class for cl::sycl::event.
70- """
71-
72- @staticmethod
73- cdef SyclEvent _create(DPCTLSyclEventRef eref, list args):
74- cdef SyclEvent ret = SyclEvent.__new__ (SyclEvent)
75- ret._event_ref = eref
76- ret._args = args
77- return ret
78-
79- def __dealloc__ (self ):
80- self .wait()
81- DPCTLEvent_Delete(self ._event_ref)
82-
83- cdef DPCTLSyclEventRef get_event_ref(self ):
84- """ Returns the DPCTLSyclEventRef pointer for this class.
85- """
86- return self ._event_ref
87-
88- cpdef void wait(self ):
89- DPCTLEvent_Wait(self ._event_ref)
90-
91- def addressof_ref (self ):
92- """ Returns the address of the C API DPCTLSyclEventRef pointer as
93- a size_t.
94-
95- Returns:
96- The address of the DPCTLSyclEventRef object used to create this
97- SyclEvent cast to a size_t.
98- """
99- return int (< size_t> self ._event_ref)
100-
10167cdef void _event_capsule_deleter(object o):
10268 cdef DPCTLSyclEventRef ERef = NULL
10369 if pycapsule.PyCapsule_IsValid(o, " SyclEventRef" ):
@@ -106,23 +72,27 @@ cdef void _event_capsule_deleter(object o):
10672 )
10773 DPCTLEvent_Delete(ERef)
10874
109- cdef void _init_helper(_SyclEventRaw event, DPCTLSyclEventRef ERef):
75+
76+ cdef void _init_helper(_SyclEvent event, DPCTLSyclEventRef ERef):
11077 " Populate attributes of class from opaque reference ERef"
11178 event._event_ref = ERef
11279
113- cdef class _SyclEventRaw:
80+
81+ cdef class _SyclEvent:
11482 """ Data owner for SyclEvent
11583 """
11684
11785 def __dealloc__ (self ):
86+ DPCTLEvent_Wait(self ._event_ref)
11887 DPCTLEvent_Delete(self ._event_ref)
88+ self .args = None
11989
12090
121- cdef class SyclEventRaw(_SyclEventRaw ):
91+ cdef class SyclEvent(_SyclEvent ):
12292 """
12393 SyclEvent(arg=None)
12494 Python class representing ``cl::sycl::event``. There are multiple
125- ways to create a :class:`dpctl.SyclEventRaw ` object:
95+ ways to create a :class:`dpctl.SyclEvent ` object:
12696
12797 - Invoking the constructor with no arguments creates a ready event
12898 using the default constructor of the ``cl::sycl::event``.
@@ -132,81 +102,53 @@ cdef class SyclEventRaw(_SyclEventRaw):
132102
133103 import dpctl
134104
135- # Create a default SyclEventRaw
136- e = dpctl.SyclEventRaw()
137-
138- - Invoking the constuctor with a :class:`dpctl.SyclEvent` object
139- creates an event by copying the passed object.
140-
141- :Example:
142- .. code-block:: python
143-
144- import dpctl
145-
146- # Create a SyclEventRaw by passing SyclEvent
147- q = dpctl.SyclQueue()
148- e = q.submit_barrier()
149- e_r = dpctl.SyclEventRaw(e)
150-
151- - Invoking the constuctor with a :class:`dpctl.SyclEventRaw` object
152- creates an event by copying the passed object.
153-
154- :Example:
155- .. code-block:: python
156-
157- import dpctl
158-
159- # Create a SyclEventRaw by passing SyclEventRaw
160- e = dpctl.SyclEventRaw()
161- e_r = dpctl.SyclEventRaw(e)
105+ # Create a default SyclEvent
106+ e = dpctl.SyclEvent()
162107
163108 - Invoking the constuctor with a named ``PyCapsule`` with name
164109 **"SyclEventRef"** that carries a pointer to a ``sycl::event``
165110 object. The capsule will be renamed upon successful consumption
166111 to ensure one-time use. A new named capsule can be constructed by
167- using :func:`dpctl.SyclEventRaw ._get_capsule` method.
112+ using :func:`dpctl.SyclEvent ._get_capsule` method.
168113
169114 Args:
170115 arg (optional): Defaults to ``None``.
171116 The argument can be a :class:`dpctl.SyclEvent`
172- instance, a :class:`dpctl.SyclEventRaw ` instance, or a
117+ instance, a :class:`dpctl.SyclEvent ` instance, or a
173118 named ``PyCapsule`` called **"SyclEventRef"**.
174119
175120 Raises:
176- ValueError: If the :class:`dpctl.SyclEventRaw ` object creation failed.
121+ ValueError: If the :class:`dpctl.SyclEvent ` object creation failed.
177122 TypeError: In case of incorrect arguments given to constructors,
178123 unexpected types of input arguments, or in the case the input
179124 capsule contained a null pointer or could not be renamed.
180125 """
181126
182127 @staticmethod
183- cdef SyclEventRaw _create(DPCTLSyclEventRef eref):
128+ cdef SyclEvent _create(DPCTLSyclEventRef eref, object args = None ):
184129 """ "
185130 This function calls DPCTLEvent_Delete(eref).
186131
187132 The user of this function must pass a copy to keep the
188133 eref argument alive.
189134 """
190- cdef _SyclEventRaw ret = _SyclEventRaw .__new__ (_SyclEventRaw )
135+ cdef _SyclEvent ret = _SyclEvent .__new__ (_SyclEvent )
191136 _init_helper(ret, eref)
192- return SyclEventRaw(ret)
137+ ret.args= args
138+ return SyclEvent(ret)
193139
194140 cdef int _init_event_default(self ):
195141 self ._event_ref = DPCTLEvent_Create()
196142 if (self ._event_ref is NULL ):
197143 return - 1
144+ self .args= None
198145 return 0
199146
200- cdef int _init_event_from__SyclEventRaw (self , _SyclEventRaw other):
147+ cdef int _init_event_from__SyclEvent (self , _SyclEvent other):
201148 self ._event_ref = DPCTLEvent_Copy(other._event_ref)
202149 if (self ._event_ref is NULL ):
203150 return - 1
204- return 0
205-
206- cdef int _init_event_from_SyclEvent(self , SyclEvent event):
207- self ._event_ref = DPCTLEvent_Copy(event._event_ref)
208- if (self ._event_ref is NULL ):
209- return - 1
151+ self .args = other.args
210152 return 0
211153
212154 cdef int _init_event_from_capsule(self , object cap):
@@ -226,6 +168,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
226168 if (ERef_copy is NULL ):
227169 return - 3
228170 self ._event_ref = ERef_copy
171+ self .args = None
229172 return 0
230173 else :
231174 return - 128
@@ -234,10 +177,8 @@ cdef class SyclEventRaw(_SyclEventRaw):
234177 cdef int ret = 0
235178 if arg is None :
236179 ret = self ._init_event_default()
237- elif type (arg) is _SyclEventRaw:
238- ret = self ._init_event_from__SyclEventRaw(< _SyclEventRaw> arg)
239- elif isinstance (arg, SyclEvent):
240- ret = self ._init_event_from_SyclEvent(< SyclEvent> arg)
180+ elif type (arg) is _SyclEvent:
181+ ret = self ._init_event_from__SyclEvent(< _SyclEvent> arg)
241182 elif pycapsule.PyCapsule_IsValid(arg, " SyclEventRef" ):
242183 ret = self ._init_event_from_capsule(arg)
243184 else :
@@ -266,22 +207,22 @@ cdef class SyclEventRaw(_SyclEventRaw):
266207 return self ._event_ref
267208
268209 @staticmethod
269- cdef void _wait(SyclEventRaw event):
210+ cdef void _wait(SyclEvent event):
270211 DPCTLEvent_WaitAndThrow(event._event_ref)
271212
272213 @staticmethod
273- def wait (event ):
214+ def wait_for (event ):
274215 """ Waits for a given event or a sequence of events.
275216 """
276217 if (isinstance (event, collections.abc.Sequence) and
277- all ((isinstance (el, SyclEventRaw ) for el in event))):
218+ all ((isinstance (el, SyclEvent ) for el in event))):
278219 for e in event:
279- SyclEventRaw ._wait(e)
280- elif isinstance (event, SyclEventRaw ):
281- SyclEventRaw ._wait(event)
220+ SyclEvent ._wait(e)
221+ elif isinstance (event, SyclEvent ):
222+ SyclEvent ._wait(event)
282223 else :
283224 raise TypeError (
284- " The passed argument is not a SyclEventRaw type or "
225+ " The passed argument is not a SyclEvent type or "
285226 " a sequence of such objects"
286227 )
287228
@@ -305,7 +246,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
305246 Returns:
306247 :class:`pycapsule`: A capsule object storing a copy of the
307248 ``cl::sycl::event`` pointer belonging to thus
308- :class:`dpctl.SyclEventRaw ` instance.
249+ :class:`dpctl.SyclEvent ` instance.
309250 Raises:
310251 ValueError: If the ``DPCTLEvent_Copy`` fails to copy the
311252 ``cl::sycl::event`` pointer.
@@ -358,7 +299,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
358299
359300 def get_wait_list (self ):
360301 """
361- Returns the list of :class:`dpctl.SyclEventRaw ` objects that depend
302+ Returns the list of :class:`dpctl.SyclEvent ` objects that depend
362303 on this event.
363304 """
364305 cdef DPCTLEventVectorRef EVRef = DPCTLEvent_GetWaitList(
@@ -373,7 +314,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
373314 events = []
374315 for i in range (num_events):
375316 ERef = DPCTLEventVector_GetAt(EVRef, i)
376- events.append(SyclEventRaw ._create(ERef))
317+ events.append(SyclEvent ._create(ERef, args = None ))
377318 DPCTLEventVector_Delete(EVRef)
378319 return events
379320
@@ -407,3 +348,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
407348 cdef uint64_t profiling_info_end = 0
408349 profiling_info_end = DPCTLEvent_GetProfilingInfoEnd(self ._event_ref)
409350 return profiling_info_end
351+
352+ cpdef void wait(self ):
353+ " Synchronously wait for completion of this event."
354+ DPCTLEvent_Wait(self ._event_ref)
0 commit comments