Skip to content

Commit d120b47

Browse files
author
Alexander Batashev
committed
Merge remote-tracking branch 'origin/sycl' into private/abatashe/user_docs
* origin/sycl: [XPTI][Framework] Reference implementation of the Xpti framework to be used with instrumentation in SYCL (#1557) [SYCL] Initial ABI checks implementation (#1528) [SYCL] Support connection with multiple plugins (#1490) [SYCL] Add a new header file with the reduction class definition (#1558) [SYCL] Add test for SYCL kernels with accessor and spec constant (#1536)
2 parents 2bc4535 + cece82e commit d120b47

Some content is hidden

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

62 files changed

+10394
-262
lines changed

clang/test/SemaSYCL/Inputs/sycl.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ class handler {
194194
}
195195
};
196196

197+
namespace experimental {
198+
199+
template <typename T, typename ID = T>
200+
class spec_constant {};
201+
} // namespace experimental
202+
197203
} // namespace sycl
198204
} // namespace cl
199205

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -I %S/Inputs -ast-dump %s | FileCheck %s
2+
// The test checks that Clang doesn't crash if a specialization constant gets
3+
// into the kernel capture list before an accessor
4+
5+
#include <sycl.hpp>
6+
7+
template <typename name, typename Func>
8+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
9+
kernelFunc();
10+
}
11+
12+
int main() {
13+
cl::sycl::experimental::spec_constant<char, class MyInt32Const> spec_const;
14+
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write> accessor;
15+
// CHECK: FieldDecl {{.*}} implicit referenced 'cl::sycl::experimental::spec_constant<char, class MyInt32Const>'
16+
// CHECK: FieldDecl {{.*}} implicit referenced 'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write>'
17+
kernel<class MyKernel>([spec_const, accessor]() {});
18+
return 0;
19+
}

sycl/doc/ABIPolicyGuide.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# ABI Policy Guide
2+
3+
## Intro
4+
5+
Application Binary Interface is a contract between binary modules, that defines
6+
how structures and routines are accessed in machine code. Changing the ABI may
7+
break backwards compatibility of user application with the DPC++ runtime library
8+
for user-developed applications, resulting in need to rebuild such applications.
9+
The goal of this document is to provide guidelines for maintaining the current
10+
ABI of the DPC++ runtime library and mechanisms of notifying users about ABI
11+
changes.
12+
13+
All ABI changes can be divided into two large groups: breaking and non-breaking.
14+
A breaking change means that the new binary is incompatible with the previous
15+
version (i.e. it can not be used as a drop-in replacement). A non-breaking
16+
change means that the forward compatibility is broken (i.e. the old library
17+
can be replaced with newer version, but not vice versa).
18+
19+
The following non-exhaustive list contains changes that are considered to be
20+
breaking:
21+
22+
1. Changing the size of exported symbol (for example, adding new member field
23+
to the exported class).
24+
1. Removing the exported symbol (that includes both changing the signature of
25+
exported routine and removing it).
26+
1. Changing the alignment of exported symbol.
27+
1. Changing the layout of exported symbol (for example, reordering class field
28+
members).
29+
1. Adding or removing base classes.
30+
31+
Adding a new exported symbol is considered to be non-breaking change.
32+
33+
## ABI Versioning Policy
34+
35+
TBD
36+
37+
## `__SYCL_EXPORT` Macro
38+
39+
The `__SYCL_EXPORT` provides facilities for fine-grained control over exported
40+
symbols. Mark symbols that are supposed to be accessible by the user and that
41+
are implemented in the SYCL Runtime library with this macro. Template
42+
specializations also must be explicitly marked with `__SYCL_EXPORT` macro.
43+
Symbols not marked `__SYCL_EXPORT` have internal linkage.
44+
45+
A few examples of when it is necessary to mark symbols with the macro:
46+
47+
* The `device` class:
48+
- It is defined as API by the SYCL spec.
49+
- It is implemented in `device.cpp` file.
50+
* The `SYCLMemObjT` class:
51+
- It is not defined in the SYCL spec, but it is an implementation detail that
52+
is accessible by the user (buffer and image inherit from this class).
53+
- It has symbols that are implemented in the Runtime library.
54+
55+
When it is not necessary to mark symbols with `__SYCL_EXPORT`:
56+
* The `buffer` class:
57+
- It is defined by the SYCL spec, but it is fully implemented in the headers.
58+
* The `ProgramManager` class:
59+
- It is an implementation detail.
60+
- It is not accessed from the header files that are available to users.
61+
62+
## Automated ABI Changes Testing
63+
64+
> The automated tests deal with the most commonly occurring problems, but they
65+
> may not catch some corner cases. If you believe your PR breaks ABI, but the
66+
> test does not indicate that, please, notify the reviewers.
67+
68+
There is a set of tests to help identifying ABI changes:
69+
70+
* `test/abi/sycl_symbols_*.dump` contains dump of publicly available symbols.
71+
If you add a new symbol, it is considered non-breaking change. When the test
72+
reports missing symbols, it means you have either changed or remove some of
73+
existing API methods. In both cases you need to adjust the dump file. You
74+
can do it either manually, or by invoking the following command:
75+
```shell
76+
python3 sycl/tools/abi_check.py --mode dump_symbols --output path/to/output.dump path/to/sycl.so(.dll)
77+
```
78+
* `test/abi/layout*` and `test/abi/symbol_size*` are a group of tests to check
79+
the internal layout of some classes. The layout tests check Clang AST for
80+
changes, while symbol_size check `sizeof` for objects. Changing the class
81+
layout is a breaking change.
82+
83+
## Breaking ABI
84+
85+
Whenever you need to change the existing ABI, please, follow these steps:
86+
87+
1. Adjust you PR description to reflect (non-)breaking ABI changes. Make sure
88+
it is clear, why breaking ABI is necessary.
89+
2. Fix failing ABI tests in your Pull Request. Use aforementioned techniques to
90+
update test files.
91+
3. Update the library version according to the policies.

