@@ -52,7 +52,6 @@ from .enum_types import backend_type, event_status_type
52
52
53
53
__all__ = [
54
54
" SyclEvent" ,
55
- " SyclEventRaw" ,
56
55
]
57
56
58
57
_logger = logging.getLogger(__name__ )
@@ -65,39 +64,6 @@ cdef api DPCTLSyclEventRef get_event_ref(SyclEvent ev):
65
64
return ev.get_event_ref()
66
65
67
66
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
-
101
67
cdef void _event_capsule_deleter(object o):
102
68
cdef DPCTLSyclEventRef ERef = NULL
103
69
if pycapsule.PyCapsule_IsValid(o, " SyclEventRef" ):
@@ -106,23 +72,27 @@ cdef void _event_capsule_deleter(object o):
106
72
)
107
73
DPCTLEvent_Delete(ERef)
108
74
109
- cdef void _init_helper(_SyclEventRaw event, DPCTLSyclEventRef ERef):
75
+
76
+ cdef void _init_helper(_SyclEvent event, DPCTLSyclEventRef ERef):
110
77
" Populate attributes of class from opaque reference ERef"
111
78
event._event_ref = ERef
112
79
113
- cdef class _SyclEventRaw:
80
+
81
+ cdef class _SyclEvent:
114
82
""" Data owner for SyclEvent
115
83
"""
116
84
117
85
def __dealloc__ (self ):
86
+ DPCTLEvent_Wait(self ._event_ref)
118
87
DPCTLEvent_Delete(self ._event_ref)
88
+ self .args = None
119
89
120
90
121
- cdef class SyclEventRaw(_SyclEventRaw ):
91
+ cdef class SyclEvent(_SyclEvent ):
122
92
"""
123
93
SyclEvent(arg=None)
124
94
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:
126
96
127
97
- Invoking the constructor with no arguments creates a ready event
128
98
using the default constructor of the ``cl::sycl::event``.
@@ -132,81 +102,53 @@ cdef class SyclEventRaw(_SyclEventRaw):
132
102
133
103
import dpctl
134
104
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()
162
107
163
108
- Invoking the constuctor with a named ``PyCapsule`` with name
164
109
**"SyclEventRef"** that carries a pointer to a ``sycl::event``
165
110
object. The capsule will be renamed upon successful consumption
166
111
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.
168
113
169
114
Args:
170
115
arg (optional): Defaults to ``None``.
171
116
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
173
118
named ``PyCapsule`` called **"SyclEventRef"**.
174
119
175
120
Raises:
176
- ValueError: If the :class:`dpctl.SyclEventRaw ` object creation failed.
121
+ ValueError: If the :class:`dpctl.SyclEvent ` object creation failed.
177
122
TypeError: In case of incorrect arguments given to constructors,
178
123
unexpected types of input arguments, or in the case the input
179
124
capsule contained a null pointer or could not be renamed.
180
125
"""
181
126
182
127
@staticmethod
183
- cdef SyclEventRaw _create(DPCTLSyclEventRef eref):
128
+ cdef SyclEvent _create(DPCTLSyclEventRef eref, object args = None ):
184
129
""" "
185
130
This function calls DPCTLEvent_Delete(eref).
186
131
187
132
The user of this function must pass a copy to keep the
188
133
eref argument alive.
189
134
"""
190
- cdef _SyclEventRaw ret = _SyclEventRaw .__new__ (_SyclEventRaw )
135
+ cdef _SyclEvent ret = _SyclEvent .__new__ (_SyclEvent )
191
136
_init_helper(ret, eref)
192
- return SyclEventRaw(ret)
137
+ ret.args= args
138
+ return SyclEvent(ret)
193
139
194
140
cdef int _init_event_default(self ):
195
141
self ._event_ref = DPCTLEvent_Create()
196
142
if (self ._event_ref is NULL ):
197
143
return - 1
144
+ self .args= None
198
145
return 0
199
146
200
- cdef int _init_event_from__SyclEventRaw (self , _SyclEventRaw other):
147
+ cdef int _init_event_from__SyclEvent (self , _SyclEvent other):
201
148
self ._event_ref = DPCTLEvent_Copy(other._event_ref)
202
149
if (self ._event_ref is NULL ):
203
150
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
210
152
return 0
211
153
212
154
cdef int _init_event_from_capsule(self , object cap):
@@ -226,6 +168,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
226
168
if (ERef_copy is NULL ):
227
169
return - 3
228
170
self ._event_ref = ERef_copy
171
+ self .args = None
229
172
return 0
230
173
else :
231
174
return - 128
@@ -234,10 +177,8 @@ cdef class SyclEventRaw(_SyclEventRaw):
234
177
cdef int ret = 0
235
178
if arg is None :
236
179
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)
241
182
elif pycapsule.PyCapsule_IsValid(arg, " SyclEventRef" ):
242
183
ret = self ._init_event_from_capsule(arg)
243
184
else :
@@ -266,22 +207,22 @@ cdef class SyclEventRaw(_SyclEventRaw):
266
207
return self ._event_ref
267
208
268
209
@staticmethod
269
- cdef void _wait(SyclEventRaw event):
210
+ cdef void _wait(SyclEvent event):
270
211
DPCTLEvent_WaitAndThrow(event._event_ref)
271
212
272
213
@staticmethod
273
- def wait (event ):
214
+ def wait_for (event ):
274
215
""" Waits for a given event or a sequence of events.
275
216
"""
276
217
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))):
278
219
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)
282
223
else :
283
224
raise TypeError (
284
- " The passed argument is not a SyclEventRaw type or "
225
+ " The passed argument is not a SyclEvent type or "
285
226
" a sequence of such objects"
286
227
)
287
228
@@ -305,7 +246,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
305
246
Returns:
306
247
:class:`pycapsule`: A capsule object storing a copy of the
307
248
``cl::sycl::event`` pointer belonging to thus
308
- :class:`dpctl.SyclEventRaw ` instance.
249
+ :class:`dpctl.SyclEvent ` instance.
309
250
Raises:
310
251
ValueError: If the ``DPCTLEvent_Copy`` fails to copy the
311
252
``cl::sycl::event`` pointer.
@@ -358,7 +299,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
358
299
359
300
def get_wait_list (self ):
360
301
"""
361
- Returns the list of :class:`dpctl.SyclEventRaw ` objects that depend
302
+ Returns the list of :class:`dpctl.SyclEvent ` objects that depend
362
303
on this event.
363
304
"""
364
305
cdef DPCTLEventVectorRef EVRef = DPCTLEvent_GetWaitList(
@@ -373,7 +314,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
373
314
events = []
374
315
for i in range (num_events):
375
316
ERef = DPCTLEventVector_GetAt(EVRef, i)
376
- events.append(SyclEventRaw ._create(ERef))
317
+ events.append(SyclEvent ._create(ERef, args = None ))
377
318
DPCTLEventVector_Delete(EVRef)
378
319
return events
379
320
@@ -407,3 +348,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
407
348
cdef uint64_t profiling_info_end = 0
408
349
profiling_info_end = DPCTLEvent_GetProfilingInfoEnd(self ._event_ref)
409
350
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