Skip to content

Commit 5bcbdc3

Browse files
[DOC] Add a guide to update SYCL device library (#2788)
Signed-off-by: Whitney Tsang <[email protected]>
1 parent 29e18cf commit 5bcbdc3

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

docs/update_sycl_libdevice.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Guide to Update SYCL Device Library
2+
3+
This guide will walk you through the steps to update the SYCL device library using the Intel DPC++ compiler.
4+
5+
## Step 1: Display Commands used during Compilation Process
6+
1. Open a terminal.
7+
2. Run the following command to compile a C++ file:
8+
```sh
9+
dpcpp -save-temps -#x t.cpp
10+
```
11+
Replace t.cpp with any C++ file of your choice. This command will display the commands used during the compilation process.
12+
13+
## Step 2: Locate the llvm-link Command
14+
From the output of the previous command, find the llvm-link command line. It should look similar to the following example:
15+
```sh
16+
"/opt/intel/oneapi/compiler/2025.0/bin/compiler/llvm-link" \
17+
-only-needed \
18+
t-sycl-spir64-unknown-unknown-b331ea.bc \
19+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-crt.bc \
20+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-complex.bc \
21+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-complex-fp64.bc \
22+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-cmath.bc \
23+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-cmath-fp64.bc \
24+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-imf.bc \
25+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-imf-fp64.bc \
26+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-imf-bf16.bc \
27+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cassert.bc \
28+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cstring.bc \
29+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-complex.bc \
30+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-complex-fp64.bc \
31+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cmath.bc \
32+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cmath-fp64.bc \
33+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-imf.bc \
34+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-imf-fp64.bc \
35+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-imf-bf16.bc \
36+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-itt-user-wrappers.bc \
37+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-itt-compiler-wrappers.bc \
38+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-itt-stubs.bc \
39+
-o \
40+
t-sycl-spir64-unknown-unknown-d81f68.bc \
41+
--suppress-warnings
42+
```
43+
44+
## Step 3: Modify the llvm-link Command
45+
Remove the `-only-needed` option and the intermediate file `t-sycl-spir64-unknown-unknown-b331ea.bc` from the command line.
46+
And modify to output file name to `libsycl-spir64-unknown-unknown.bc`.
47+
The modified command should look like this:
48+
```sh
49+
"/opt/intel/oneapi/compiler/2025.0/bin/compiler/llvm-link" \
50+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-crt.bc \
51+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-complex.bc \
52+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-complex-fp64.bc \
53+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-cmath.bc \
54+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-cmath-fp64.bc \
55+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-imf.bc \
56+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-imf-fp64.bc \
57+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-imf-bf16.bc \
58+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cassert.bc \
59+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cstring.bc \
60+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-complex.bc \
61+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-complex-fp64.bc \
62+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cmath.bc \
63+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-cmath-fp64.bc \
64+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-imf.bc \
65+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-imf-fp64.bc \
66+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-fallback-imf-bf16.bc \
67+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-itt-user-wrappers.bc \
68+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-itt-compiler-wrappers.bc \
69+
/opt/intel/oneapi/compiler/2025.0/bin/compiler/../../lib/libsycl-itt-stubs.bc \
70+
-o \
71+
libsycl-spir64-unknown-unknown.bc \
72+
--suppress-warnings
73+
```
74+
75+
## Step 4: Execute the Modified Command
76+
Copy the modified llvm-link command.
77+
Paste and run it in the terminal.
78+
79+
## Step 5: Check for Manual Changes
80+
Check the log of the existing device library to see what manual changes need to be made:
81+
```sh
82+
git log third_party/intel/backend/lib/libsycl-spir64-unknown-unknown.bc
83+
```
84+
Look for any specific changes mentioned in the commit messages. For example, from commit 0dd37fc92c46f35c6ced34801e51058b6b89ea47, you need to change one of the module metadata from 4 to 3.
85+
86+
## Step 6: Apply Manual Changes
87+
`llvm-dis` to disassemble the bitcode library, then based on the information from the git log, apply the necessary manual changes to the updated device library.
88+
Reassemble the modified LLVMIR device library using `llvm-as`.
89+
90+
By following these steps, you will have successfully updated the SYCL device library and applied any necessary manual changes.

0 commit comments

Comments
 (0)