Skip to content

Commit 5c68333

Browse files
Checking in new documentation in doc_sources/
1 parent 90afdc3 commit 5c68333

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2972
-0
lines changed

docs/doc_sources/_static/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*~
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. auto{{ objtype }}:: {{ objname }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
6+
7+
.. autoclass:: {{ name }}
8+
9+
{% block methods %}
10+
11+
{% if methods %}
12+
.. rubric:: {{ _('Methods') }}
13+
14+
.. autosummary::
15+
{% for item in methods %}
16+
~{{ name }}.{{ item }}
17+
{%- endfor %}
18+
{% endif %}
19+
{% endblock %}
20+
21+
{% block attributes %}
22+
{% if attributes %}
23+
.. rubric:: {{ _('Attributes') }}
24+
25+
.. autosummary::
26+
{% for item in attributes %}
27+
~{{ name }}.{{ item }}
28+
{%- endfor %}
29+
{% endif %}
30+
{% endblock %}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
{% if objtype == "data" %}
6+
.. auto{{ objtype }}:: {{ objname }}
7+
:no-value:
8+
{% endif %}
9+
10+
{% if objtype == "function" %}
11+
.. auto{{ objtype }}:: {{ objname }}
12+
{% endif %}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. automodule:: {{ fullname }}
4+
5+
{% block attributes %}
6+
{% if attributes %}
7+
.. rubric:: {{ _('Module Attributes') }}
8+
9+
.. autosummary::
10+
{% for item in attributes %}
11+
{{ item }}
12+
{%- endfor %}
13+
{% endif %}
14+
{% endblock %}
15+
16+
{% block functions %}
17+
{% if functions %}
18+
.. rubric:: {{ _('Functions') }}
19+
20+
.. autosummary::
21+
{% for item in functions %}
22+
{{ item }}
23+
{%- endfor %}
24+
{% endif %}
25+
{% endblock %}
26+
27+
{% block classes %}
28+
{% if classes %}
29+
.. rubric:: {{ _('Classes') }}
30+
31+
.. autosummary::
32+
{% for item in classes %}
33+
{{ item }}
34+
{%- endfor %}
35+
{% endif %}
36+
{% endblock %}
37+
38+
{% block exceptions %}
39+
{% if exceptions %}
40+
.. rubric:: {{ _('Exceptions') }}
41+
42+
.. autosummary::
43+
{% for item in exceptions %}
44+
{{ item }}
45+
{%- endfor %}
46+
{% endif %}
47+
{% endblock %}
48+
49+
{% block modules %}
50+
{% if modules %}
51+
.. rubric:: Modules
52+
53+
.. autosummary::
54+
:toctree:
55+
:recursive:
56+
{% for item in modules %}
57+
{{ item }}
58+
{%- endfor %}
59+
{% endif %}
60+
{% endblock %}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
6+
7+
.. autoclass:: {{ name }}
8+
9+
{% block methods %}
10+
11+
{% if methods %}
12+
.. rubric:: {{ _('Methods') }}
13+
14+
.. autosummary::
15+
{% for item in methods %}
16+
~{{ name }}.{{ item }}
17+
{%- endfor %}
18+
{% endif %}
19+
{% endblock %}
20+
21+
:special-members: __sycl_usm_array_interface__
22+
23+
{% block attributes %}
24+
{% if attributes %}
25+
.. rubric:: {{ _('Attributes') }}
26+
27+
.. autosummary::
28+
{% for item in attributes %}
29+
~{{ name }}.{{ item }}
30+
{%- endfor %}
31+
{% endif %}
32+
{% endblock %}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. _beginners_guide_device_info:
2+
3+
Obtaining information about device
4+
==================================
5+
6+
An instance of :py:class:`SyclDevice` provides access to a collection of information
7+
descriptors characterizing underlying ``sycl::device``.
8+
9+
Information of Boolean nature is exposed via ``has_aspect_*`` properties.
10+
Other descriptions are exposed as properties of the instance.
11+
12+
.. code-block:: python
13+
:caption: Example: Obtaining information about a device
14+
15+
import dpctl
16+
17+
# create default-selected device
18+
dev = dpctl.SyclDevice()
19+
20+
# number of compute units
21+
cu = dev.max_compute_units
22+
# maximal supported size of a work-group
23+
max_wg = dev.max_work_group_size
24+
# size of shared local memory in bytes
25+
loc_mem_sz = dev.local_mem_size
26+
27+
# name of the device
28+
dname = dev.name
29+
# maximal clock frequency in MHz
30+
freq = dev.max_clock_frequency
31+
32+
33+
.. currentmodule:: dpctl.utils
34+
35+
For Intel GPU devices, additional architectural information can be access with :py:func:`intel_device_info` function:
36+
37+
.. code-block:: python
38+
:caption: Example: Intel GPU-specific information
39+
40+
In [1]: import dpctl, dpctl.utils
41+
42+
In [2]: d_gpu = dpctl.SyclDevice()
43+
44+
# Output for Iris Xe integerate GPU, with PCI ID 0x9a49
45+
# (corresponding decimal value: 39497)
46+
In [3]: dpctl.utils.intel_device_info(d_gpu)
47+
Out[3]:
48+
{'device_id': 39497,
49+
'gpu_eu_count': 96,
50+
'gpu_hw_threads_per_eu': 7,
51+
'gpu_eu_simd_width': 8,
52+
'gpu_slices': 1,
53+
'gpu_subslices_per_slice': 12,
54+
'gpu_eu_count_per_subslice': 8}
55+
56+
Please refer to "Intel(R) Xe GPU Architecture" section of the "`oneAPI GPU Optimization Guide <gpu_opt_guide_>`_"
57+
for detailed explanation of these architectural descriptors.
58+
59+
.. _gpu_opt_guide: https://www.intel.com/content/www/us/en/docs/oneapi/optimization-guide-gpu/
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.. _beginners_guide_device_selection:
2+
3+
Device selection
4+
================
5+
6+
DPC++ runtime provides a way to select a device with a highest score to for a set of selection scroring strategies.
7+
Amongst these are a default selector, CPU selector, GPU selector, as well as filter-string selector.
8+
9+
Using fixed device selectors
10+
----------------------------
11+
12+
:py:mod:`dpctl` exposes device selection using fixed selectors as free functions:
13+
14+
.. currentmodule:: dpctl
15+
16+
.. list-table::
17+
18+
* - :py:func:`select_default_device`
19+
- :py:func:`select_gpu_device`
20+
* - :py:func:`select_cpu_device`
21+
- :py:func:`select_accelerator_device`
22+
23+
Selecting device based on aspects
24+
---------------------------------
25+
26+
In addition, a :py:func:`select_device_with_aspects` permits selecting a device based on aspects it is required to have:
27+
28+
.. code-block:: python
29+
:caption: Example: Selecting devices based on their aspects
30+
31+
import dpctl
32+
33+
# select a device that support float64 data type
34+
dev1 = dpctl.select_device_with_aspects("fp64")
35+
36+
# select a device that supports atomic operations on 64-bit types
37+
# in USM-shared allocations
38+
dev2 = dpctl.select_device_with_aspects(
39+
["atomic64", "usm_atomic_shared_allocations"]
40+
)
41+
42+
An aspect string ``asp`` is valid if ``hasattr(dpctl.SyclDevice, "has_aspect_" + asp)`` evaluates to ``True``.
43+
44+
Selecting device using filter selector string
45+
---------------------------------------------
46+
47+
:py:class:`SyclDevice` may also be created using :ref:`filter selector string <filter_selector_string>` specified
48+
as argument to the class constructor:
49+
50+
.. code-block:: python
51+
:caption: Example: Creating device based on filter-selector string
52+
53+
import dpctl
54+
55+
# create any GPU device
56+
dev_gpu = dpctl.SyclDevice("gpu")
57+
58+
# take second device GPU device in the list of GPU devices
59+
# 0-based number is used
60+
dev_gpu1 = dpctl.SyclDevice("gpu:1")
61+
62+
# create GPU device, or CPU if GPU is not available
63+
dev_gpu_or_cpu = dpctl.SyclDevice("gpu,cpu")
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
.. _beginners_guide_enumerating_devices:
2+
3+
Enumerating available devices
4+
=============================
5+
6+
7+
8+
Listing platform from command-line
9+
-----------------------------------
10+
11+
:py:mod:`dpctl` provides command-line interface to list available platforms:
12+
13+
.. code-block:: bash
14+
:caption: List platforms with detailed information on devices
15+
16+
python -m dpctl --full-list
17+
18+
A sample output of executing such a command on a laptop:
19+
20+
.. code-block:: text
21+
:caption: Sample output of running ``python -m dpctl --full-list``
22+
23+
Platform 0 ::
24+
Name Intel(R) FPGA Emulation Platform for OpenCL(TM)
25+
Version OpenCL 1.2 Intel(R) FPGA SDK for OpenCL(TM), Version 20.3
26+
Vendor Intel(R) Corporation
27+
Backend opencl
28+
Num Devices 1
29+
# 0
30+
Name Intel(R) FPGA Emulation Device
31+
Version 2024.17.2.0.22_223154
32+
Filter string opencl:accelerator:0
33+
Platform 1 ::
34+
Name Intel(R) OpenCL
35+
Version OpenCL 3.0 LINUX
36+
Vendor Intel(R) Corporation
37+
Backend opencl
38+
Num Devices 1
39+
# 0
40+
Name 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
41+
Version 2024.17.2.0.22_223154
42+
Filter string opencl:cpu:0
43+
Platform 2 ::
44+
Name Intel(R) OpenCL Graphics
45+
Version OpenCL 3.0
46+
Vendor Intel(R) Corporation
47+
Backend opencl
48+
Num Devices 1
49+
# 0
50+
Name Intel(R) Graphics [0x9a49]
51+
Version 23.52.28202.26
52+
Filter string opencl:gpu:0
53+
Platform 3 ::
54+
Name Intel(R) Level-Zero
55+
Version 1.3
56+
Vendor Intel(R) Corporation
57+
Backend ext_oneapi_level_zero
58+
Num Devices 1
59+
# 0
60+
Name Intel(R) Graphics [0x9a49]
61+
Version 1.3.28202
62+
Filter string level_zero:gpu:0
63+
64+
.. currentmodule:: dpctl
65+
66+
Command-line interface is useful for verifying that drivers are installed correctly.
67+
It is implemented using :py:func:`lsplatform` function.
68+
69+
.. note::
70+
The output on your particular heterogeneous system may vary, depending on available hardware and drivers installed.
71+
72+
Listing devices programmatically
73+
--------------------------------
74+
75+
Devices can also be discovered programmatically, either by using :py:func:`lsplatform` to :py:func:`print`` the listing or
76+
by using :py:func:`get_devices` to obtain a list of :py:class:`SyclDevice` objects suitable for further processing.
77+
78+
.. code-block:: python
79+
:caption: Example: Obtaining list of available devices for processing
80+
81+
import dpctl
82+
83+
# get all available devices
84+
devices = dpctl.get_devices()
85+
86+
# get memory of each in GB
87+
{d.name: d.global_mem_size // (1024 ** 3) for d in devices}
88+
89+
90+
Interaction with DPC++ environment variables
91+
--------------------------------------------
92+
93+
:py:mod:`dpctl` relies on DPC++ runtime for device discovery and is :ref:`subject <beginners_guide_env_variables>` to
94+
environment variables that influence behavior of the runtime.
95+
Setting ``ONEAPI_DEVICE_SELECTOR`` environment variable (see the `list of environment variables <dpcpp_env_vars_>`_
96+
recognized by oneAPI DPC++ runtime for additional details) may restrict the set of devices visible to DPC++ runtime, and hence to :py:mod:`dpctl`
97+
98+
.. _dpcpp_env_vars: https://intel.github.io/llvm-docs/EnvironmentVariables.html
99+
100+
.. code-block:: bash
101+
:caption: Example: Setting ``ONEAPI_DEVICE_SELECTOR=*:cpu`` renders GPU devices unavailable even if they are present
102+
103+
export ONEAPI_DEVICE_SELECTOR=*:cpu
104+
# would only show CPU device
105+
python -m dpctl -f
106+
107+
unset ONEAPI_DEVICE_SELECTOR
108+
# all available devices are available now
109+
python -m dpctl -f

0 commit comments

Comments
 (0)