Skip to content

Commit 9ded2dd

Browse files
author
Diptorup Deb
committed
Fixes and clean ups for the device page of the user guide.
1 parent 306069f commit 9ded2dd

File tree

9 files changed

+206
-83
lines changed

9 files changed

+206
-83
lines changed

docs/conf.in

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,43 @@
1+
# Data Parallel Control (dpctl)
2+
#
3+
# Copyright 2020-2021 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
117
#!/usr/bin/env python3
218
# -*- coding: utf-8 -*-
319

420
# If extensions (or modules to document with autodoc) are in another directory,
521
# add these directories to sys.path here. If the directory is relative to the
622
# documentation root, use os.path.abspath to make it absolute, like shown here.
723
#
8-
# import os
9-
# import sys
10-
# sys.path.insert(0, os.path.abspath('.'))
24+
import os
25+
import sys
26+
1127
from docutils.parsers.rst import directives
1228
from sphinx.ext.autosummary import Autosummary, get_documenter
1329
from sphinx.util.inspect import safe_getattr
1430

1531
import dpctl
1632

33+
sys.path.insert(0, os.path.abspath("."))
34+
35+
import extlinks_gen as urlgen
36+
1737
# -- Project information -----------------------------------------------------
1838

1939
project = "Data-parallel Control (dpctl)"
20-
copyright = "2020, Intel Corp."
40+
copyright = "2020-21, Intel Corp."
2141
author = "Intel Corp."
2242

2343
version = dpctl.__version__.strip(".dirty")
@@ -31,14 +51,15 @@ release = dpctl.__version__.strip(".dirty")
3151
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3252
# ones.
3353
extensions = [
34-
"sphinx.ext.todo",
35-
"sphinx.ext.coverage",
36-
"sphinx.ext.viewcode",
37-
"sphinx.ext.githubpages",
3854
"sphinx.ext.autodoc",
3955
"sphinx.ext.autosummary",
56+
"sphinx.ext.coverage",
57+
"sphinx.ext.extlinks",
58+
"sphinx.ext.githubpages",
4059
"sphinx.ext.napoleon",
41-
"sphinxcontrib.programoutput"
60+
"sphinx.ext.todo",
61+
"sphinx.ext.viewcode",
62+
"sphinxcontrib.programoutput",
4263
]
4364

4465
todo_include_todos = True
@@ -210,3 +231,7 @@ class AutoAutoSummary(Autosummary):
210231

211232
def setup(app):
212233
app.add_directive("autoautosummary", AutoAutoSummary)
234+
235+
236+
# A dictionary of urls
237+
extlinks = urlgen.create_extlinks()

docs/docfiles/urls.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sycl_aspects": "https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#table.device.aspect",
3+
"sycl_device_info": "https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_information_descriptors",
4+
"numa_domain": "https://en.wikipedia.org/wiki/Non-uniform_memory_access"
5+
}

docs/docfiles/urls.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
.. _SYCL 2020 spec: https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html
77
.. _sycl::platform: https://sycl.readthedocs.io/en/latest/iface/platform.html
88
.. _sycl::device_selector: https://sycl.readthedocs.io/en/latest/iface/device-selector.html
9-
.. _sycl device: https://sycl.readthedocs.io/en/latest/iface/device.html
9+
.. _sycl::device: https://sycl.readthedocs.io/en/latest/iface/device.html
1010
.. _sycl queue: https://sycl.readthedocs.io/en/latest/iface/queue.html
1111
.. _sycl event: https://sycl.readthedocs.io/en/latest/iface/event.html
1212
.. _sycl context: https://sycl.readthedocs.io/en/latest/iface/context.html
1313
.. _oneAPI: https://www.oneapi.io/
1414
.. _oneAPI filter selection extension: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/FilterSelector/FilterSelector.adoc
1515
.. _DPCPP environment variables: https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md
1616
.. _SYCL 2020 aspects: https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#table.device.aspect
17+
.. _SYCL device info: https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_information_descriptors

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Device Selection
55
################
66

77
Device selection refers to programmatically selecting a single device from
8-
the set of `devices`_ available on the system.
8+
the set of :ref:`devices <devices>` available on the system.
99

1010
Selecting a Specific Type of Device
1111
-----------------------------------
@@ -93,7 +93,7 @@ A possible output for the example :ref:`fig-adv-device-selection` may be:
9393

9494
The device listing including the device number value remain stable for
9595
a given system unless the driver configuration is changed or the SYCL
96-
runtime setting is changed using the **SYCL_DEVICE_FILTER** environment
96+
runtime setting is changed using the ``SYCL_DEVICE_FILTER`` environment
9797
variable. Please refer `oneAPI filter selection extension`_ for more detail.
9898

9999
Advanced Device Selection

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

Lines changed: 96 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,70 @@
44
Device
55
######
66

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+
1011

1112
Listing Devices
1213
---------------
1314

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
1718
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:
4467

4568
.. code-block:: Python
69+
:caption: Listing Available Device Aspects and Information Descriptors
70+
:linenos:
4671
4772
import dpctl
4873
import inspect
@@ -55,47 +80,56 @@ The list of available properties can be retrieved programmatically, or found in
5580
print(len(get_properties(dpctl.SyclDevice, "name")))
5681
# Output: 52
5782
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+
5887
.. _sec-devices-sub-devices:
5988

6089
Sub-devices
6190
-----------
6291

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.
6798

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:
75104

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.
78109

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.
83114

84-
.. code-block:: Python
115+
.. Note::
85116

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:
88124

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:
90130

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:
94132

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
98134

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

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
Platform
55
########
66

7-
In dpctl, the class :class:`dpctl.SyclPlatform` represents a platform and
8-
abstracts the `sycl::platform`_ SYCL runtime class. A platform abstracts one or
9-
more XPU that is connected to the host and that can be used for computation. The
10-
platforms queryable using dpctl depends on the device drivers that are installed
11-
on a system. A single driver may control multiple physical XPU, thus a platform
12-
may also consist of multiple XPUs.
7+
A platform abstracts a device driver for one or more XPU that is connected to
8+
a host. The :class:`dpctl.SyclPlatform` class represents a platform and
9+
abstracts the `sycl::platform`_ SYCL runtime class.
1310

1411
Listing Available Platforms
1512
---------------------------
@@ -20,8 +17,7 @@ example it is possible to print out metadata about a platform.
2017

2118
.. literalinclude:: ../../../../../examples/python/lsplatform.py
2219
:language: python
23-
:start-after: # START
24-
:end-before: # END
20+
:lines: 20-41
2521
:linenos:
2622

2723
The example can be executed as follows:

docs/extlinks_gen.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Data Parallel Control (dpctl)
2+
#
3+
# Copyright 2020-2021 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import json
18+
19+
20+
def create_extlinks():
21+
"""Reads a JSON file to create a dictionary of urls in the format supported
22+
by the sphinx.ect.extlinks extension.
23+
24+
Returns:
25+
dict: A dictionary that is understood by the extlinks Sphinx extension.
26+
27+
"""
28+
extlinks = {}
29+
30+
with open("docfiles/urls.json") as urls_json:
31+
urls = json.load(urls_json)
32+
for url in urls:
33+
url_value = urls[url]
34+
extlinks[url] = (url_value + "%s", None)
35+
36+
return extlinks

examples/python/_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def run_examples(example_description, glbls_dict):
5555
print("Available examples:")
5656
print(", ".join(fns))
5757
else:
58-
print("No examples are availble.")
58+
print("No examples are available.")
5959
exit(0)
6060
if args.run == "all":
6161
fns = []

0 commit comments

Comments
 (0)