@@ -52,7 +52,12 @@ __all__ = [
52
52
" SyclContext" ,
53
53
" SyclDevice" ,
54
54
" SyclEvent" ,
55
- " SyclQueue"
55
+ " SyclQueue" ,
56
+ " SyclKernelInvalidRangeError" ,
57
+ " SyclKernelSubmitError" ,
58
+ " SyclQueueCreationError" ,
59
+ " UnsupportedBackendError" ,
60
+ " UnsupportedDeviceError" ,
56
61
]
57
62
58
63
_logger = logging.getLogger(__name__ )
@@ -65,10 +70,10 @@ class device_type(Enum):
65
70
================== ============
66
71
Device type Enum value
67
72
================== ============
68
- GPU 1
69
- CPU 2
70
- Accelerator 3
71
- Host 4
73
+ gpu 1
74
+ cpu 2
75
+ accelerator 3
76
+ host_device 4
72
77
================== ============
73
78
74
79
"""
@@ -84,10 +89,10 @@ class backend_type(Enum):
84
89
================== ============
85
90
Name of backend Enum value
86
91
================== ============
87
- OpenCL 1
88
- Level Zero 2
89
- Cuda 3
90
- Host 4
92
+ opencl 1
93
+ level_zero 2
94
+ cuda 3
95
+ host 4
91
96
================== ============
92
97
93
98
"""
@@ -96,38 +101,50 @@ class backend_type(Enum):
96
101
cuda = auto ()
97
102
host = auto ()
98
103
99
- cdef class UnsupportedBackendError (Exception ):
100
- """ This exception is raised when a device type other than CPU or GPU is
101
- encountered.
104
+ cdef class UnsupportedBackendError(Exception ):
105
+ """
106
+ An UnsupportedBackendError exception is raised when a backend value
107
+ is other than `backend_type.opencl` or `backend_type.level_zero` is
108
+ encountered. All other backends are currently not supported.
109
+
102
110
"""
103
111
pass
104
112
105
- cdef class UnsupportedDeviceError (Exception ):
106
- """ This exception is raised when a device type other than CPU or GPU is
107
- encountered.
113
+ cdef class UnsupportedDeviceError(Exception ):
114
+ """
115
+ An UnsupportedDeviceError exception is raised when a device type value
116
+ other than `device_type.cpu` or `device_type.gpu` is encountered.
117
+
108
118
"""
109
119
pass
110
120
111
- cdef class SyclKernelSubmitError (Exception ):
112
- """ This exception is raised when a SYCL program could not be built from
113
- either a SPIR-V binary file or a string source.
121
+ cdef class SyclKernelSubmitError(Exception ):
122
+ """
123
+ A SyclKernelSubmitError exception is raised when the provided
124
+ :class:`.SyclKernel` could not be submitted to the :class:`.SyclQueue`.
125
+
114
126
"""
115
127
pass
116
128
117
- cdef class SyclKernelInvalidRangeError (Exception ):
118
- """ This exception is raised when a range that has more than three
119
- dimensions or less than one dimension.
129
+ cdef class SyclKernelInvalidRangeError(Exception ):
130
+ """
131
+ A SyclKernelInvalidRangeError is raised when the provided range has less
132
+ than one or more than three dimensions.
120
133
"""
121
134
pass
122
135
123
- cdef class SyclQueueCreationError (Exception ):
124
- """ This exception is raised when a range that has more than three
125
- dimensions or less than one dimension.
136
+ cdef class SyclQueueCreationError(Exception ):
137
+ """
138
+ A SyclQueueCreationError exception is raised when a :class:`.SyclQueue`
139
+ could not be created. :class:`.SyclQueue` creation can fail if the filter
140
+ string is invalid, or the backend or device type values are not supported.
141
+
126
142
"""
127
143
pass
128
144
129
145
cdef class SyclContext:
130
-
146
+ """ Python wrapper class for cl::sycl::context.
147
+ """
131
148
@staticmethod
132
149
cdef SyclContext _create (DPCTLSyclContextRef ctxt):
133
150
cdef SyclContext ret = SyclContext.__new__ (SyclContext)
@@ -147,17 +164,17 @@ cdef class SyclContext:
147
164
return self ._ctxt_ref
148
165
149
166
def addressof_ref (self ):
150
- """ Returns the address of the DPCTLSyclContextRef pointer as a
151
- long .
167
+ """
168
+ Returns the address of the DPCTLSyclContextRef pointer as a size_t .
152
169
153
170
Returns:
154
171
The address of the DPCTLSyclContextRef object used to create this
155
- SyclContext cast to a long .
172
+ SyclContext cast to a size_t .
156
173
"""
157
174
return int (< size_t> self ._ctx_ref)
158
175
159
176
cdef class SyclDevice:
160
- """ Wrapper class for a Sycl Device
177
+ """ Python wrapper class for cl::sycl::device.
161
178
"""
162
179
163
180
@staticmethod
@@ -274,17 +291,17 @@ cdef class SyclDevice:
274
291
return self ._device_ref
275
292
276
293
def addressof_ref (self ):
277
- """ Returns the address of the DPCTLSyclDeviceRef pointer as a
278
- long .
294
+ """
295
+ Returns the address of the DPCTLSyclDeviceRef pointer as a size_t .
279
296
280
297
Returns:
281
298
The address of the DPCTLSyclDeviceRef object used to create this
282
- SyclDevice cast to a long .
299
+ SyclDevice cast to a size_t .
283
300
"""
284
301
return int (< size_t> self ._device_ref)
285
302
286
303
cdef class SyclEvent:
287
- """ Wrapper class for a Sycl Event
304
+ """ Python wrapper class for cl::sycl::event.
288
305
"""
289
306
290
307
@staticmethod
@@ -308,18 +325,18 @@ cdef class SyclEvent:
308
325
309
326
def addressof_ref (self ):
310
327
""" Returns the address of the C API DPCTLSyclEventRef pointer as
311
- a long .
328
+ a size_t .
312
329
313
330
Returns:
314
331
The address of the DPCTLSyclEventRef object used to create this
315
- SyclEvent cast to a long .
332
+ SyclEvent cast to a size_t .
316
333
"""
317
334
return int (< size_t> self ._event_ref)
318
335
319
336
import ctypes
320
337
321
338
cdef class SyclQueue:
322
- """ Wrapper class for a Sycl queue.
339
+ """ Python wrapper class for cl::sycl:: queue.
323
340
"""
324
341
325
342
@staticmethod
@@ -464,11 +481,12 @@ cdef class SyclQueue:
464
481
return self ._queue_ref
465
482
466
483
def addressof_ref (self ):
467
- """ Returns the address of the C API DPCTLSyclQueueRef pointer as a long.
484
+ """
485
+ Returns the address of the C API DPCTLSyclQueueRef pointer as a size_t.
468
486
469
487
Returns:
470
488
The address of the DPCTLSyclQueueRef object used to create this
471
- SyclQueue cast to a long .
489
+ SyclQueue cast to a size_t .
472
490
"""
473
491
return int (< size_t> self ._queue_ref)
474
492
@@ -618,7 +636,7 @@ cdef class SyclQueue:
618
636
619
637
620
638
cdef class _SyclRTManager:
621
- """ Wrapper for the C API 's sycl queue manager interface.
639
+ """ Provides a wrapper for dpCtl 's SYCL queue manager interface.
622
640
"""
623
641
cdef dict _backend_str_ty_dict
624
642
cdef dict _device_str_ty_dict
@@ -1010,7 +1028,7 @@ from contextlib import contextmanager
1010
1028
@contextmanager
1011
1029
def device_context (str queue_str = " opencl:gpu:0" ):
1012
1030
"""
1013
- Yeilds a SYCL queue corresponding to the input filter string.
1031
+ Yields a SYCL queue corresponding to the input filter string.
1014
1032
1015
1033
This context manager "activates", *i.e.*, sets as the currently usable
1016
1034
queue, the SYCL queue defined by the "backend:device type:device id" tuple.
@@ -1025,7 +1043,8 @@ def device_context(str queue_str="opencl:gpu:0"):
1025
1043
"backend:device-type:device-id", defaults to "opencl:gpu:0".
1026
1044
1027
1045
Yields:
1028
- SyclQueue: A SYCL queue corresponding to the specified filter string.
1046
+ :class:`.SyclQueue`: A SYCL queue corresponding to the specified \
1047
+ filter string.
1029
1048
1030
1049
Raises:
1031
1050
ValueError: If the filter string is malformed.
0 commit comments