1
1
# Overview
2
+
2
3
The SYCL* Compiler compiles C++\- based SYCL source files with code for both CPU
3
4
and a wide range of compute accelerators. The compiler uses Khronos*
4
5
OpenCL&trade ; API to offload computations to accelerators.
5
6
7
+ # Table of contents
6
8
7
- # Before You Begin
8
-
9
- ### Get ` OpenCL runtime ` for CPU and/or GPU on ` Linux ` :
10
-
11
- a. OpenCL&trade ; runtime for GPU: follow instructions on
12
- [ github.com/intel/compute-runtime/releases] ( https://github.com/intel/compute-runtime/releases )
13
- to install.
14
-
15
- b. Experimental Intel® ; CPU Runtime for OpenCL&trade ; Applications with
16
- SYCL support: follow the instructions under
17
- [ SYCL* Compiler and Runtimes] ( https://github.com/intel/llvm/releases/tag/2019-07 )
18
-
19
- ### Get ` OpenCL runtime ` for CPU and/or GPU on ` Windows ` :
20
- a. OpenCL&trade ; runtime for GPU and CPU: download it from
21
- [ Intel® ; Download Center] ( https://downloadcenter.intel.com/download/28991/Intel-Graphics-Windows-10-DCH-Drivers )
9
+ * [ Prerequisites] ( #prerequisites )
10
+ * [ Create SYCL workspace] ( #create-sycl-workspace )
11
+ * [ Build SYCL toolchain] ( #build-sycl-toolchain )
12
+ * [ Build SYCL toolchain with libc++ library] ( #build-sycl-toolchain-with-libc-library )
13
+ * [ Use SYCL toolchain] ( #use-sycl-toolchain )
14
+ * [ Install low level runtime] ( #install-low-level-runtime )
15
+ * [ Test SYCL toolchain] ( #test-sycl-toolchain )
16
+ * [ Run simple SYCL application] ( #run-simple-sycl-application )
17
+ * [ C++ standard] ( #c-standard )
18
+ * [ Known Issues and Limitations] ( #known-issues-and-limitations )
19
+ * [ Find More] ( #find-more )
22
20
23
- b. The latest/experimental Intel® ; CPU Runtime for OpenCL&trade ; Applications with SYCL support
24
- on Windows ` will soon be published ` together with Linux runtime at [ SYCL* Compiler and Runtimes] ( https://github.com/intel/llvm/releases )
21
+ # Prerequisites
25
22
26
- ### Get the required tools:
23
+ * ` git ` - https://git-scm.com/downloads
24
+ * ` cmake ` version 3.2 or later - http://www.cmake.org/download/
25
+ * ` python ` - https://www.python.org/downloads/release/python-2716/
26
+ * C++ compiler
27
+ * Linux: ` GCC ` version 5.1.0 or later (including libstdc++) -
28
+ https://gcc.gnu.org/install/
29
+ * Windows: ` Visual Studio ` version 15.7 preview 4 or later -
30
+ https://visualstudio.microsoft.com/downloads/
27
31
28
- a. ` git ` - for downloading the sources (Get it at https://git-scm.com/downloads )
32
+ ## Create SYCL workspace
29
33
30
- b. ` cmake ` - for building the compiler and tools, version 3.2 or later (Get it at: http://www.cmake.org/download )
34
+ Throughout this document ` SYCL_HOME ` denotes the path to the local directory
35
+ created as SYCL workspace. It might be useful to create an environment variable
36
+ with the same name.
31
37
32
- c. ` python ` - for building the compiler and running tests (Get it at: https://www.python.org/downloads/release/python-2716/ )
38
+ ** Linux **
33
39
34
- d. ` Visual Studio 2017 or later ` (Windows only. Get it at: https://visualstudio.microsoft.com/downloads/ )
35
-
36
-
37
- # Configure environment:
38
- 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.
39
- ### Linux:
40
40
``` bash
41
- export SYCL_HOME=/export/home/workspaces/ sycl_workspace
41
+ export SYCL_HOME=/export/home/sycl_workspace
42
42
mkdir $SYCL_HOME
43
43
```
44
- ### Windows:
45
- Open a developer command prompt using one of tho methods:
46
- - Click start menu and search for the command prompt. So, for MSVC-2017 it is '` x64 Native Tools Command Prompt for VS 2017 ` '
47
- - run 'cmd' and then '` "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 ` '
48
44
49
- ``` bash
50
- set SYCL_HOME=%USERPROFILE%\w orkspaces\s ycl_workspace
51
- mkdir %SYCL_HOME%
52
- ```
53
- # Get ` OpenCL-Headers ` and ` OpenCL-ICD-Loader `
54
-
55
- ** These 2 steps are optional.** The Compiler build process is going to look for available OpenCL SDK on the local machine.
56
- 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.
57
- 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.
58
-
59
- ## Get ` OpenCL-Headers `
60
- ### Linux:
61
- ``` bash
62
- cd $SYCL_HOME
63
- git clone https://github.com/KhronosGroup/OpenCL-Headers
64
- export OPENCL_HEADERS=$SYCL_HOME /OpenCL-Headers
65
- ```
66
-
67
- ### Windows:
68
- ``` bash
69
- cd %SYCL_HOME%
70
- git clone https://github.com/KhronosGroup/OpenCL-Headers
71
- set OPENCL_HEADERS=%SYCL_HOME%\O penCL-Headers
72
- ```
45
+ ** Windows**
73
46
74
- ## Get ` OpenCL-ICD-Loader `
75
- You can also find the most recent instructions for this component at https://github.com/KhronosGroup/OpenCL-ICD-Loader
47
+ Open a developer command prompt using one of two methods:
76
48
77
- ### Linux:
78
- ``` bash
79
- cd $SYCL_HOME
80
- git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
81
- cd OpenCL-ICD-Loader
82
- mkdir build
83
- cd build
84
- cmake -DOPENCL_ICD_LOADER_HEADERS_DIR=$OPENCL_HEADERS ..
85
- make
86
- export ICD_LIB=$SYCL_HOME /OpenCL-ICD-Loader/build/libOpenCL.so
87
- ```
49
+ - Click start menu and search for "Developer Command Prompt for VS XX", where
50
+ XX is a version of installed Visual Studio.
51
+ - Ctrl-R, write "cmd", click enter, then run
52
+ ` "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 `
88
53
89
- ### Windows:
90
- ``` bash
91
- cd %SYCL_HOME%
92
- git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
93
- cd OpenCL-ICD-Loader
94
- mkdir build
95
- cd build
96
- cmake -G " Ninja" -DOPENCL_ICD_LOADER_HEADERS_DIR=%OPENCL_HEADERS% -DOPENCL_ICD_LOADER_REQUIRE_WDK=OFF ..
97
- ninja
98
- set ICD_LIB=%SYCL_HOME%\O penCL-ICD-Loader\b uild\O penCL.lib
54
+ ``` bat
55
+ set SYCL_HOME=%USERPROFILE%\sycl_workspace
56
+ mkdir %SYCL_HOME%
99
57
```
100
58
101
- # Checkout and Build the SYCL compiler and runtime
102
-
103
- Defining paths to ` OpenCL-Headers ` and ` OpenCL-ICD-Loader ` is optional ( ` -DOpenCL_INCLUDE_DIR= ` and ` -DOpenCL_LIBRARY= ` ).
104
- If you do not specify the paths explicitly, then:
105
- - If ` OpenCL-Headers ` and ` OpenCL-ICD-Loader ` are availalbe in the system, they will be used;
106
- - If they are not available, then OpenCL files are automatically downloaded/built from GitHub during compiler build.
59
+ # Build SYCL toolchain
107
60
108
- ### Linux:
61
+ ** Linux**
109
62
``` bash
110
63
cd $SYCL_HOME
111
64
git clone https://github.com/intel/llvm -b sycl
@@ -117,62 +70,116 @@ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" \
117
70
-DLLVM_ENABLE_PROJECTS=" clang;llvm-spirv;sycl" \
118
71
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME /llvm/sycl \
119
72
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME /llvm/llvm-spirv \
120
- -DOpenCL_INCLUDE_DIR=" $OPENCL_HEADERS " -DOpenCL_LIBRARY=" $ICD_LIB " \
121
73
$SYCL_HOME /llvm/llvm
122
74
123
75
make -j` nproc` sycl-toolchain
124
76
```
125
- ### Windows:
126
- ``` bash
127
- mkdir %SYCL_HOME%
77
+
78
+ ** Windows **
79
+ ``` bat
128
80
cd %SYCL_HOME%
129
81
git clone https://github.com/intel/llvm -b sycl
130
82
mkdir %SYCL_HOME%\build
131
83
cd %SYCL_HOME%\build
132
84
133
- 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"
85
+ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86"^
86
+ -DLLVM_EXTERNAL_PROJECTS="llvm-spirv;sycl"^
87
+ -DLLVM_ENABLE_PROJECTS="clang;llvm-spirv;sycl"^
88
+ -DLLVM_EXTERNAL_SYCL_SOURCE_DIR="%SYCL_HOME%\llvm\sycl"^
89
+ -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR="%SYCL_HOME%\llvm\llvm-spirv"^
90
+ -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_FLAGS="/GS"^
91
+ -DCMAKE_CXX_FLAGS="/GS" -DCMAKE_EXE_LINKER_FLAGS="/NXCompat /DynamicBase"^
92
+ -DCMAKE_SHARED_LINKER_FLAGS="/NXCompat /DynamicBase"^
93
+ "%SYCL_HOME%\llvm\llvm"
134
94
135
95
ninja sycl-toolchain
136
96
```
137
97
138
- After the build completed, the SYCL compiler/include/libraries can be found
139
- in ` $SYCL_HOME/build ` directory.
140
-
141
- ---
98
+ TODO: add instructions how to deploy built SYCL toolchain.
142
99
143
- ## Build the SYCL runtime with libc++ library.
100
+ ## Build SYCL toolchain with libc++ library
144
101
145
102
There is experimental support for building and linking SYCL runtime with
146
- libc++ library instead of libstdc++. To enable it the following cmake options
103
+ libc++ library instead of libstdc++. To enable it the following CMake options
147
104
should be used.
148
- ### Linux:
105
+
106
+ ** Linux**
149
107
```
150
108
-DSYCL_USE_LIBCXX=ON \
151
109
-DSYCL_LIBCXX_INCLUDE_PATH=<path to libc++ headers> \
152
110
-DSYCL_LIBCXX_LIBRARY_PATH=<path to libc++ and libc++abi libraries>
153
111
```
154
- # Test the SYCL compiler and runtime
155
112
156
- 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:
157
- ### Linux:
113
+ # Use SYCL toolchain
114
+
115
+ ## Install low level runtime
116
+
117
+ To run SYCL applications on OpenCL devices, OpenCL implementation(s) must be
118
+ present in the system.
119
+
120
+ To execute SYCL tests on Intel devices following runtimes should be installed:
121
+
122
+ ** Linux**
123
+
124
+ * Intel GPU [ Intel® ; Graphics Compute Runtime for
125
+ OpenCL&trade ; ] ( https://github.com/intel/compute-runtime/releases )
126
+ * Intel CPU - [ Experimental Intel® ; CPU Runtime for OpenCL&trade ; Applications
127
+ with SYCL support] ( https://github.com/intel/llvm/releases )
128
+ * Intel FPGA - TBD.
129
+
130
+ ** Windows**
131
+ * OpenCL&trade ; runtime for Intel GPU [ Intel® ; Download
132
+ Center] ( https://downloadcenter.intel.com/product/80939/Graphics-Drivers )
133
+
134
+ * The experimental Intel® ; CPU Runtime for OpenCL&trade ; Applications with
135
+ SYCL support on Windows will be available soon.
136
+
137
+ Please, refer to [ the Release Notes] ( ../ReleaseNotes.md ) for recommended Intel
138
+ runtime versions.
139
+
140
+ ## Test SYCL toolchain
141
+
142
+ ### Run regression tests
143
+
144
+ To verify that built SYCL toolchain is working correctly, run:
145
+
146
+ ** Linux**
158
147
``` bash
159
- make -j` nproc` check-all # to run all test suites including those smaller ones shown below
160
- make -j` nproc` check-llvm # run llvm tests only
161
- make -j` nproc` check-llvm-spirv # run llvm-spirv tests only
162
- make -j` nproc` check-clang # run clang tests only
163
- make -j` nproc` check-sycl # run sycl tests only
148
+ make -j` nproc` check-all
164
149
```
165
- ### Windows:
166
- ``` bash
150
+
151
+ ** Windows**
152
+ ``` bat
167
153
ninja check-all
168
- ninja check-llvm
169
- ninja check-llvm-spirv
170
- ninja check-clang
171
- ninja check-sycl
172
154
```
173
- If no OpenCL GPU/CPU runtimes are available, the corresponding LIT tests are skipped
174
155
175
- # Create a simple SYCL program
156
+ If no OpenCL GPU/CPU runtimes are available, the corresponding tests are
157
+ skipped.
158
+
159
+ ### Run Khronos SYCL conformance test suite (optional)
160
+
161
+ Khronos SYCL conformance test suite (CTS) is intended to validate SYCL
162
+ implementation conformance to Khronos SYCL specification.
163
+
164
+ Follow Khronos SYCL-CTS instructions from
165
+ [ README] ( https://github.com/KhronosGroup/SYCL-CTS#sycl-121-conformance-test-suite )
166
+ file to obtain test sources and instructions how build and execute the tests.
167
+
168
+ To configure testing of "Intel SYCL" toochain set
169
+ ` SYCL_IMPLEMENTATION=Intel_SYCL ` and ` Intel_SYCL_ROOT=<path to the SYCL installation> `
170
+ CMake variables.
171
+
172
+ ** Linux**
173
+ ``` bash
174
+ cmake -DIntel_SYCL_ROOT=$SYCL_HOME /deploy -DSYCL_IMPLEMENTATION=Intel_SYCL ...
175
+ ```
176
+
177
+ ** Windows**
178
+ ``` bat
179
+ cmake -DIntel_SYCL_ROOT=%SYCL_HOME%\deploy -DSYCL_IMPLEMENTATION=Intel_SYCL ...
180
+ ```
181
+
182
+ ## Run simple SYCL application
176
183
177
184
A simple SYCL program consists of following parts:
178
185
1 . Header section
@@ -234,43 +241,43 @@ int main() {
234
241
235
242
```
236
243
237
- # Build and Test a simple SYCL program
238
-
239
- To build simple-sycl-app put ` bin ` and ` lib ` to PATHs and run following command:
240
- ### Linux:
241
- ``` bash
242
- export PATH=$SYCL_HOME /build/bin:$PATH
243
- export LD_LIBRARY_PATH=$SYCL_HOME /build/lib:$LD_LIBRARY_PATH
244
- ```
245
- ### Windows:
246
- ``` bash
247
- set PATH=%SYCL_HOME%\b uild\b in; %PATH%
248
- set LIB=%SYCL_HOME%\b uild\l ib; %LIB%
249
- ```
250
-
251
- ### Linux & Windows:
252
- ``` bash
253
- clang++ -fsycl simple-sycl-app.cpp -o simple-sycl-app.exe -lOpenCL
254
- ```
244
+ To build simple-sycl-app put ` bin ` and ` lib ` to PATHs:
255
245
256
- This ` simple-sycl-app.exe ` application doesn't specify SYCL device for execution,
257
- so SYCL runtime will first try to execute on OpenCL GPU device first, if OpenCL
258
- GPU device is not found, it will try to run OpenCL CPU device; and if OpenCL
259
- CPU device is also not available, SYCL runtime will run on SYCL host device.
246
+ ** Linux**
247
+ ``` bash
248
+ export PATH=$SYCL_HOME /build/bin:$PATH
249
+ export LD_LIBRARY_PATH=$SYCL_HOME /build/lib:$LD_LIBRARY_PATH
250
+ ```
251
+
252
+ ** Windows**
253
+ ``` bat
254
+ set PATH=%SYCL_HOME%\build\bin;%PATH%
255
+ set LIB=%SYCL_HOME%\build\lib;%LIB%
256
+ ```
257
+
258
+ and run following command:
259
+
260
+ ``` bash
261
+ clang++ -fsycl simple-sycl-app.cpp -o simple-sycl-app.exe
262
+ ```
260
263
261
- ### Linux & Windows:
262
- ``` bash
263
- ./simple-sycl-app.exe
264
- The results are correct!
265
- ```
264
+ This ` simple-sycl-app.exe ` application doesn't specify SYCL device for execution,
265
+ so SYCL runtime will use ` default_selector ` logic to select one of accelerators
266
+ available in the system or SYCL host device.
266
267
268
+ ** Linux & Windows**
269
+ ``` bash
270
+ ./simple-sycl-app.exe
271
+ The results are correct!
272
+ ```
267
273
268
274
NOTE: SYCL developer can specify SYCL device for execution using device
269
- selectors (e.g. ` cl::sycl::cpu_selector ` , ` cl::sycl::gpu_selector ` ) as
275
+ selectors (e.g. ` cl::sycl::cpu_selector ` , ` cl::sycl::gpu_selector ` ,
276
+ [ Intel FPGA selector(s)] ( extensions/IntelFPGA/FPGASelector.md ) ) as
270
277
explained in following section [ Code the program for a specific
271
278
GPU] ( #code-the-program-for-a-specific-gpu ) .
272
279
273
- # Code the program for a specific GPU
280
+ ## Code the program for a specific GPU
274
281
275
282
To specify OpenCL device SYCL provides the abstract ` cl::sycl::device_selector `
276
283
class which the can be used to define how the runtime should select the best
@@ -299,7 +306,7 @@ int main() {
299
306
const std::string DeviceName = Device.get_info<device::name>();
300
307
const std::string DeviceVendor = Device.get_info<device::vendor>();
301
308
302
- return Device.is_gpu() && DeviceName.find("HD Graphics NEO") ? 1 : -1 ;
309
+ return Device.is_gpu() && ( DeviceName.find("HD Graphics NEO") != std::string::npos) ;
303
310
}
304
311
};
305
312
@@ -317,7 +324,7 @@ int main() {
317
324
# C++ standard
318
325
- Minimally support C++ standard is c++11 on Linux and c++14 on Windows.
319
326
320
- # Known Issues or Limitations
327
+ # Known Issues and Limitations
321
328
322
329
- SYCL device compiler fails if the same kernel was used in different
323
330
translation units.
0 commit comments