Skip to content

Commit 0b6f8cd

Browse files
authored
[SYCL][DOC] Update C-CXX-StandardLibrary doc to align with latest status (#2529)
Signed-off-by: gejin <[email protected]>
1 parent df45f00 commit 0b6f8cd

File tree

2 files changed

+36
-40
lines changed

2 files changed

+36
-40
lines changed

sycl/doc/extensions/C-CXX-StandardLibrary/C-CXX-StandardLibrary.rst

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,7 @@ explicitly included in user code.
1010

1111
Implementation requires a special device library to be linked with a
1212
SYCL program. The library should match the C or C++ standard library
13-
used to compile the program:
14-
15-
For example, on Linux with GNU glibc:
16-
.. code:
17-
clang++ -fsycl -c main.cpp -o main.o
18-
clang++ -fsycl main.o $(SYCL_INSTALL)/lib/libsycl-glibc.o -o a.out
19-
20-
or, in case of Windows:
21-
.. code:
22-
clang++ -fsycl -c main.cpp -o main.obj
23-
clang++ -fsycl main.obj %SYCL_INSTALL%/lib/libsycl-msvc.o -o a.exe
24-
25-
For Ahead-Of-Time compilation (AOT), fallback libraries (object files)
26-
must be linked as well:
27-
28-
.. code:
29-
clang++ -fsycl -c -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice \
30-
main.cpp -o main.o
31-
clang++ -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice \
32-
main.o $(SYCL_INSTALL)/lib/libsycl-glibc.o \
33-
$(SYCL_INSTALL)/lib/libsycl-fallback-cassert.o -o a.out
13+
used to compile the program.
3414

3515
List of supported functions from C standard library:
3616
- assert macro (from <assert.h> or <cassert>)
@@ -120,12 +100,38 @@ following math functions are not supported now:
120100
- lrintf, lrint
121101
- nexttowardf, nexttoward
122102
- nanf, nan
103+
123104
Device libraries can't support both single and double precision as some
124105
underlying device may not support double precision.
125106
'ldexpf' and 'frexpf' from MSVC <math.h> are implemented using corresponding
126107
double precision version, they can be used only when double precision is
127108
supported by underlying device.
128109

110+
All device libraries without double precision usage are linked by default and
111+
in order to use double precision device library, please add
112+
'-fsycl-device-lib=libm-fp64' or '-fsycl-device-lib=all'.
113+
114+
For example, no options need to be added to use `assert` or float precision
115+
math functions:
116+
.. code:
117+
clang++ -fsycl main.cpp -o main.o
118+
119+
To use double precision math functions:
120+
.. code:
121+
clang++ -fsycl -fsycl-device-lib=libm-fp64 main.cpp -o main.o
122+
123+
For Ahead-Of-Time compilation (AOT), the steps to use device libraries is
124+
same, no options need to be added to use `assert` or float precision math
125+
functions:
126+
.. code:
127+
clang++ -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice \
128+
main.cpp -o main.o
129+
130+
To use double precision math functions in AOT:
131+
.. code:
132+
clang++ -fsycl -fsycl-device-lib=libm-fp64 -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice \
133+
main.cpp -o main.o
134+
129135
Example of usage
130136
================
131137

@@ -212,11 +218,7 @@ wrapper libraries are provided with the SYCL compiler that "lower"
212218
libc implementation-specific functions into a stable set of functions,
213219
that can be later handled by a device compiler.
214220

215-
.. code:
216-
clang++ -fsycl -c main.cpp -o main.o
217-
clang++ -fsycl main.o $(SYCL_INSTALL)/lib/libsycl-glibc.o -o a.out
218-
219-
This `libsycl-glibc.o` is one of these wrapper libraries: it provides
221+
This `libsycl-crt.o` is one of these wrapper libraries: it provides
220222
definitions for glibc specific library function, and these definitions
221223
call the corresponding functions from `__devicelib_*` set of
222224
functions.
@@ -237,11 +239,7 @@ For example, `__assert_fail` from IR above gets transformed into:
237239
unreachable
238240
239241
A single wrapper object provides function wrappers for *all* supported
240-
library functions. Every supported C library implementation (MSVC or
241-
glibc) has its own wrapper library object:
242-
243-
- libsycl-glibc.o
244-
- libsycl-msvc.o
242+
library functions.
245243

246244
SPIR-V
247245
======
@@ -283,4 +281,5 @@ extension is provided as `libsycl-fallback-cassert.spv`
283281
For AOT compilation, fallback libraries are provided as object files
284282
(e.g. `libsycl-fallback-cassert.o`) which contain device code in LLVM
285283
IR format. Device code in these object files is equivalent to device
286-
code in the `*.spv` files.
284+
code in the `*.spv` files. Those object files are located in compiler
285+
package's 'lib/' folder.

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,6 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M,
388388
// If device image is not SPIR-V, DeviceLibReqMask will be 0 which means
389389
// no fallback device library will be linked.
390390
uint32_t DeviceLibReqMask = 0;
391-
// FIXME: disable the fallback device libraries online link as not all
392-
// backend supports spv online link. Need to enable it when all backends
393-
// support spv online link.
394391
if (Img.getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV &&
395392
!SYCLConfig<SYCL_DEVICELIB_NO_FALLBACK>::get())
396393
DeviceLibReqMask = getDeviceLibReqMask(Img);
@@ -797,11 +794,11 @@ ProgramManager::ProgramPtr ProgramManager::build(
797794
LinkOpts = LinkOptions.c_str();
798795
}
799796

800-
// TODO: Because online linking isn't implemented yet on Level Zero, the
801-
// compiler always links against the fallback device libraries. Once
802-
// online linking is supported on all backends, we should remove the line
803-
// below and also change the compiler, so it no longer links the fallback
804-
// code unconditionally.
797+
// TODO: Currently, online linking isn't implemented yet on Level Zero.
798+
// To enable device libraries and unify the behaviors on all backends,
799+
// online linking is disabled temporarily, all fallback device libraries
800+
// will be linked offline. When Level Zero supports online linking, we need
801+
// to remove the line of code below and switch back to online linking.
805802
LinkDeviceLibs = false;
806803

807804
// TODO: this is a temporary workaround for GPU tests for ESIMD compiler.

0 commit comments

Comments
 (0)