Skip to content

Commit 1f2ea6d

Browse files
author
LU-JOHN
authored
[SYCL][Doc] Describe sycl-post-link support for dynamic linking (#14337)
Describe behavior of sycl-post-link in support of dynamic linking --------- Signed-off-by: Lu, John <[email protected]>
1 parent 711655c commit 1f2ea6d

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

sycl/doc/design/SharedLibraries.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,34 @@ For this purpose DPC++ front-end generates `module-id` attribute on each
148148
149149
### sycl-post-link changes
150150
151-
In order to support dynamic linking of device code, `sycl-post-link` performs
152-
2 main tasks:
151+
When device code splitting is performed during a typical compilation of a SYCL offloading program,
152+
all dependent device code is brought into a split image in order to construct a complete image.
153+
When device code splitting is performed during the compilation flow to generate a dynamic library,
154+
construction of a complete device image is not possible since the dynamic library may rely on
155+
functions that are not defined in the library. Thus, when supporting dynamic linking a dependency
156+
to a `canBeImportedFunction` will not cause the dependent function to be added to the image.
157+
158+
`canBeImportedFunction` is a boolean function accepting a Function input and returns true
159+
if the Function "can be imported". A `canBeImportedFunction` is:
160+
161+
1. Not an intrinsic
162+
2. Name does not start with "__"
163+
3. Demangled name does not start with "__"
164+
4. Must be a `SYCL_EXTERNAL` function
165+
166+
More information about `SYCL_EXTERNAL` can be found in:
167+
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#subsec:syclexternal
168+
169+
In order to support dynamic linking of device code, `sycl-post-link` has
170+
the following modifications:
171+
172+
- Device images that have a dependency to a `canBeImportedFunction` do not include the
173+
function. Instead the dependency is recorded in the imported symbols property list.
174+
- An image that provides a `canBeImportedFunction` has the symbol recorded in the exported
175+
symbols property list.
176+
- All functions symbols that are not `canBeImportedFunction` are internalized
177+
153178
154-
- Supplies device images containing exports with an information about exported
155-
symbols
156-
- Supplies device images with an information about imported symbols
157179
158180
In addition, `SYCL_EXTERNAL` functions as well as kernels are considered as entry
159181
points during device code split.

0 commit comments

Comments
 (0)