@@ -1046,6 +1046,28 @@ sycl::kernel k_float = kb.ext_oneapi_get_kernel("bartmpl<float>");
10461046sycl::kernel k_int = kb.ext_oneapi_get_kernel("bartmpl<int>");
10471047----
10481048
1049+ === Restrictions on the source code when language is `sycl`
1050+
1051+ Currently, SYCL applications are linked with MSVC/GNU C/C\++ runtimes on Win/Lin
1052+ respectively. Unfortunately, we cannot distribute those headers together with
1053+ SYCL applications using kernel compiler due to license restrictions. Instead, we
1054+ distribute LLVM's libc\++/libc headers as part of the kernel compiler and default
1055+ to using them for SPIR-V-based targets. That results in a restriction not to
1056+ pass any data that transitively uses any types defined in C/C++ headers (with
1057+ the exception of `[u]intN_t` type aliases) as those might be ABI-incompatible
1058+ between headers used to compiler device code and those used to compile the host
1059+ part of the SYCL application.
1060+
1061+ Technical implementation of that disables system include paths entirely (as
1062+ having multiple C library implementation in include search paths would break
1063+ things) and uses virtual file system containing in-memory copy of LLVM's
1064+ libc\++/libc headers. That implicitly removes CUDA/HIP SKDs and would break
1065+ online compilation for those targets, thus we do **not** employ that mechanism
1066+ for those targets. Instead, end user's system is required to have a C/C++
1067+ toolchain installation.
1068+
1069+ SYCL application can also pass `--sycl-rtc-use-system-includes` option to change
1070+ the behavior for SPIR-V targets and force usage of the system toolchain.
10491071
10501072== Examples
10511073
@@ -1351,56 +1373,11 @@ Some notes about the current behavior:
13511373 using the conflicting hash would proceed without pre-compiled preamble support
13521374 as if this option wasn't enabled.
13531375
1354- ==== `--sycl-rtc-experimental-redist-mode `
1376+ ==== `--sycl-rtc-use-system-includes `
13551377
1356- Highly experimental option to facilitate distribution of applications that use
1357- SYCL RTC.
1358-
1359- While SYCL-specific header/bitcode files are embedded/distributed inside
1360- `sycl-jit` DSO we still have a dependency on the C/C++ compiler toolchain on the
1361- end-user system (header files only actually, but that's not too important). That
1362- requirement is troublesome for many of the SYCL RTC customers and this option
1363- tries to address that limitation.
1364-
1365- The main problem we face is that default host toolchain (MSVC/GCC on Win/Lin,
1366- respectively) has license requirements that prohibit distribution of necessary
1367- headers as part of SYCL redistributables. Instead, we embed LLVM's libc++ and
1368- libc headers into the `sycl-jit` DSO and provide this option to use those
1369- headers instead. This obviously comes with many limitations/obstacles. Using
1370- this options results in roughly following options being passed implicitly:
1371-
1372- * `--nostdlibinc`, effectively excluding CUDA/HIP SDKs, unless the application
1373- deals with that somehow. The reason we need to do that is because having
1374- different C library implementation in includes search path doesn't work.
1375-
1376- * Setup virtual file system include paths to enable the use of LLVM's
1377- `libc++`/`libc` headers embedded into `sycl-jit` DSO.
1378-
1379- * Define/undefine some macros found by trial-and-error to make that fragile
1380- configuration work, at least for some examples.
1381-
1382- * Add implicit `-include` directive to several C headers. Again, found by
1383- trial-and-error to make things work for some of the examples we tried.
1384-
1385- This also comes with lots of limitations:
1386-
1387- * First, huge potential for ABI mismatch between host (SYCL app) ABI and the
1388- device code (JIT-compiled via SYCL RTC). As such, it is recommended to limit
1389- types passing the host/device boundary to:
1390-
1391- - Fixed-width integer types
1392- - `float`/`double`
1393- - Aggregate types of the above.
1394- - Anything else needs **very thorough** testing at the SYCL application side.
1395-
1396- Using SYCL/STL types in the device code only, without passing host-device
1397- boundary is expected to work.
1398-
1399- * CUDA/HIP aren't expected to work out-of-the-box, see above (`--nostdlibinc`).
1400-
1401- * Option is **highly** experimentall, **no** support is guaranteed and is
1402- subject to change at **any** time, including the possibility of a complete
1403- removal.
1378+ Force usage of system C/C++ toolchain headers instead of the in-memory
1379+ distribution of LLVM's libc\+\+/libc. Option has no effect if the target
1380+ defaults to using system toolchain by default.
14041381
14051382=== Known issues and limitations when the language is `sycl`
14061383
0 commit comments