Skip to content

Commit d2d39ca

Browse files
Update doc
1 parent 3c7efe1 commit d2d39ca

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,12 +1129,27 @@ forward-declarable.
11291129

11301130
===== `--auto-pch`
11311131

1132-
Enable auto-detection of the preamble and use it as a pre-compiled header to
1133-
speed up subsequent compilations of TUs matching the preamble/compilation
1134-
options. Example of the code that can benefit from this:
1132+
The first time this option is passed, the compiler finds the initial set of
1133+
preprocessor directives (e.g., `#define`/`#include`) and comments in the
1134+
compiled source string (the preamble) and pre-compiles it. Essentialy, it
1135+
behaves like a precompiled header containing that preamble. On subsequent
1136+
compilations, if the compiled source string has the same preamble and the same
1137+
compilation options are used, the precompiled preamble is used, which speeds up
1138+
compilation.
1139+
1140+
If the compiled source string has a different preamble or compilation options
1141+
differ, a new precompiled preamble is generated, and that preamble can also be
1142+
used to speed up subsequent compilations. These precompiled preambles are stored
1143+
internally in memory, so they do not persist from one execution of the
1144+
application to the next.
1145+
1146+
The preamble ends with the first statement that is not a preprocessor directive
1147+
or a comment. For example, in the code below, the preamble ends immediately
1148+
before the namespace syclext = statement.
11351149

11361150
[source,c++]
11371151
----
1152+
#define SYCL_SIMPLE_SWIZZLES
11381153
#include <sycl/sycl.hpp>
11391154
11401155
// Auto-detected preamble ends before next line:
@@ -1143,28 +1158,23 @@ namespace syclexp = sycl::ext::oneapi::experimental;
11431158
11441159
extern "C"
11451160
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
1146-
void iota(float start, float *ptr) {
1161+
void iota(sycl::vec<int, 2> *p) {
11471162
size_t id = syclext::this_work_item::get_nd_item<1>().get_global_linear_id();
1148-
ptr[id] = start + static_cast<float>(id);
1163+
p[id] = p[id].xx();
11491164
}
11501165
----
11511166

1152-
Limitations:
1167+
The compiler uses the following factors when deciding whether a previously
1168+
generated precompiled preamble can be used:
11531169

1154-
* Any changes in either preamble or compilation options (including
1155-
`-DSOMETHING`!) result in a creation of a new pre-compiled header/preamble.
1170+
* The preamble must exactly match (including whitespace and comments).
1171+
* The compilation options must match (including the same order and the same spelling).
1172+
* There are also certain restrictions that the user must avoid:
11561173

1157-
* No support (including not reporting any errors) for `+__DATE__+`/`+__TIME__+`
1158-
macros inside auto-detected preamble (transitively in regards to the
1159-
includes).
1160-
1161-
* Files used inside preamble must not change between different compilations (at
1162-
least for the same auto-detected preamble).
1163-
1164-
* Auto-generated pre-compiled headers/preambles are stored in memory only. That means:
1165-
- No persistency between invocations
1166-
- Currently there is no eviction mechanism, so application is expected to use
1167-
the option only when number of preambles is limited.
1174+
- The content of each header file in the preamble must not change from one
1175+
compilation to another.
1176+
- The header files in the preamble must not use the `+__DATE__+` or
1177+
`+__TIME__+` macros.
11681178

11691179
=== Known issues and limitations when the language is `sycl`
11701180

sycl/test-e2e/KernelCompiler/preamble_define_before_include.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,11 @@ int main(int argc, char **argv) {
4242
namespace syclext = sycl::ext::oneapi;
4343
namespace syclexp = sycl::ext::oneapi::experimental;
4444
45-
auto foo(sycl::vec<int, 4> v) {
46-
// Wouldn't work without SYCL_SIMPLE_SWIZZLES
47-
return v.xx();
48-
}
49-
5045
extern "C"
5146
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
52-
void iota(float start, float *ptr) {
47+
void iota(sycl::vec<int, 2> *p) {
5348
size_t id = syclext::this_work_item::get_nd_item<1>().get_global_linear_id();
54-
ptr[id] = start + static_cast<float>(id);
49+
p[id] = p[id].xx();
5550
}
5651
)""");
5752
}

0 commit comments

Comments
 (0)