@@ -149,6 +149,27 @@ cdef list _get_devices(DPCTLDeviceVectorRef DVRef):
149
149
150
150
151
151
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
+ """
152
173
cdef DPCTLSyclBackendType BTy = _backend_type._ALL_BACKENDS
153
174
cdef DPCTLSyclDeviceType DTy = _device_type._ALL_DEVICES
154
175
cdef DPCTLDeviceVectorRef DVRef = NULL
@@ -184,6 +205,22 @@ cpdef list get_devices(backend=backend_type.all, device_type=device_type_t.all):
184
205
cpdef int get_num_devices(
185
206
backend = backend_type.all, device_type = device_type_t.all
186
207
):
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
+ """
187
224
cdef DPCTLSyclBackendType BTy = _backend_type._ALL_BACKENDS
188
225
cdef DPCTLSyclDeviceType DTy = _device_type._ALL_DEVICES
189
226
cdef int num_devices = 0
0 commit comments