Skip to content

Commit 8c7d456

Browse files
populated devices.rst
1 parent 0a9996c commit 8c7d456

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

docs/docfiles/user_guides/manual/dpctl/devices.rst

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,85 @@ type of accelerator.
1616
Listing Devices
1717
---------------
1818

19-
.. todo::
19+
`dpctl` has a fixed number of :ref:`root devices<RootDevice>` which does not vary as the application executes.
2020

21-
Get a list of devices
21+
Function :func:`dpctl.get_devices` can be used to retrieve these devices. This list is determined by
22+
available hardware, installed drivers, as well as by
23+
`environment variables <https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md>`
24+
influencing SYCL runtime such as `SYCL_DEVICE_FILTER` or `SYCL_DEVICE_ALLOWLIST`. Thanks for SYCL runtime
25+
determinism, this list does not change from run to run provided all other conditions stay the same.
26+
27+
The list can be filtered based on `backend` and `device_type` keywords. The 0-based ordinal position
28+
of a device in the output of `dpctl.get_devices` corresponds to device id in the filter selector string.
29+
For example, "opencl:gpu:0" refers to the first device in the list returned by
30+
`dpctl.get_devices(backend="opencl", device_type="gpu")`. If such a list is empty device construction call
31+
`dpctl.SyclDevice("opencl:gpu:0")` will raise a `ValueError`.
2232

2333
Device Aspects and Properties
2434
-----------------------------
2535

26-
.. todo::
36+
:class:`dpctl.SyclDevice` exposes various Python properties describing device's aspects and characteristics.
37+
38+
`Aspects <https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#table.device.aspect>`_ are
39+
boolean characterstics of the device. Property `dev.has_aspect_fp16` returns a boolean expression indicating
40+
whether the particular device has aspect "fp16", indicating whether it supposts IEEE-754 half-precision
41+
floating point type.
42+
43+
Non-boolean characteristics as exposed as :class:`dpctl.SyclDevice` instance properties with a
44+
non-boolean value type. For example, `dev.name` returns a string with a name of the device, while
45+
`dev.max_compute_units` returns a positive integer reflecting the number of parallel compute units
46+
available to the device.
47+
48+
The list of available properties can be retrieved programmatically, or found in documentation page of
49+
:class:`dpctl.SyclDevice` class.
50+
51+
.. code-block:: Python
52+
53+
import dpctl
54+
import inspect
2755
28-
Demonstrate how to query a device's various aspects and properties.
56+
def get_properties(cls, prop_name):
57+
"Get name of properties of a class known to have `prop_name`"
58+
known_property_t = type(getattr(cls, prop_name))
59+
return [n for n, o in inspect.getmembers(cls) if isinstance(o, known_property_t)]
2960
61+
print(len(get_properties(dpctl.SyclDevice, "name")))
62+
# Output: 52
3063
3164
.. _sec-devices-sub-devices:
3265

3366
Sub-devices
3467
-----------
3568

36-
.. todo::
69+
Certain devices supporting such capability can be partitioned into multiple devices
70+
by calling :func:`dpctl.SyclDevice.create_sub_devices`, which returns a list of created
71+
sub-device instances of type :class:`dpctl.SyclDevice`. These instances can be partitioned
72+
further.
73+
74+
The requested partitioning is indicated with use of required `partition` keyword, which
75+
can be a positive integers (indicating equal partitioning with each sub-device having
76+
the requested number of parallel compute units), a list of positive integers
77+
(indicating the requested number of parallel compute units in each sub-device), or
78+
a string indicate partitioning by affinity domain (creating sub-devices sharing a common
79+
resource, such as L2-cache).
80+
81+
A sub-device's parent device can be retrived using `dev.parent_device` property.
82+
When called on a root device, `root_dev.parent_device` returns `None`.
83+
84+
For non-partitioned devices, its corresponding filter selector string can be retrieved
85+
using `dev.filter_string` which returns a fully specified triplet. Method
86+
:func:`dpctl.SyclDevice.get_filter_string(include_backend=True, include_device_type=True)`
87+
can be used to obtain a partially qualified filter selector string.
88+
89+
.. code-block:: Python
90+
91+
import dpctl
92+
dev = dpctl.SyclDevice()
3793
38-
Talk about sub-device creation
94+
print(dev.filter_string)
95+
# The following prints fully qualified string, i.e. same as dev.filter_string
96+
print(dev.get_filter_string())
97+
# do not include backend, i.e. "cpu:0"
98+
print(dev.get_filter_string(include_backend=False))
99+
# include neither backend, nor device type, e.g. "1"
100+
print(dev.get_filter_string(include_backend=False, include_device_type=False)

0 commit comments

Comments
 (0)