Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 204b096

Browse files
authored
[SYCL][Doc] Add test plan for dynamic linking feature (#382)
1 parent e813726 commit 204b096

File tree

1 file changed

+181
-0
lines changed

1 file changed

+181
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Test plan for dynamic linking of device code
2+
3+
This is a test plan for device code dynamic linking feature described in
4+
https://github.com/intel/llvm/blob/sycl/sycl/doc/SharedLibraries.md document.
5+
6+
## 1. Testing scope
7+
8+
### 1.1. Device & BE coverage
9+
10+
All of the tests described below are performed on Intel CPU and GPU devices.
11+
For GPU device both OpenCL and L0 backends are used.
12+
13+
**NOTE**: The feature isn't supported on FPGA device.
14+
15+
### 1.2. AOT & JIT compilation
16+
17+
All the tests are compiled using AOT, JIT and mixed (AOT with JIT) compilation.
18+
Mixed compilation is the case when application is built using AOT and used
19+
shared library uses JIT or vice versa.
20+
21+
### 1.3. Device code split modes
22+
23+
All the tests are compiled using different combination of device code split
24+
mode.
25+
There are four possible device code split modes that can be requested via
26+
`fsycl-device-code-split` compiler's option:
27+
- `per_kernel` - device code module is created for each SYCL kernel
28+
- `per_source` - device code module is created for each source
29+
- `off` - no device code split
30+
- `auto` - use heuristic to select the best way of splitting device code
31+
32+
For each test the main application and all shared libraries are compiled with
33+
all the variations of device code split modes. This results in four binaries for
34+
each application or library.
35+
Each tests covers all the combinations of device code split modes used for
36+
the application and libraries, i.e. all binaries of the application are checked
37+
with all binaries for shared libraries.
38+
For one application and one shared library examples of the combinations will be:
39+
- Application compiled with `per_kernel` and library compiled with `per_kernel`
40+
- Application compiled with `per_kernel` and library compiled with `per_source`
41+
- Application compiled with `per_kernel` and library compiled with `off`
42+
- Application compiled with `per_kernel` and library compiled with `auto`
43+
44+
- Application compiled with `per_source` and library compiled with `per_kernel`
45+
- Application compiled with `per_source` and library compiled with `per_source`
46+
- Application compiled with `per_source` and library compiled with `off`
47+
- Application compiled with `per_source` and library compiled with `auto`
48+
49+
and etc. Total 16 combinations.
50+
51+
## 2. Tests
52+
53+
All the tests consist of at least one main application and at least one shared
54+
library.
55+
For all the tests simple calculation is performed by the application's kernel(s)
56+
that used `SYCL_EXTERNAL` from the shared library. Example : addition of
57+
vectors.
58+
The result of the calculation must be checked on host.
59+
60+
### 2.1. Basic test with shared library
61+
62+
- Several kernels and `SYCL_EXTERNAL` functions are defined in both library and
63+
application.
64+
- At least one `SYCL_EXTERNAL` function defined in shared library is used from
65+
the application's kernel.
66+
- At least one `SYCL_EXTERNAL` function defined in shared library is used in
67+
kernel inside the library.
68+
- Defined kernels are submitted and ran.
69+
70+
### 2.2. Test with dependent shared libraries
71+
72+
The test consists of the main application and **two** shared libraries libA and
73+
libB and performs the following:
74+
- Application defines kernel(s) with dependency on libA.
75+
- libA defines `SYCL_EXTERNAL` function(s) with dependency on libB.
76+
- libB defines `SYCL_EXTERNAL` function(s) without external dependencies.
77+
- Defined kernels are submitted and ran.
78+
79+
### 2.3. Tests with function pointers
80+
81+
#### 2.3.1. Variation 1
82+
83+
- Application defines a function with `indirectly_callable` attribute.
84+
- Shared library defines host API that can receive function pointer as an
85+
argument and runs a kernel that calls through passed function pointer.
86+
- Address of `indirectly_callable` function is taken and passed to shared
87+
library's host API.
88+
89+
#### 2.3.2. Variation 2
90+
91+
- Shared library defines a function with `indirectly_callable` attribute.
92+
- Shared library defines host API that can return a function pointer to
93+
a function with `indirectly_callable` attribute.
94+
- Application used host API of shared library and calls through received
95+
function pointer from a kernel.
96+
97+
### 2.4. Test with shared library without device code
98+
99+
The test aimed to check that support for device code inside shared library
100+
doesn't break support for host-only shared library.
101+
102+
- Shared library defines host-only non-`SYCL_EXTERNAL` function.
103+
- The function from shared library is used by host part of the application.
104+
- Application defines and runs a kernel with a simple calculation.
105+
106+
### 2.5. Tests with run-time loaded shared library
107+
108+
Tests aimed to check that support for dynamic linking of device code doesn't
109+
break run-time loading of shared library.
110+
111+
#### 2.5.1. Variation 1
112+
113+
The test makes sure that run-time loading of host-only shared libraries is
114+
not broken.
115+
116+
- Shared library defines several host-only external functions
117+
- Shared library doesn't contain any device code
118+
- There is no explicit dependencies between application and library
119+
- Shared library is loaded via dlopen/LoadLibrary functionality
120+
- Functions from the shared library are used by host part of the application
121+
to perform a simple calculation
122+
- Result of the simple calculation is checked
123+
124+
#### 2.5.2. Variation 2
125+
126+
The test makes sure that run-time loading of shared libraries with embedded
127+
device code is not broken.
128+
129+
- Shared library defines several host-only external functions, several
130+
`SYCL_EXTERNAL` functions and several kernels
131+
- There is no explicit dependencies between application and library on
132+
device and host
133+
- Shared library is loaded via dlopen/LoadLibrary functionality
134+
- Host functions from the shared library are used by host part of the
135+
application to perform a simple calculation
136+
- Result of the simple calculation is checked
137+
138+
### 2.6. Test with two versions of shared library
139+
140+
The test is compiled with version 1 of the shared library and ran with
141+
shared library of version 2.
142+
Code can be distributed in the same way as in basic test, but `SYCL_EXTERNAL`
143+
functions defined in shared library of version 2, should have a different
144+
definition comparing to version 1, so it is possible to check that correct
145+
version of the shared library were used.
146+
147+
### 2.7. Test with kernel bundle
148+
149+
The tests aim to check that operations with kernel bundles work correctly in
150+
co-existence with dynamic linking feature.
151+
152+
#### 2.7.1. Variation 1
153+
154+
- Shared library defines at least one `SYCL_EXTERNAL` function
155+
- Application defines a kernel with dependency on `SYCL_EXTERNAL` function(s)
156+
from the shared library
157+
- Application gets a `kernel_bundle` object that contains kernel with
158+
dependency (can be done via getting `kernel_id` object and using it as a
159+
parameter for `get_kernel_bundle` free function overload).
160+
- Application builds the `kernel_bundle` object and uses it to run the kernel
161+
with dependency
162+
163+
#### 2.7.2. Variation 2
164+
165+
- Shared library defines at least one `SYCL_EXTERNAL` function
166+
- Shared library defines several kernels, at least one kernel from shared
167+
library uses `SYCL_EXTERNAL` function
168+
- Application defines a kernel with dependency on `SYCL_EXTERNAL` function(s)
169+
from the shared library
170+
- Shared library provides a host function that returns `kernel_bundle` object
171+
containing kernels from the shared library
172+
- Application gets a `kernel_bundle` object that contains kernel with
173+
dependency and links it using link API with `kernel_bundle` that contains
174+
kernels from shared library
175+
- Resulting `kernel_bundle` object is used to run the kernel with dependency
176+
on shared library
177+
178+
### 2.8. Test with several applications
179+
180+
Same as [Basic test with shared library](#Basic-test-with-shared-library) but
181+
two or more applications using same shared library are ran at the same time.

0 commit comments

Comments
 (0)