@@ -16,23 +16,85 @@ type of accelerator.
16
16
Listing Devices
17
17
---------------
18
18
19
- .. todo ::
19
+ ` dpctl ` has a fixed number of :ref: ` root devices<RootDevice> ` which does not vary as the application executes.
20
20
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 `.
22
32
23
33
Device Aspects and Properties
24
34
-----------------------------
25
35
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
27
55
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)]
29
60
61
+ print (len (get_properties(dpctl.SyclDevice, " name" )))
62
+ # Output: 52
30
63
31
64
.. _sec-devices-sub-devices :
32
65
33
66
Sub-devices
34
67
-----------
35
68
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()
37
93
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