@@ -107,22 +107,86 @@ cdef void _event_capsule_deleter(object o):
107
107
DPCTLEvent_Delete(ERef)
108
108
109
109
cdef void _init_helper(_SyclEventRaw event, DPCTLSyclEventRef ERef):
110
+ " Populate attributes of class from opaque reference ERef"
110
111
event._event_ref = ERef
111
112
112
113
cdef class _SyclEventRaw:
113
- """ Python wrapper class for a ``cl::sycl::event``.
114
+ """ Data owner for SyclEvent
114
115
"""
115
116
116
117
def __dealloc__ (self ):
117
118
DPCTLEvent_Delete(self ._event_ref)
118
119
119
120
120
121
cdef class SyclEventRaw(_SyclEventRaw):
121
- """ Python wrapper class for a ``cl::sycl::event``.
122
+ """
123
+ SyclEvent(arg=None)
124
+ Python class representing ``cl::sycl::event``. There are multiple
125
+ ways to create a :class:`dpctl.SyclEventRaw` object:
126
+
127
+ - Invoking the constructor with no arguments creates a ready event
128
+ using the default constructor of the ``cl::sycl::event``.
129
+
130
+ :Example:
131
+ .. code-block:: python
132
+
133
+ import dpctl
134
+
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)
162
+
163
+ - Invoking the constuctor with a named ``PyCapsule`` with name
164
+ **"SyclEventRef"** that carries a pointer to a ``sycl::event``
165
+ object. The capsule will be renamed upon successful consumption
166
+ to ensure one-time use. A new named capsule can be constructed by
167
+ using :func:`dpctl.SyclEventRaw._get_capsule` method.
168
+
169
+ Args:
170
+ arg (optional): Defaults to ``None``.
171
+ The argument can be a :class:`dpctl.SyclEvent`
172
+ instance, a :class:`dpctl.SyclEventRaw` instance, or a
173
+ named ``PyCapsule`` called **"SyclEventRef"**.
174
+
175
+ Raises:
176
+ ValueError: If the :class:`dpctl.SyclEventRaw` object creation failed.
177
+ TypeError: In case of incorrect arguments given to constructors,
178
+ unexpected types of input arguments, or in the case the input
179
+ capsule contained a null pointer or could not be renamed.
122
180
"""
123
181
124
182
@staticmethod
125
183
cdef SyclEventRaw _create(DPCTLSyclEventRef eref):
184
+ """ "
185
+ This function calls DPCTLEvent_Delete(eref).
186
+
187
+ The user of this function must pass a copy to keep the
188
+ eref argument alive.
189
+ """
126
190
cdef _SyclEventRaw ret = _SyclEventRaw.__new__ (_SyclEventRaw)
127
191
_init_helper(ret, eref)
128
192
return SyclEventRaw(ret)
@@ -232,6 +296,20 @@ cdef class SyclEventRaw(_SyclEventRaw):
232
296
return < size_t> self ._event_ref
233
297
234
298
def _get_capsule (self ):
299
+ """
300
+ Returns a copy of the underlying ``cl::sycl::event`` pointer as a void
301
+ pointer inside a named ``PyCapsule`` that has the name
302
+ **SyclEventRef**. The ownership of the pointer inside the capsule is
303
+ passed to the caller, and pointer is deleted when the capsule goes out
304
+ of scope.
305
+ Returns:
306
+ :class:`pycapsule`: A capsule object storing a copy of the
307
+ ``cl::sycl::event`` pointer belonging to thus
308
+ :class:`dpctl.SyclEventRaw` instance.
309
+ Raises:
310
+ ValueError: If the ``DPCTLEvent_Copy`` fails to copy the
311
+ ``cl::sycl::event`` pointer.
312
+ """
235
313
cdef DPCTLSyclEventRef ERef = NULL
236
314
ERef = DPCTLEvent_Copy(self ._event_ref)
237
315
if (ERef is NULL ):
@@ -244,7 +322,7 @@ cdef class SyclEventRaw(_SyclEventRaw):
244
322
245
323
@property
246
324
def execution_status (self ):
247
- """ Returns the event status .
325
+ """ Returns the event_status_type enum value for this event .
248
326
"""
249
327
cdef _event_status_type ESTy = DPCTLEvent_GetCommandExecutionStatus(
250
328
self ._event_ref
@@ -260,7 +338,11 @@ cdef class SyclEventRaw(_SyclEventRaw):
260
338
261
339
@property
262
340
def backend (self ):
263
- """ Returns the Sycl backend associated with the event.
341
+ """ Returns the backend_type enum value for the device
342
+ associated with this event.
343
+
344
+ Returns:
345
+ backend_type: The backend for the device.
264
346
"""
265
347
cdef _backend_type BE = DPCTLEvent_GetBackend(self ._event_ref)
266
348
if BE == _backend_type._OPENCL:
@@ -275,6 +357,10 @@ cdef class SyclEventRaw(_SyclEventRaw):
275
357
raise ValueError (" Unknown backend type." )
276
358
277
359
def get_wait_list (self ):
360
+ """
361
+ Returns the list of :class:`dpctl.SyclEventRaw` objects that depend
362
+ on this event.
363
+ """
278
364
cdef DPCTLEventVectorRef EVRef = DPCTLEvent_GetWaitList(
279
365
self .get_event_ref()
280
366
)
@@ -292,6 +378,10 @@ cdef class SyclEventRaw(_SyclEventRaw):
292
378
return events
293
379
294
380
def profiling_info_submit (self ):
381
+ """
382
+ Returns the 64-bit time value in nanoseconds
383
+ when ``cl::sycl::command_group`` was submitted to the queue.
384
+ """
295
385
cdef uint64_t profiling_info_submit = 0
296
386
profiling_info_submit = DPCTLEvent_GetProfilingInfoSubmit(
297
387
self ._event_ref
@@ -300,12 +390,20 @@ cdef class SyclEventRaw(_SyclEventRaw):
300
390
301
391
@property
302
392
def profiling_info_start (self ):
393
+ """
394
+ Returns the 64-bit time value in nanoseconds
395
+ when ``cl::sycl::command_group`` started execution on the device.
396
+ """
303
397
cdef uint64_t profiling_info_start = 0
304
398
profiling_info_start = DPCTLEvent_GetProfilingInfoStart(self ._event_ref)
305
399
return profiling_info_start
306
400
307
401
@property
308
402
def profiling_info_end (self ):
403
+ """
404
+ Returns the 64-bit time value in nanoseconds
405
+ when ``cl::sycl::command_group`` finished execution on the device.
406
+ """
309
407
cdef uint64_t profiling_info_end = 0
310
408
profiling_info_end = DPCTLEvent_GetProfilingInfoEnd(self ._event_ref)
311
409
return profiling_info_end
0 commit comments