Skip to content

Commit a6e0194

Browse files
author
Diptorup Deb
committed
Doc string fixes
1 parent f930806 commit a6e0194

File tree

7 files changed

+80
-77
lines changed

7 files changed

+80
-77
lines changed

numba_dpex/core/kernel_interface/ranges_overloads.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def codegen(context, builder, sig, args):
3333
range_struct.dim1 = dim1
3434
else:
3535
range_struct.dim1 = llvmir.Constant(
36-
llvmir.types.IntType(64), Range.UNDEFINED_DIMENSION
36+
llvmir.types.IntType(64), Range._UNDEFINED_DIMENSION
3737
)
3838

3939
if not isinstance(sig.args[2], types.NoneType):
4040
range_struct.dim2 = dim2
4141
else:
4242
range_struct.dim2 = llvmir.Constant(
43-
llvmir.types.IntType(64), Range.UNDEFINED_DIMENSION
43+
llvmir.types.IntType(64), Range._UNDEFINED_DIMENSION
4444
)
4545

4646
range_struct.ndim = llvmir.Constant(llvmir.types.IntType(64), typ.ndim)

numba_dpex/experimental/launcher.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,19 @@ def codegen(
220220

221221
@dpjit
222222
def call_kernel(kernel_fn, index_space, *kernel_args) -> None:
223-
"""Calls a numba_dpex.kernel decorated function from CPython or from another
224-
dpjit function. Kernel execution happens in synchronous way, so the thread
225-
will be blocked till the kernel done execution.
223+
"""Compiles and synchronously executes a kernel function.
224+
225+
Kernel execution happens in synchronous way, so the main thread will be
226+
blocked till the kernel done execution.
226227
227228
Args:
228229
kernel_fn (numba_dpex.experimental.KernelDispatcher): A
229-
numba_dpex.kernel decorated function that is compiled to a
230-
KernelDispatcher by numba_dpex.
231-
index_space (Range | NdRange): A numba_dpex.Range or numba_dpex.NdRange
232-
type object that specifies the index space for the kernel.
230+
:func:`numba_dpex.experimental.kernel` decorated function that is
231+
compiled to a ``KernelDispatcher``.
232+
index_space (Range | NdRange): A Range or NdRange type object that
233+
specifies the index space for the kernel.
233234
kernel_args : List of objects that are passed to the numba_dpex.kernel
234-
decorated function.
235+
decorated function.
235236
"""
236237
_submit_kernel_sync( # pylint: disable=E1120
237238
kernel_fn,
@@ -247,25 +248,32 @@ def call_kernel_async(
247248
dependent_events: list[dpctl.SyclEvent],
248249
*kernel_args
249250
) -> tuple[dpctl.SyclEvent, dpctl.SyclEvent]:
250-
"""Calls a numba_dpex.kernel decorated function from CPython or from another
251-
dpjit function. Kernel execution happens in asynchronous way, so the thread
252-
will not be blocked till the kernel done execution. That means that it is
253-
user responsibility to properly use any memory used by kernel until the
254-
kernel execution is completed.
251+
"""Compiles and asynchronously executes a kernel function.
252+
253+
Calls a :func:`numba_dpex.experimental.kernel` decorated function
254+
asynchronously from CPython or from a :func:`numba_dpex.dpjit` function. As
255+
the kernel execution happens asynchronously, so the main thread will not be
256+
blocked till the kernel done execution. Instead the function returns back to
257+
caller a handle for an *event* to track kernel execution. It is a user's
258+
responsibility to properly track kernel execution completion and not use any
259+
data that may still be used by the kernel prior to the kernel's completion.
255260
256261
Args:
257-
kernel_fn (numba_dpex.experimental.KernelDispatcher): A
258-
numba_dpex.kernel decorated function that is compiled to a
259-
KernelDispatcher by numba_dpex.
260-
index_space (Range | NdRange): A numba_dpex.Range or numba_dpex.NdRange
261-
type object that specifies the index space for the kernel.
262+
kernel_fn (KernelDispatcher): A
263+
:func:`numba_dpex.experimental.kernel` decorated function that is
264+
compiled to a ``KernelDispatcher``.
265+
index_space (Range | NdRange): A Range or NdRange type object that
266+
specifies the index space for the kernel.
262267
kernel_args : List of objects that are passed to the numba_dpex.kernel
263-
decorated function.
268+
decorated function.
264269
265270
Returns:
266-
pair of host event and device event. Host event represent host task
267-
that releases use of any kernel argument so it can be deallocated.
268-
This task may be executed only after device task is done.
271+
A pair of ``dpctl.SyclEvent`` objects. The pair of events constitute of
272+
a host task and an event associated with the kernel execution. The event
273+
associated with the kernel execution indicates the execution status of
274+
the submitted kernel function. The host task manages the lifetime of any
275+
PyObject passed in as a kernel argument and automatically decrements the
276+
reference count of the object on kernel execution completion.
269277
"""
270278
return _submit_kernel_async( # pylint: disable=E1120
271279
kernel_fn,

numba_dpex/kernel_api/atomic_ref.py

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111

1212
class AtomicRef:
13-
"""Analogue to the ``sycl::atomic_ref`` type. An atomic reference is a
14-
view into a data container that can be then updated atomically using any of
15-
the ``fetch_*`` member functions of the class.
13+
"""Analogue to the ``sycl::atomic_ref`` class.
14+
15+
An atomic reference is a view into a data container that can be then updated
16+
atomically using any of the ``fetch_*`` member functions of the class.
1617
"""
1718

1819
def __init__( # pylint: disable=too-many-arguments
@@ -66,7 +67,6 @@ def fetch_add(self, val):
6667
val : Value to be added to the object referenced by the AtomicRef.
6768
6869
Returns: The original value of the object referenced by the AtomicRef.
69-
7070
"""
7171
old = self._ref[self._index].copy()
7272
self._ref[self._index] += val
@@ -79,10 +79,9 @@ def fetch_sub(self, val):
7979
8080
Args:
8181
val : Value to be subtracted from the object referenced by the
82-
AtomicRef.
82+
AtomicRef.
8383
8484
Returns: The original value of the object referenced by the AtomicRef.
85-
8685
"""
8786
old = self._ref[self._index].copy()
8887
self._ref[self._index] -= val
@@ -95,10 +94,9 @@ def fetch_min(self, val):
9594
9695
Args:
9796
val : Value to be compared against the object referenced by the
98-
AtomicRef.
97+
AtomicRef.
9998
10099
Returns: The original value of the object referenced by the AtomicRef.
101-
102100
"""
103101
old = self._ref[self._index].copy()
104102
self._ref[self._index] = min(old, val)
@@ -111,10 +109,9 @@ def fetch_max(self, val):
111109
112110
Args:
113111
val : Value to be compared against the object referenced by the
114-
AtomicRef.
112+
AtomicRef.
115113
116114
Returns: The original value of the object referenced by the AtomicRef.
117-
118115
"""
119116
old = self._ref[self._index].copy()
120117
self._ref[self._index] = max(old, val)
@@ -127,10 +124,9 @@ def fetch_and(self, val):
127124
128125
Args:
129126
val : Value to be bitwise ANDed against the object referenced by
130-
the AtomicRef.
127+
the AtomicRef.
131128
132129
Returns: The original value of the object referenced by the AtomicRef.
133-
134130
"""
135131
old = self._ref[self._index].copy()
136132
self._ref[self._index] &= val
@@ -143,10 +139,9 @@ def fetch_or(self, val):
143139
144140
Args:
145141
val : Value to be bitwise ORed against the object referenced by
146-
the AtomicRef.
142+
the AtomicRef.
147143
148144
Returns: The original value of the object referenced by the AtomicRef.
149-
150145
"""
151146
old = self._ref[self._index].copy()
152147
self._ref[self._index] |= val
@@ -159,7 +154,7 @@ def fetch_xor(self, val):
159154
160155
Args:
161156
val : Value to be bitwise XORed against the object referenced by
162-
the AtomicRef.
157+
the AtomicRef.
163158
164159
Returns: The original value of the object referenced by the AtomicRef.
165160
@@ -172,54 +167,49 @@ def load(self):
172167
"""Loads the value of the object referenced by the AtomicRef.
173168
174169
Returns: The value of the object referenced by the AtomicRef.
175-
176170
"""
177171
return self._ref[self._index]
178172

179173
def store(self, val):
180174
"""Stores operand ``val`` to the object referenced by the AtomicRef.
181175
182176
Args:
183-
val : Value to be stored in the object referenced by
184-
the AtomicRef.
185-
177+
val : Value to be stored in the object referenced by the AtomicRef.
186178
"""
187179
self._ref[self._index] = val
188180

189181
def exchange(self, val):
190182
"""Replaces the value of the object referenced by the AtomicRef
191-
with value of ``val``. Returns the original value of the referenced object.
183+
with value of ``val``. Returns the original value of the referenced
184+
object.
192185
193186
Args:
194187
val : Value to be exchanged against the object referenced by
195-
the AtomicRef.
188+
the AtomicRef.
196189
197190
Returns: The original value of the object referenced by the AtomicRef.
198-
199191
"""
200192
old = self._ref[self._index].copy()
201193
self._ref[self._index] = val
202194
return old
203195

204196
def compare_exchange(self, expected, desired, expected_idx=0):
205197
"""Compares the value of the object referenced by the AtomicRef
206-
against the value of ``expected[expected_idx]``.
207-
If the values are equal, replaces the value of the
208-
referenced object with the value of ``desired``.
209-
Otherwise assigns the original value of the
210-
referenced object to ``expected[expected_idx]``.
198+
against the value of ``expected[expected_idx]``. If the values are
199+
equal, replaces the value of the referenced object with the value of
200+
``desired``. Otherwise assigns the original value of the referenced
201+
object to ``expected[expected_idx]``.
211202
212203
Args:
213-
expected : Array containing the expected value of the
214-
object referenced by the AtomicRef.
215-
desired : Value that replaces the value of the object
216-
referenced by the AtomicRef.
204+
expected : Array containing the expected value of the object
205+
referenced by the AtomicRef.
206+
desired : Value that replaces the value of the object referenced by
207+
the AtomicRef.
217208
expected_idx: Offset in `expected` array where the expected
218209
value of the object referenced by the AtomicRef is present.
219210
220-
Returns: Returns ``True`` if the comparison operation and
221-
replacement operation were successful.
222-
211+
Returns: ``True`` if the comparison operation and replacement operation
212+
were successful.
223213
"""
224214
if self._ref[self._index] == expected[expected_idx]:
225215
self._ref[self._index] = desired

numba_dpex/kernel_api/barrier.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
"""Python functions that simulate SYCL's barrier primitives.
5+
"""Python functions that simulate SYCL's group_barrier function.
66
"""
77

88
from .index_space_ids import Group
@@ -14,13 +14,13 @@ def group_barrier(group: Group, fence_scope=MemoryScope.WORK_GROUP):
1414
1515
The function is modeled after the ``sycl::group_barrier`` function. It
1616
synchronizes work within a group of work items. All the work-items
17-
of the group must execute the barrier construct before any work-item
17+
of the group must execute the barrier call before any work-item
1818
continues execution beyond the barrier.
1919
2020
The ``group_barrier`` performs mem-fence operations ensuring that memory
2121
accesses issued before the barrier are not re-ordered with those issued
22-
after the barrier: all work-items in group g execute a release fence prior
23-
to synchronizing at the barrier, all work-items in group g execute an
22+
after the barrier: all work-items in group G execute a release fence prior
23+
to synchronizing at the barrier, all work-items in group G execute an
2424
acquire fence afterwards, and there is an implicit synchronization of these
2525
fences as if provided by an explicit atomic operation on an atomic object.
2626

numba_dpex/kernel_api/index_space_ids.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ def leader(self, work_item_id):
119119

120120

121121
class Item:
122-
"""Analogue to the ``sycl::item`` type. Identifies an instance of the
123-
function object executing at each point in an Range.
122+
"""Analogue to the ``sycl::item`` class.
123+
124+
Identifies an instance of the function object executing at each point in an
125+
:class:`.Range`.
124126
"""
125127

126128
def __init__(self, extent: Range, index: list):
@@ -170,7 +172,7 @@ def get_range(self, idx):
170172

171173
@property
172174
def dimensions(self) -> int:
173-
"""Returns the rank of a Item object.
175+
"""Returns the number of dimensions of a Item object.
174176
175177
Returns:
176178
int: Number of dimensions in the Item object
@@ -179,8 +181,10 @@ def dimensions(self) -> int:
179181

180182

181183
class NdItem:
182-
"""Analogue to the ``sycl::nd_item`` type. Identifies an instance of the
183-
function object executing at each point in an NdRange.
184+
"""Analogue to the ``sycl::nd_item`` class.
185+
186+
Identifies an instance of the function object executing at each point in an
187+
:class:`.NdRange`.
184188
"""
185189

186190
# TODO: define group type
@@ -201,8 +205,7 @@ def get_global_id(self, idx):
201205
return self._global_item.get_id(idx)
202206

203207
def get_global_linear_id(self):
204-
"""Get the global linear id associated with this item for all
205-
dimensions.
208+
"""Get the linearized global id for the item for all dimensions.
206209
207210
Returns:
208211
int: The global linear id.

numba_dpex/kernel_api/memory_enums.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
class MemoryOrder(FlagEnum):
1313
"""
14-
An enumeration of the supported ``sycl::memory_order`` values in dpcpp. The
15-
integer values of the enums is kept consistent with the corresponding
14+
An enumeration of the supported ``sycl::memory_order`` values.
15+
16+
The integer values of the enums is kept consistent with the corresponding
1617
implementation in dpcpp.
1718
1819
===================== ============
@@ -37,8 +38,9 @@ class MemoryOrder(FlagEnum):
3738

3839
class MemoryScope(FlagEnum):
3940
"""
40-
An enumeration of SYCL memory scope. For more details please refer to
41-
SYCL 2020 specification, section 3.8.3.2
41+
An enumeration of the supported ``sycl::memory_scope`` values.
42+
43+
For more details please refer to SYCL 2020 specification, section 3.8.3.2
4244
4345
=============== ============
4446
Memory Scope Enum value
@@ -59,7 +61,7 @@ class MemoryScope(FlagEnum):
5961

6062

6163
class AddressSpace(FlagEnum):
62-
"""The address space values supported by numba_dpex.
64+
"""An enumeration of the supported address space values.
6365
6466
================== ============
6567
Address space Value

numba_dpex/kernel_api/ranges.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Range(tuple):
2727
the behavior of `sycl::range`.
2828
"""
2929

30-
UNDEFINED_DIMENSION = -1
30+
_UNDEFINED_DIMENSION = -1
3131

3232
def __new__(cls, dim0, dim1=None, dim2=None):
3333
"""Constructs a 1, 2, or 3 dimensional range.
@@ -114,7 +114,7 @@ def dim1(self) -> int:
114114
try:
115115
return self[1]
116116
except IndexError:
117-
return Range.UNDEFINED_DIMENSION
117+
return Range._UNDEFINED_DIMENSION
118118

119119
@property
120120
def dim2(self) -> int:
@@ -127,7 +127,7 @@ def dim2(self) -> int:
127127
try:
128128
return self[2]
129129
except IndexError:
130-
return Range.UNDEFINED_DIMENSION
130+
return Range._UNDEFINED_DIMENSION
131131

132132

133133
class NdRange:

0 commit comments

Comments
 (0)