Skip to content

Commit 9c0508b

Browse files
author
Alexander Batashev
authored
[SYCL][Doc] Update ITT instrumentation docs (#4503)
Add more details about ITT annotations implementation in SYCL runtime and update feature controls documentation.
1 parent d66cc4b commit 9c0508b

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

sycl/doc/EnvironmentVariables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ subject to change. Do not rely on these variables in production code.
4949
| `SYCL_CACHE_MIN_DEVICE_IMAGE_SIZE` | Positive integer | Minimum size of device code image in bytes which is reasonable to cache on disk because disk access operation may take more time than do JIT compilation for it. Default value is 0 to cache all images. |
5050
| `SYCL_CACHE_MAX_DEVICE_IMAGE_SIZE` | Positive integer | Maximum size of device image in bytes which is cached. Too big kernels may overload disk too fast. Default value is 1 GB. |
5151
| `SYCL_ENABLE_DEFAULT_CONTEXTS` | '1' or '0' | Enable ('1') or disable ('0') creation of default platform contexts in SYCL runtime. The default context for each platform contains all devices in the platform. Refer to [Platform Default Contexts](extensions/PlatformContext/PlatformContext.adoc) extension to learn more. Enabled by default on Linux and disabled on Windows. |
52+
| `INTEL_ENABLE_OFFLOAD_ANNOTATIONS` | Any(\*) | Enables ITT Annotations support for SYCL runtime. This variable should only be used by tools, that support ITT Annotations. |
5253

5354
`(*) Note: Any means this environment variable is effective when set to any non-null value.`
5455

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
ITT annotations support
2-
=======================
1+
# ITT annotations support
32

43
This extension enables a set of functions implementing
54
the Instrumentation and Tracing Technology (ITT) functionality
@@ -8,64 +7,64 @@ in SYCL device code.
87
There are three sets of functions defined by this extension,
98
and they serve different purposes.
109

11-
User APIs
12-
---------
10+
## User APIs
1311

1412
The user code calling these functions must include the corresponding header
15-
file(s) provided by ``ittnotify`` project (TBD: reference ITT repo here).
13+
file(s) provided by `ittnotify` project (TBD: reference ITT repo here).
1614

17-
These functions are named using ``__itt_notify_`` prefix.
15+
These functions are named using `__itt_notify_` prefix.
1816

19-
Stub APIs
20-
---------
17+
## Stub APIs
2118

2219
These functions are not defined in any header file, and their declarations
2320
follow exactly the declarations of the corresponding user APIs, except that
24-
they have an extra ``_stub`` suffix in their names.
21+
they have an extra `_stub` suffix in their names.
2522

2623
These functions implement the ITT functionality in a way that allows
2724
the tools, such as Intel(R) Inspector, to recognize the ITT annotations
2825
and run their analysis methods based on that.
2926

30-
For SYCL device code these functions are implemented as ``noinline`` and
31-
``optnone`` functions so that the corresponding calls may be distinguished
27+
For SYCL device code these functions are implemented as `noinline` and
28+
`optnone` functions so that the corresponding calls may be distinguished
3229
in the execution trace. This is just one way for implementing them,
3330
and the actual implementation may change in future.
3431

35-
Compiler wrapper APIs
36-
---------------------
32+
## Compiler wrapper APIs
3733

3834
These functions are not defined in any header file, and they are supposed
3935
to be called from the compiler generated code. These thin wrappers
4036
just provide a convenient way for compilers to produce ITT annotations
4137
without generating too much code in the compilers' IR.
4238

43-
These functions have ``_wrapper`` suffix in their names.
39+
These functions have `_wrapper` suffix in their names.
4440

45-
Example
46-
~~~~~~~
41+
**Example**
4742

48-
.. code: c++
49-
DEVICE_EXTERN_C void __itt_offload_wi_start_stub(
50-
size_t[3], size_t, uint32_t);
43+
```c++
44+
DEVICE_EXTERN_C void __itt_offload_wi_start_stub(
45+
size_t[3], size_t, uint32_t);
5146

52-
DEVICE_EXTERN_C void __itt_offload_wi_start_wrapper() {
53-
if (__spirv_SpecConstant(0xFF747469, 0)) {
54-
size_t GroupID[3] = ...;
55-
size_t WIId = ...;
56-
uint32_t WGSize = ...;
57-
__itt_offload_wi_start_stub(GroupID, WIId, WGSize);
58-
}
59-
}
47+
DEVICE_EXTERN_C void __itt_offload_wi_start_wrapper() {
48+
if (__spirv_SpecConstant(0xFF747469, 0)) {
49+
size_t GroupID[3] = ...;
50+
size_t WIId = ...;
51+
uint32_t WGSize = ...;
52+
__itt_offload_wi_start_stub(GroupID, WIId, WGSize);
53+
}
54+
}
55+
```
6056
61-
A compiler may generate a simple call to ``__itt_offload_wi_start_wrapper``
57+
A compiler may generate a simple call to `__itt_offload_wi_start_wrapper`
6258
to annotate a kernel entry point. Compare this to the code inside the wrapper
6359
function, which a compiler would have to generate if there were no such
6460
a wrapper.
6561
66-
Conditional compilation
67-
-----------------------
62+
## Conditional compilation
6863
64+
Data Parallel C++ compiler automatically instruments user code through
65+
SPIRITTAnnotations LLVM pass, which is enabled for targets, that natively
66+
support specialization constants (i.e., SPIR-V targets). Annotations are
67+
generated for barriers, atomics, work item start and finish.
6968
To minimize the effect of ITT annotations on the performance of the device code,
7069
the implementation is guarded with a specialization constant check. This allows
7170
users and tools to have one version of the annotated code that may be built
@@ -74,6 +73,10 @@ enabled, we expect that the overall effect of the annotations will be minimized
7473
by the dead code elimination optimization(s) made by the device compilers.
7574
7675
For this purpose we reserve a 1-byte specialization constant numbered
77-
``4285822057`` (``0xFF747469``). The users/tools/runtimes should set this
76+
`4285822057` (`0xFF747469`). The users/tools/runtimes should set this
7877
specialization constant to non-zero value to enable the ITT annotations
7978
in SYCL device code.
79+
80+
The specialization constant value is controlled by
81+
INTEL_ENABLE_OFFLOAD_ANNOTATIONS environment variable. Tools, that support ITT
82+
annotations must set this environment variable to any value.

sycl/doc/extensions/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ DPC++ extensions status:
3636
| [Unified Shared Memory](USM/USM.adoc) | Supported(OpenCL) | |
3737
| [Use Pinned Memory Property](UsePinnedMemoryProperty/UsePinnedMemoryPropery.adoc) | Supported | |
3838
| [Level-Zero backend specification](LevelZeroBackend/LevelZeroBackend.md) | Supported | |
39-
| [ITT annotations support](ITTAnnotations/ITTAnnotations.rst) | Supported | |
4039
| [Platform Context](PlatformContext/PlatformContext.adoc) | Proposal | |
4140
| [SYCL_EXT_ONEAPI_DEVICE_IF](DeviceIf/device_if.asciidoc) | Proposal | |
4241
| [SYCL_INTEL_group_sort](GroupAlgorithms/SYCL_INTEL_group_sort.asciidoc) | Proposal | |

sycl/doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ Developing oneAPI DPC++ Compiler
3939
MultiTileCardWithLevelZero
4040
OptionalDeviceFeatures
4141
SYCLInstrumentationUsingXPTI
42+
ITTAnnotations
4243

0 commit comments

Comments
 (0)