Skip to content

Commit 76fdd08

Browse files
committed
Add docstrings to LocalAccessor
Also improve messages in errors
1 parent 1f94e7f commit 76fdd08

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

dpctl/_sycl_queue.pyx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,41 @@ cdef class kernel_arg_type_attribute:
127127

128128

129129
cdef class LocalAccessor:
130+
"""
131+
LocalAccessor(ndim, dtype, dim0, dim1, dim2)
132+
133+
Python class for specifying the dimensionality and type of a
134+
``sycl::local_accessor``, to be used as a kernel argument type.
135+
136+
Args:
137+
ndim (size_t):
138+
number of dimensions.
139+
Can be between one and three.
140+
dtype (str):
141+
the data type of the local memory.
142+
The permitted values are
143+
144+
`'i1'`, `'i2'`, `'i4'`, `'i8'`:
145+
signed integral types int8_t, int16_t, int32_t, int64_t
146+
`'u1'`, `'u2'`, `'u4'`, `'u8'`
147+
unsigned integral types uint8_t, uint16_t, uint32_t,
148+
uint64_t
149+
`'f4'`, `'f8'`,
150+
single- and double-precision floating-point types float and
151+
double
152+
dim0 (size_t):
153+
Size of the first dimension.
154+
dim1 (size_t):
155+
Size of the second dimension.
156+
dim2 (size_t):
157+
Size of the third dimension.
158+
159+
Raises:
160+
ValueError:
161+
If the given dimension is not between one and three.
162+
ValueError:
163+
If the dtype string is unrecognized.
164+
"""
130165
cdef _md_local_accessor lacc
131166

132167
def __cinit__(self, size_t ndim, str dtype, size_t dim0, size_t dim1, size_t dim2):
@@ -136,7 +171,7 @@ cdef class LocalAccessor:
136171
self.lacc.dim2 = dim2
137172

138173
if ndim < 1 or ndim > 3:
139-
raise ValueError
174+
raise ValueError("LocalAccessor must have dimension between one and three")
140175
if dtype == 'i1':
141176
self.lacc.dpctl_type_id = _arg_data_type._INT8_T
142177
elif dtype == 'u1':
@@ -164,6 +199,10 @@ cdef class LocalAccessor:
164199
return "LocalAccessor(" + self.ndim + ")"
165200

166201
cdef size_t addressof(self):
202+
"""
203+
Returns the address of the _md_local_accessor for this LocalAccessor
204+
cast to ``size_t``.
205+
"""
167206
return <size_t>&self.lacc
168207

169208

0 commit comments

Comments
 (0)