4
4
Device
5
5
######
6
6
7
- The :class: `dpctl.SyclDevice ` class is an abstract representation of a
8
- data-parallel computation device. A device can be a CPU, GPU, FPGA, or other
9
- type of accelerator.
7
+ A device is an abstract representation for an XPU. The :class: `dpctl.SyclDevice `
8
+ class represents a device and is a wrapper over the `sycl::device `_ SYCL runtime
9
+ class.
10
+
10
11
11
12
Listing Devices
12
13
---------------
13
14
14
- :py:mod: `dpctl ` has a fixed number of :ref: ` root devices<RootDevice> ` which does not vary as the application executes.
15
-
16
- Function :func : `dpctl.get_devices ` can be used to retrieve these devices. This list is determined by
15
+ :py:mod: `dpctl ` provides the :func: ` dpctl.get_devices ` utility function to list
16
+ the available devices on a user's system. The function only lists
17
+ :class : `dpctl.SyclDevice ` instances. The list of devices returned depends on
17
18
available hardware, installed drivers, as well as by
18
- `environment variables <DPCPP environment variables >`_
19
- influencing SYCL runtime such as ``SYCL_DEVICE_FILTER `` or ``SYCL_DEVICE_ALLOWLIST ``. Thanks for SYCL runtime
20
- determinism, this list does not change from run to run provided all other conditions stay the same.
21
-
22
- The list can be filtered based on ``backend `` and ``device_type `` keywords. The 0-based ordinal position
23
- of a device in the output of ``dpctl.get_devices `` corresponds to device id in the filter selector string.
24
- For example, ``"opencl:gpu:0" `` refers to the first device in the list returned by
25
- ``dpctl.get_devices(backend="opencl", device_type="gpu") ``. If such a list is empty device construction call
26
- ``dpctl.SyclDevice("opencl:gpu:0") `` will raise a ``ValueError ``.
27
-
28
- Device Aspects and Properties
29
- -----------------------------
30
-
31
- :class: `dpctl.SyclDevice ` exposes various Python properties describing device's aspects and characteristics.
32
-
33
- `Aspects <SYCL 2020 aspects >`_ are boolean characterstics of the device.
34
- Property ``dev.has_aspect_fp16 `` returns a boolean expression indicating whether a particular device has
35
- aspect ``"fp16" ``, indicating whether it supposts IEEE-754 half-precision floating point type.
36
-
37
- Non-boolean characteristics as exposed as :class: `dpctl.SyclDevice ` instance properties with a
38
- non-boolean value type. For example, ``dev.name `` returns a string with a name of the device, while
39
- ``dev.max_compute_units `` returns a positive integer reflecting the number of parallel compute units
40
- available to the device.
41
-
42
- The list of available properties can be retrieved programmatically, or found in documentation page of
43
- :class: `dpctl.SyclDevice ` class.
19
+ `environment variables <DPCPP environment variables >`_ influencing SYCL runtime
20
+ such as ``SYCL_DEVICE_FILTER `` or ``SYCL_DEVICE_ALLOWLIST ``.
21
+
22
+ .. _fig-listing-devices :
23
+
24
+ .. literalinclude :: ../../../../../examples/python/device_selection.py
25
+ :language: python
26
+ :lines: 20-22, 107-131
27
+ :caption: Listing Available Devices
28
+ :linenos:
29
+
30
+ A possible output for the example :ref: `fig-listing-devices ` may be:
31
+
32
+ .. program-output :: python ../examples/python/device_selection.py -r list_devices
33
+
34
+ The example :ref: `fig-listing-devices ` demonstrates the usage of
35
+ :func: `dpctl.get_devices `. The list can be filtered based on
36
+ :class: `dpctl.backend` ` and :class: `dpctl.device_type `. The 0-based ordinal
37
+ position of a device in the output of :func: `dpctl.get_devices ` corresponds to
38
+ the ``device id `` value in the filter selector string corresponding to the
39
+ device. For example, ``"opencl:cpu:0" `` refers to the first device in the list
40
+ returned by ``dpctl.get_devices(backend="opencl", device_type="cpu") ``. If such
41
+ a list is empty, device construction call ``dpctl.SyclDevice("opencl:gpu:0") ``
42
+ will raise a ``ValueError ``.
43
+
44
+ .. Note ::
45
+
46
+ Unless the system configuration changes, the list of devices returned by
47
+ :func: `dpctl.get_devices ` and the relative ordering of devices in the list
48
+ is stable for every call to the function, even across different runs of an
49
+ application.
50
+
51
+ Device Aspects and Information Descriptors
52
+ ------------------------------------------
53
+
54
+ A device can have various *aspects * and *information descriptors * that describe
55
+ its hardware characteristics. :sycl_aspects: `Aspects <> ` are boolean
56
+ characteristics of the device, whereas
57
+ :sycl_device_info: `information descriptors <> ` are non-boolean characteristics
58
+ that provide more verbose information about the device.
59
+ :class: `dpctl.SyclDevice ` exposes various Python properties that describe a
60
+ device's aspects and information descriptors. For example, the property
61
+ ``has_aspect_fp16 `` returns a boolean expression indicating whether a
62
+ particular device has aspect ``"fp16" ``, indicating whether it supports the
63
+ IEEE-754 half-precision floating point type. Whereas, the ``name `` property is
64
+ an information descriptor that returns a string with the name of the device.
65
+
66
+ .. _fig-available-properties :
44
67
45
68
.. code-block :: Python
69
+ :caption: Listing Available Device Aspects and Information Descriptors
70
+ :linenos:
46
71
47
72
import dpctl
48
73
import inspect
@@ -55,47 +80,56 @@ The list of available properties can be retrieved programmatically, or found in
55
80
print (len (get_properties(dpctl.SyclDevice, " name" )))
56
81
# Output: 52
57
82
83
+ The example :ref: `fig-available-properties ` demonstrates a programmatic way of
84
+ listing all the aspects and information descriptor properties in
85
+ :class: `dpctl.SyclDevice `.
86
+
58
87
.. _sec-devices-sub-devices :
59
88
60
89
Sub-devices
61
90
-----------
62
91
63
- Certain devices supporting such capability can be partitioned into multiple devices
64
- by calling :func: `dpctl.SyclDevice.create_sub_devices `, which returns a list of created
65
- sub-device instances of type :class: `dpctl.SyclDevice `. These instances can be partitioned
66
- further.
92
+ It is possible for a device to be partitioned into "sub-devices". A sub-device
93
+ represents a sub-set of the computational units within a device that are grouped
94
+ based on some hardware criteria. For example, a two socket CPU device may be
95
+ partitioned into two sub-devices, where each sub-device represents a separate
96
+ :numa_domain: `NUMA domain <> `. Depending on the hardware characteristics and
97
+ the capabilities of the SYCL runtime, a sub-device may be partitioned further.
67
98
68
- The requested partitioning is indicated with use of required ``partition `` keyword, which
69
- can be a positive integers (indicating equal partitioning with each sub-device having
70
- the requested number of parallel compute units), a list of positive integers
71
- (indicating the requested number of parallel compute units in each sub-device), or
72
- a string indicate partitioning by affinity domain (creating sub-devices sharing a common
73
- resource, such as certain low level cache). Use ``partition="next_partitionable" ``
74
- to partition along the next level of architectural hierarchy.
99
+ For devices that support partitioning, the
100
+ :func: `dpctl.SyclDevice.create_sub_devices ` can be used to create a list of
101
+ sub-devices. The requested partitioning scheme is indicated with use of the
102
+ required ``partition `` keyword. Several types of partitioning schemes are
103
+ available:
75
104
76
- A sub-device's parent device can be retrived using ``dev.parent_device `` property.
77
- When called on a root device, ``root_dev.parent_device `` returns ``None ``.
105
+ * **Equal partitioning **
106
+ The partitioning scheme is specified as a list of positive integers
107
+ indicating a partitioning with each sub-device having the requested number
108
+ of parallel compute units.
78
109
79
- For non-partitioned devices, its corresponding filter selector string can be retrieved
80
- using `` dev.filter_string `` which returns a fully specified triplet. Method
81
- :func: ` dpctl.SyclDevice.get_filter_string ` can be used to obtain a partially
82
- qualified filter selector string .
110
+ * ** Affinity partitioning **
111
+ The partitioning scheme is specified as a string indicating an affinity
112
+ domain used to create sub-devices that sharing a common resource, such as
113
+ certain hardware cache levels .
83
114
84
- .. code-block :: Python
115
+ .. Note ::
85
116
86
- import dpctl
87
- dev = dpctl.SyclDevice()
117
+ Use ``partition="next_partitionable" `` to partition along the next level of
118
+ architectural hierarchy.
119
+
120
+ The following example shows the partitioning of a CPU device into sub-devices
121
+ using the equal partitioning scheme.
122
+
123
+ .. _fig-partition-cpu :
88
124
89
- print (dev.filter_string)
125
+ .. literalinclude :: ../../../../../examples/python/subdevices.py
126
+ :language: python
127
+ :lines: 17, 34-59
128
+ :caption: Partitioning a CPU device
129
+ :linenos:
90
130
91
- # The following prints fully qualified string same as dev.filter_string
92
- # possible output: "opencl:cpu:0"
93
- print (dev.get_filter_string())
131
+ A possible output for the example :ref: `fig-listing-devices ` may be:
94
132
95
- # do not include backend
96
- # possible output: "cpu:0"
97
- print (dev.get_filter_string(include_backend = False ))
133
+ .. program-output :: python ../examples/python/subdevices.py -r subdivide_root_cpu_device
98
134
99
- # include neither backend, nor device Type
100
- # possible output: "1"
101
- print (dev.get_filter_string(include_backend = False , include_device_type = False )
135
+ .. include :: ../../../urls.rst
0 commit comments