Skip to content

Commit b93d53a

Browse files
populated devices.rst
1 parent 0a9996c commit b93d53a

File tree

1 file changed

+74
-6
lines changed

1 file changed

+74
-6
lines changed

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

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,91 @@ 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 <DPCPP environment variables>`_
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 <SYCL 2020 aspects>`_ are boolean characterstics of the device.
39+
Property ``dev.has_aspect_fp16`` returns a boolean expression indicating whether a particular device has
40+
aspect ``"fp16"``, indicating whether it supposts IEEE-754 half-precision floating point type.
41+
42+
Non-boolean characteristics as exposed as :class:`dpctl.SyclDevice` instance properties with a
43+
non-boolean value type. For example, ``dev.name`` returns a string with a name of the device, while
44+
``dev.max_compute_units`` returns a positive integer reflecting the number of parallel compute units
45+
available to the device.
46+
47+
The list of available properties can be retrieved programmatically, or found in documentation page of
48+
:class:`dpctl.SyclDevice` class.
2749

28-
Demonstrate how to query a device's various aspects and properties.
50+
.. code-block:: Python
2951
52+
import dpctl
53+
import inspect
54+
55+
def get_properties(cls, prop_name):
56+
"Get name of properties of a class known to have `prop_name`"
57+
known_property_t = type(getattr(cls, prop_name))
58+
return [n for n, o in inspect.getmembers(cls) if isinstance(o, known_property_t)]
59+
60+
print(len(get_properties(dpctl.SyclDevice, "name")))
61+
# Output: 52
3062
3163
.. _sec-devices-sub-devices:
3264

3365
Sub-devices
3466
-----------
3567

36-
.. todo::
68+
Certain devices supporting such capability can be partitioned into multiple devices
69+
by calling :func:`dpctl.SyclDevice.create_sub_devices`, which returns a list of created
70+
sub-device instances of type :class:`dpctl.SyclDevice`. These instances can be partitioned
71+
further.
72+
73+
The requested partitioning is indicated with use of required ``partition`` keyword, which
74+
can be a positive integers (indicating equal partitioning with each sub-device having
75+
the requested number of parallel compute units), a list of positive integers
76+
(indicating the requested number of parallel compute units in each sub-device), or
77+
a string indicate partitioning by affinity domain (creating sub-devices sharing a common
78+
resource, such as certain low level cache). Use ``partition="next_partitionable"``
79+
to partition along the next level of architectural hierarchy.
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` can be used to obtain a partially
87+
qualified filter selector string.
88+
89+
.. code-block:: Python
90+
91+
import dpctl
92+
dev = dpctl.SyclDevice()
93+
94+
print(dev.filter_string)
95+
96+
# The following prints fully qualified string same as dev.filter_string
97+
# possible output: "opencl:cpu:0"
98+
print(dev.get_filter_string())
99+
100+
# do not include backend
101+
# possible output: "cpu:0"
102+
print(dev.get_filter_string(include_backend=False))
37103
38-
Talk about sub-device creation
104+
# include neither backend, nor device Type
105+
# possible output: "1"
106+
print(dev.get_filter_string(include_backend=False, include_device_type=False)

0 commit comments

Comments
 (0)