Skip to content

Commit 2276a42

Browse files
v-klochkovbader
authored andcommitted
[SYCL][DOC] Add build instructions for Windows to GetStartedWithSYCLCompiler.md
1. Fixed an error in cmake command for Linux. 2. Added steps for OpenCL-Headers and OpenCL-ICD-Loader components, which are required. 3. Added Windows build instructions. 4. Made the build process more verbose and clear. You can literally follow the guide step-by-step to build compiler and tools and run a simple test. Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent f0f9120 commit 2276a42

File tree

1 file changed

+143
-30
lines changed

1 file changed

+143
-30
lines changed

sycl/doc/GetStartedWithSYCLCompiler.md

Lines changed: 143 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Overview
2-
32
The SYCL* Compiler compiles C++\-based SYCL source files with code for both CPU
43
and a wide range of compute accelerators. The compiler uses Khronos*
54
OpenCL&trade; API to offload computations to accelerators.
65

6+
77
# Before You Begin
88

9-
OpenCL runtime for CPU and/or GPU:
9+
### Get `OpenCL runtime` for CPU and/or GPU:
1010

1111
a. OpenCL runtime for GPU: follow instructions on
1212
[github.com/intel/compute-runtime/releases](https://github.com/intel/compute-runtime/releases)
@@ -16,55 +16,156 @@ to install.
1616
SYCL support: follow the instructions under
1717
[SYCL* Compiler and Runtimes](https://github.com/intel/llvm/releases/tag/2019-07)
1818

19-
# Build the SYCL compiler and runtime
19+
### Get the required tools:
20+
21+
a. `git` - for downloading the sources (Get it at https://git-scm.com/downloads)
22+
23+
b. `cmake` - for building the compiler and tools, version 3.2 or later (Get it at: http://www.cmake.org/download)
24+
25+
c. `python` - for building the compiler and running tests (Get it at: https://www.python.org/downloads/release/python-2716/ )
26+
27+
d. `Visual Studio 2017 or later` (Windows only. Get it at: https://visualstudio.microsoft.com/downloads/)
28+
29+
30+
# Configure environment:
31+
For simplicity it is assumed below that the environment variable SYCL_HOME contains path to a folder where the SYCL compiler and runtime will be stored.
32+
### Linux:
33+
```bash
34+
export SYCL_HOME=/export/home/workspaces/sycl_workspace
35+
mkdir $SYCL_HOME
36+
```
37+
### Windows:
38+
Open a developer command prompt using one of tho methods:
39+
- Click start menu and search for the command prompt. So, for MSVC-2017 it is '`x64 Native Tools Command Prompt for VS 2017`'
40+
- run 'cmd' and then '`"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64`'
41+
42+
```bash
43+
set SYCL_HOME=%USERPROFILE%\workspaces\sycl_workspace
44+
mkdir %SYCL_HOME%
45+
```
46+
# Get `OpenCL-Headers` and `OpenCL-ICD-Loader`
47+
48+
**These 2 steps are optional.** The Compiler build process is going to look for available OpenCL SDK on the local machine.
49+
If it finds suitable OpenCL, it will reuse it. Otherwise, it will automatically download `OpenCL-Headers` and `OpenCL-ICD-Loader` from GitHub and build it.
50+
You may want to run these steps if have some unexpected problems caused by `OpenCL-Headers` or `OpenCL-ICD-Loader` at the compiler build phase.
51+
52+
## Get `OpenCL-Headers`
53+
### Linux:
54+
```bash
55+
cd $SYCL_HOME
56+
git clone https://github.com/KhronosGroup/OpenCL-Headers
57+
export OPENCL_HEADERS=$SYCL_HOME/OpenCL-Headers
58+
```
59+
60+
### Windows:
61+
```bash
62+
cd %SYCL_HOME%
63+
git clone https://github.com/KhronosGroup/OpenCL-Headers
64+
set OPENCL_HEADERS=%SYCL_HOME%\OpenCL-Headers
65+
```
2066

21-
Download the LLVM* repository with SYCL support to your local machine folder
22-
e.g. `$HOME/sycl` (assuming environment var `$SYCL_HOME`) folder using
23-
following command:
67+
## Get `OpenCL-ICD-Loader`
68+
You can also find the most recent instructions for this component at https://github.com/KhronosGroup/OpenCL-ICD-Loader
69+
70+
### Linux:
71+
```bash
72+
cd $SYCL_HOME
73+
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
74+
cd OpenCL-ICD-Loader
75+
mkdir build
76+
cd build
77+
cmake -DOPENCL_ICD_LOADER_HEADERS_DIR=$OPENCL_HEADERS ..
78+
make
79+
export ICD_LIB=$SYCL_HOME/OpenCL-ICD-Loader/build/libOpenCL.so
80+
```
2481

82+
### Windows:
2583
```bash
26-
git clone https://github.com/intel/llvm -b sycl $HOME/sycl
84+
cd %SYCL_HOME%
85+
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
86+
cd OpenCL-ICD-Loader
87+
mkdir build
88+
cd build
89+
cmake -G "Ninja" -DOPENCL_ICD_LOADER_HEADERS_DIR=%OPENCL_HEADERS% -DOPENCL_ICD_LOADER_REQUIRE_WDK=OFF ..
90+
ninja
91+
set ICD_LIB=%SYCL_HOME%\OpenCL-ICD-Loader\build\OpenCL.lib
2792
```
2893

29-
Build the SYCL compiler and runtime following instruction below:
94+
# Checkout and Build the SYCL compiler and runtime
95+
96+
Defining paths to `OpenCL-Headers` and `OpenCL-ICD-Loader` is optional ( `-DOpenCL_INCLUDE_DIR=` and `-DOpenCL_LIBRARY=` ).
97+
If you do not specify the paths explicitly, then:
98+
- If `OpenCL-Headers` and `OpenCL-ICD-Loader` are availalbe in the system, they will be used;
99+
- If they are not available, then OpenCL files are automatically downloaded/built from GitHub during compiler build.
30100

101+
### Linux:
31102
```bash
103+
cd $SYCL_HOME
104+
git clone https://github.com/intel/llvm -b sycl
32105
mkdir $SYCL_HOME/build
33106
cd $SYCL_HOME/build
34-
cmake -DCMAKE_BUILD_TYPE=Release \
107+
108+
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" \
35109
-DLLVM_EXTERNAL_PROJECTS="llvm-spirv;sycl" \
36-
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME/sycl \
37-
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME/llvm-spirv \
38110
-DLLVM_ENABLE_PROJECTS="clang;llvm-spirv;sycl" \
39-
$SYCL_HOME/llvm
111+
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME/llvm/sycl \
112+
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME/llvm/llvm-spirv \
113+
-DOpenCL_INCLUDE_DIR="$OPENCL_HEADERS" -DOpenCL_LIBRARY="$ICD_LIB" \
114+
$SYCL_HOME/llvm/llvm
115+
40116
make -j`nproc` sycl-toolchain
41117
```
118+
### Windows:
119+
```bash
120+
mkdir %SYCL_HOME%
121+
cd %SYCL_HOME%
122+
git clone https://github.com/intel/llvm -b sycl
123+
mkdir %SYCL_HOME%\build
124+
cd %SYCL_HOME%\build
125+
126+
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_EXTERNAL_PROJECTS="llvm-spirv;sycl" -DLLVM_ENABLE_PROJECTS="clang;llvm-spirv;sycl" -DLLVM_EXTERNAL_SYCL_SOURCE_DIR="%SYCL_HOME%\llvm\sycl" -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR="%SYCL_HOME%\llvm\llvm-spirv" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_FLAGS="/GS" -DCMAKE_CXX_FLAGS="/GS" -DCMAKE_EXE_LINKER_FLAGS="/NXCompat /DynamicBase" -DCMAKE_SHARED_LINKER_FLAGS="/NXCompat /DynamicBase" -DOpenCL_INCLUDE_DIR="%OPENCL_HEADERS%" -DOpenCL_LIBRARY="%ICD_LIB%" "%SYCL_HOME%\llvm\llvm"
127+
128+
ninja sycl-toolchain
129+
```
42130

43131
After the build completed, the SYCL compiler/include/libraries can be found
44-
under `$SYCL_HOME/build` directory.
132+
in `$SYCL_HOME/build` directory.
133+
134+
---
45135

46136
## Build the SYCL runtime with libc++ library.
47137

48138
There is experimental support for building and linking SYCL runtime with
49139
libc++ library instead of libstdc++. To enable it the following cmake options
50-
should be used:
51-
140+
should be used.
141+
### Linux:
52142
```
53143
-DSYCL_USE_LIBCXX=ON \
54144
-DSYCL_LIBCXX_INCLUDE_PATH=<path to libc++ headers> \
55145
-DSYCL_LIBCXX_LIBRARY_PATH=<path to libc++ and libc++abi libraries>
56146
```
57-
58147
# Test the SYCL compiler and runtime
59148

60-
Run LIT testing using the command below after building SYCL compiler and runtime.
61-
149+
After building the SYCL compiler and runtime, choose the amount of LIT testing you need and run one of the LIT tests suites shown below:
150+
### Linux:
62151
```bash
63-
make -j`nproc` check-all
152+
make -j`nproc` check-all # to run all test suites including those smaller ones shown below
153+
make -j`nproc` check-llvm # run llvm tests only
154+
make -j`nproc` check-llvm-spirv # run llvm-spirv tests only
155+
make -j`nproc` check-clang # run clang tests only
156+
make -j`nproc` check-sycl # run sycl tests only
157+
```
158+
### Windows:
159+
```bash
160+
ninja check-all
161+
ninja check-llvm
162+
ninja check-llvm-spirv
163+
ninja check-clang
164+
ninja check-sycl
64165
```
65166
If no OpenCL GPU/CPU runtimes are available, the corresponding LIT tests are skipped
66167

67-
# Creating a simple SYCL program
168+
# Create a simple SYCL program
68169

69170
A simple SYCL program consists of following parts:
70171
1. Header section
@@ -78,7 +179,6 @@ A simple SYCL program consists of following parts:
78179
Creating a file `simple-sycl-app.cpp` with the following C++ SYCL code in it:
79180

80181
```c++
81-
82182
#include <CL/sycl.hpp>
83183

84184
int main() {
@@ -129,21 +229,34 @@ int main() {
129229

130230
# Build and Test a simple SYCL program
131231

132-
To build simple-sycl-app run following command:
232+
To build simple-sycl-app put `bin` and `lib` to PATHs and run following command:
233+
### Linux:
234+
```bash
235+
export PATH=$SYCL_HOME/build/bin:$PATH
236+
export LD_LIBRARY_PATH=$SYCL_HOME/build/lib:$LD_LIBRARY_PATH
237+
```
238+
### Windows:
239+
```bash
240+
set PATH=%SYCL_HOME%\build\bin;%PATH%
241+
set LIB=%SYCL_HOME%\build\lib;%LIB%
242+
```
133243

134-
```console
135-
clang++ -std=c++11 -fsycl simple-sycl-app.cpp -o simple-sycl-app -lOpenCL
244+
### Linux & Windows:
245+
```bash
246+
clang++ -fsycl simple-sycl-app.cpp -o simple-sycl-app.exe -lOpenCL
136247
```
137248

138-
This `simple-sycl-app` application doesn't specify SYCL device for execution,
249+
This `simple-sycl-app.exe` application doesn't specify SYCL device for execution,
139250
so SYCL runtime will first try to execute on OpenCL GPU device first, if OpenCL
140251
GPU device is not found, it will try to run OpenCL CPU device; and if OpenCL
141252
CPU device is also not available, SYCL runtime will run on SYCL host device.
142253

143-
To run the `simple-sycl-app`:
254+
### Linux & Windows:
255+
```bash
256+
./simple-sycl-app.exe
257+
The results are correct!
258+
```
144259

145-
LD_LIBRARY_PATH=$SYCL_HOME/build/lib ./simple-sycl-app
146-
The results are correct!
147260

148261
NOTE: SYCL developer can specify SYCL device for execution using device
149262
selectors (e.g. `cl::sycl::cpu_selector`, `cl::sycl::gpu_selector`) as
@@ -194,6 +307,8 @@ int main() {
194307

195308
```
196309

310+
# C++ standard
311+
- Minimally support C++ standard is c++11 on Linux and c++14 on Windows.
197312

198313
# Known Issues or Limitations
199314

@@ -202,8 +317,6 @@ int main() {
202317
- SYCL host device is not fully supported.
203318
- SYCL works only with OpenCL implementations supporting out-of-order queues.
204319

205-
206320
# Find More
207321

208322
SYCL 1.2.1 specification: [www.khronos.org/registry/SYCL/specs/sycl-1.2.1.pdf](https://www.khronos.org/registry/SYCL/specs/sycl-1.2.1.pdf)
209-

0 commit comments

Comments
 (0)