Skip to content

Commit 3729836

Browse files
Partially address review feedback
1 parent d76c4df commit 3729836

File tree

2 files changed

+87
-39
lines changed

2 files changed

+87
-39
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,44 @@ this extension.
11991199

12001200
== Non-normative implementation notes for {dpcpp}
12011201

1202+
=== C/{cpp} header files and limitations when the language is sycl
1203+
1204+
By default, the SYCL runtime compiler uses a self-contained set of C and {cpp}
1205+
header files when compiling kernels in the `sycl` language. This means that SYCL
1206+
applications using this feature can be run even on a system that does not have
1207+
these headers installed. However, the self contained header files may not be the
1208+
same as the C and {cpp} header files that were used to build the host part of
1209+
the SYCL application. As a result, there are additional limitations around data
1210+
that is shared between the host part of the application and the kernel. These
1211+
limitations apply to arguments that are passed to the kernel and also to data
1212+
shared through USM or through accessors. Additionally, other header files might
1213+
be installed in the same location as system C headers (e.g., `/usr/include/`).
1214+
Those will not be available as well.
1215+
1216+
Types that are defined by the compiler (e.g. fundamental types like `int` and
1217+
`float`) are guaranteed to have the same representation and alignment
1218+
requirements in both the host compiler and in the compiler used to compile the
1219+
kernel. Therefore data using these types can be safely shared. However, types
1220+
defined by the C or {cpp} library (e.g. types in the `std` namespace) are not
1221+
guaranteed to be the same, so data defined using these types cannot be safely
1222+
shared. There are a few specific exceptions to this limitation. The following C
1223+
/ {cpp} types are guaranteed to have the same representation and alignment
1224+
requirements, so data defined as these types can be safely shared:
1225+
1226+
* The following fixed-width integer types: `int8_t`, `int16_t`, `int32_t`,
1227+
`int64_t`, `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`.
1228+
* The types `size_t` and `ptrdiff_t`.
1229+
1230+
Array and class types defined by your application are safe to share so long as
1231+
the element types are safe. Pointer types are safe to share so long as the
1232+
pointed-at type is safe. Enumeration types defined by your application are also
1233+
safe.
1234+
1235+
It is also possible to use the system C and C++ headers instead of the
1236+
self-contained versions. See the description of the
1237+
`--sycl-rtc-use-system-includes` option for more details.
1238+
1239+
12021240
=== Supported `build_options` when the language is `sycl`
12031241

12041242
The SYCL runtime compiler supports the following {dpcpp} options to be passed in
@@ -1359,44 +1397,6 @@ default.
13591397

13601398
=== Known issues and limitations when the language is `sycl`
13611399

1362-
==== C/{cpp} header files
1363-
1364-
By default, the SYCL runtime compiler uses a self-contained set of C and {cpp}
1365-
header files when compiling kernels in the `sycl` language (unless target has
1366-
other dependencies in system includes). This means that SYCL applications using
1367-
this feature can be run even on a system that does not have these headers
1368-
installed. However, the self contained header files may not be the same as the C
1369-
and {cpp} header files that were used to build the host part of the SYCL
1370-
application. As a result, there are additional limitations around data that is
1371-
shared between the host part of the application and the kernel. These
1372-
limitations apply to arguments that are passed to the kernel and also to data
1373-
shared through USM or through accessors. Additionally, other header files might
1374-
be installed in the same location as system C headers (e.g., `/usr/include/`).
1375-
Those will not be available as well.
1376-
1377-
Types that are defined by the compiler (e.g. fundamental types like `int` and
1378-
`float`) are guaranteed to have the same representation and alignment
1379-
requirements in both the host compiler and in the compiler used to compile the
1380-
kernel. Therefore data using these types can be safely shared. However, types
1381-
defined by the C or {cpp} library (e.g. types in the `std` namespace) are not
1382-
guaranteed to be the same, so data defined using these types cannot be safely
1383-
shared. There are a few specific exceptions to this limitation. The following C
1384-
/ {cpp} types are guaranteed to have the same representation and alignment
1385-
requirements, so data defined as these types can be safely shared:
1386-
1387-
* The following fixed-width integer types: `int8_t`, `int16_t`, `int32_t`,
1388-
`int64_t`, `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`.
1389-
* The types `size_t` and `ptrdiff_t`.
1390-
1391-
Array and class types defined by your application are safe to share so long as
1392-
the element types are safe. Pointer types are safe to share so long as the
1393-
pointed-at type is safe. Enumeration types defined by your application are also
1394-
safe.
1395-
1396-
It is also possible to use the system C and C++ headers instead of the
1397-
self-contained versions. See the description of the
1398-
`--sycl-rtc-use-system-includes` option for more details.
1399-
14001400
==== Changing the compiler action or output
14011401