sycl/doc/EnvironmentVariables.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ subject to change. Do not rely on these variables in production code.
1111

1212
| Environment variable | Values | Description |
1313
| -------------------- | ------ | ----------- |
14-
| SYCL_PI_TRACE | Any(\*) | Force tracing of PI calls to stderr. |
15-
| SYCL_BE | PI_OPENCL, PI_CUDA, PI_OTHER | When SYCL RT is built with PI, this controls which plugin is used by the default device selector. Default value is PI_OPENCL. |
14+
| SYCL_PI_TRACE | Described [below](#sycl_pi_trace-options) | Enable specified level of tracing for PI. |
15+
| SYCL_BE | PI_OPENCL, PI_CUDA | Force SYCL RT to consider only devices of the specified backend during the device selection. |
1616
| SYCL_DEVICE_TYPE | One of: CPU, GPU, ACC, HOST | Force SYCL to use the specified device type. If unset, default selection rules are applied. If set to any unlisted value, this control has no effect. If the requested device type is not found, a `cl::sycl::runtime_error` exception is thrown. If a non-default device selector is used, a device must satisfy both the selector and this control to be chosen. This control only has effect on devices created with a selector. |
1717
| SYCL_PROGRAM_COMPILE_OPTIONS | String of valid OpenCL compile options | Override compile options for all programs. |
1818
| SYCL_PROGRAM_LINK_OPTIONS | String of valid OpenCL link options | Override link options for all programs. |
@@ -39,3 +39,12 @@ SYCL_PRINT_EXECUTION_GRAPH can accept one or more comma separated values from th
3939
| after_addHostAcc | print graph after addHostAccessor method |
4040
| always | print graph before and after each of the above methods |
4141

42+
### SYCL_PI_TRACE Options
43+
44+
SYCL_PI_TRACE accepts a bit-mask. Supported tracing levels are in the table below
45+
46+
| Option | Description |
47+
| ------ | ----------- |
48+
| 1 | Enable basic tracing, which is tracing of PI plugins/devices discovery |
49+
| 2 | Enable tracing of the PI calls |
50+
| -1 | Enable all levels of tracing |

sycl/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Developing oneAPI DPC++ Compiler
2525
CompilerAndRuntimeDesign
2626
EnvironmentVariables
2727
PluginInterface
28-
28+
ABIPolicyGuide

sycl/include/CL/sycl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <CL/sycl/intel/builtins.hpp>
2727
#include <CL/sycl/intel/function_pointer.hpp>
2828
#include <CL/sycl/intel/group_algorithm.hpp>
29+
#include <CL/sycl/intel/reduction.hpp>
2930
#include <CL/sycl/intel/sub_group.hpp>
3031
#include <CL/sycl/item.hpp>
3132
#include <CL/sycl/kernel.hpp>

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#pragma once
1515

16+
#include <CL/sycl/backend_types.hpp>
1617
#include <CL/sycl/detail/common.hpp>
1718
#include <CL/sycl/detail/export.hpp>
1819
#include <CL/sycl/detail/os_util.hpp>
@@ -43,6 +44,17 @@ enum class PiApiKind {
4344
class plugin;
4445
namespace pi {
4546

47+
// The SYCL_PI_TRACE sets what we will trace.
48+
// This is a bit-mask of various things we'd want to trace.
49+
enum TraceLevel {
50+
PI_TRACE_BASIC = 0x1,
51+
PI_TRACE_CALLS = 0x2,
52+
PI_TRACE_ALL = -1
53+
};
54+
55+
// Return true if we want to trace PI related activities.
56+
bool trace(TraceLevel level);
57+
4658
#ifdef SYCL_RT_OS_WINDOWS
4759
#define OPENCL_PLUGIN_NAME "pi_opencl.dll"
4860
#define CUDA_PLUGIN_NAME "pi_cuda.dll"
@@ -111,13 +123,6 @@ void *loadOsLibrary(const std::string &Library);
111123
// library, implementation is OS dependent.
112124
void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName);
113125

114-
// For selection of SYCL RT back-end, now manually through the "SYCL_BE"
115-
// environment variable.
116-
enum Backend { SYCL_BE_PI_OPENCL, SYCL_BE_PI_CUDA, SYCL_BE_PI_OTHER };
117-
118-
// Check for manually selected BE at run-time.
119-
bool useBackend(Backend Backend);
120-
121126
// Get a string representing a _pi_platform_info enum
122127
std::string platformInfoToString(pi_platform_info info);
123128

sycl/include/CL/sycl/intel/functional.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ template <> struct maximum<void> {
5353
#endif
5454

5555
template <typename T = void> using plus = std::plus<T>;
56+
template <typename T = void> using bit_or = std::bit_or<T>;
57+
template <typename T = void> using bit_xor = std::bit_xor<T>;
58+
template <typename T = void> using bit_and = std::bit_and<T>;
5659

5760
} // namespace intel
5861

0 commit comments

Comments
 (0)