Skip to content

Commit 20f88f1

Browse files
author
Diptorup Deb
authored
Add missing doc strings. (#433)
* Add missing doc strings. * Fix section headings.
1 parent c87a53b commit 20f88f1

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

docs/docfiles/dpctl_pyapi.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Device Selection Functions
6363
.. autofunction:: has_accelerator_devices
6464
.. autofunction:: has_host_device
6565

66-
DPCTL Queue Management Functions
67-
--------------------------------
66+
Queue Management Functions
67+
--------------------------
6868

6969
.. autofunction:: device_context
7070
.. autofunction:: get_current_backend

dpctl/_sycl_context.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ cdef class SyclContext(_SyclContext):
142142
using :func:`dpctl.SyclContext._get_capsule` method.
143143
144144
Args:
145-
arg (optional): Defaults to None.
145+
arg (optional): Defaults to ``None``.
146146
The argument can be a selector string, a :class:`dpctl.SyclDevice`
147147
instance, a :obj:`list` of :class:`dpctl.SyclDevice` objects, or a
148148
named ``PyCapsule`` called **"SyclContextRef"**.

dpctl/_sycl_device_factory.pyx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@ cdef list _get_devices(DPCTLDeviceVectorRef DVRef):
149149

150150

151151
cpdef list get_devices(backend=backend_type.all, device_type=device_type_t.all):
152+
""" Returns a list of :class:`dpctl.SyclDevice` instances selected based on
153+
the given :class:`dpctl.device_type` and :class:`dpctl.backend_type` values.
154+
155+
The function is analogous to ``sycl::devices::get_devices()``, but with an
156+
additional functionality that allows filtering SYCL devices based on
157+
``backend`` in addition to only ``device_type``.
158+
159+
Args:
160+
backend (optional): Defaults to ``dpctl.backend_type.all``.
161+
A :class:`dpctl.backend_type` enum value or a string that
162+
specifies a SYCL backend. Currently, accepted values are: "cuda",
163+
"opencl", "level_zero", or "all".
164+
device_type (optional): Defaults to ``dpctl.device_type.all``.
165+
A :class:`dpctl.device_type` enum value or a string that
166+
specifies a SYCL device type. Currently, accepted values are:
167+
"gpu", "cpu", "accelerator", "host_device", or "all".
168+
Returns:
169+
list: A list of available :class:`dpctl.SyclDevice` instances that
170+
satisfy the provided :class:`dpctl.backend_type` and
171+
:class:`dpctl.device_type` values.
172+
"""
152173
cdef DPCTLSyclBackendType BTy = _backend_type._ALL_BACKENDS
153174
cdef DPCTLSyclDeviceType DTy = _device_type._ALL_DEVICES
154175
cdef DPCTLDeviceVectorRef DVRef = NULL
@@ -184,6 +205,22 @@ cpdef list get_devices(backend=backend_type.all, device_type=device_type_t.all):
184205
cpdef int get_num_devices(
185206
backend=backend_type.all, device_type=device_type_t.all
186207
):
208+
""" A helper function to return the number of SYCL devices of a given
209+
:class:`dpctl.device_type` and :class:`dpctl.backend_type`.
210+
211+
Args:
212+
backend (optional): Defaults to ``dpctl.backend_type.all``.
213+
A :class:`dpctl.backend_type` enum value or a string that
214+
specifies a SYCL backend. Currently, accepted values are: "cuda",
215+
"opencl", "level_zero", or "all".
216+
device_type (optional): Defaults to ``dpctl.device_type.all``.
217+
A :class:`dpctl.device_type` enum value or a string that
218+
specifies a SYCL device type. Currently, accepted values are:
219+
"gpu", "cpu", "accelerator", "host_device", or "all".
220+
Returns:
221+
int: The number of available SYCL devices that satisfy the provided
222+
:class:`dpctl.backend_type` and :class:`dpctl.device_type` values.
223+
"""
187224
cdef DPCTLSyclBackendType BTy = _backend_type._ALL_BACKENDS
188225
cdef DPCTLSyclDeviceType DTy = _device_type._ALL_DEVICES
189226
cdef int num_devices = 0

0 commit comments

Comments
 (0)