14021402
As the {dpcpp} frontend is integrated tightly in the runtime compilation

sycl/test-e2e/KernelCompiler/sycl_host_device_data_layout.cpp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717
#define STRINGIFY(x) #x
1818
#define EXPAND_AND_STRINGIFY(x) STRINGIFY(x)
1919

20+
// Needs to be duplicated between host/device. @{
21+
22+
// Comma would make preprocessor macro trickier.
23+
using mint3 = sycl::marray<int, 3>;
24+
25+
enum E {
26+
V0 = 0x12345689,
27+
};
28+
static_assert(sizeof(E) == 4);
29+
enum class ScopedE {
30+
ScopedV0 = 0x12345689,
31+
};
32+
static_assert(sizeof(ScopedE) == 4);
33+
34+
// }@
35+
2036
namespace syclexp = sycl::ext::oneapi::experimental;
2137
int main() {
2238
sycl::queue q;
@@ -35,6 +51,15 @@ namespace syclexp = sycl::ext::oneapi::experimental;
3551
3652
using mint3 = sycl::marray<int, 3>;
3753
54+
enum E {
55+
V0 = 0x12345689,
56+
};
57+
static_assert(sizeof(E) == 4);
58+
enum class ScopedE {
59+
ScopedV0 = 0x12345689,
60+
};
61+
static_assert(sizeof(ScopedE) == 4);
62+
3863
extern "C"
3964
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::single_task_kernel))
4065
void foo(TYPE *in, TYPE *out, size_t *align_out, size_t *size_out, bool *equal_out) {
@@ -150,12 +175,35 @@ void foo(TYPE *in, TYPE *out, size_t *align_out, size_t *size_out, bool *equal_o
150175
TEST3(sycl::range<3>, 0x1122334455667788, 0x1223344556677889,
151176
0x132435465768798A)
152177

178+
TEST(sycl::id<1>, 0x1122334455667788)
179+
TEST2(sycl::id<2>, 0x1122334455667788, 0x1223344556677889)
180+
TEST3(sycl::id<3>, 0x1122334455667788, 0x1223344556677889,
181+
0x132435465768798A)
182+
183+
// Making these work with macros would be too much work:
184+
Test(sycl::nd_range<1>{{0x1122334455667788}, {0x1223344556677889}},
185+
"sycl::nd_range<1>", "{0x1122334455667788}, {0x1223344556677889}");
186+
Test(sycl::nd_range<2>{{0x1122334455667788, 0x2132435465768798},
187+
{0x1223344556677889, 0x2233445586778899}},
188+
"sycl::nd_range<2>",
189+
"{0x1122334455667788, 0x2132435465768798}, {0x1223344556677889, "
190+
"0x2233445586778899}");
191+
Test(
192+
sycl::nd_range<3>{
193+
{0x1122334455667788, 0x2132435465768798, 0x31525364758697A8},
194+
{0x1223344556677889, 0x2233445586778899, 0x32435465768798A9}},
195+
"sycl::nd_range<3>",
196+
"{0x1122334455667788, 0x2132435465768798, 0x31525364758697A8}, "
197+
"{0x1223344556677889, 0x2233445586778899, 0x32435465768798A9}");
198+
153199
TEST2(sycl::short2, 0x1234, 0x2345)
154200
TEST3(sycl::short3, 0x1234, 0x2345, 0x3456)
155201

156-
using mint3 = sycl::marray<int, 3>;
157202
TEST3(mint3, 0x1234, 0x2345, 0x3456)
158203

204+
TEST(E, V0)
205+
TEST(ScopedE, ScopedE::ScopedV0)
206+
159207
sycl::free(align, q);
160208
sycl::free(size, q);
161209
sycl::free(equal, q);

0 commit comments

Comments
 (0)