Skip to content

Commit 9050a98

Browse files
baderromanovvlad
authored andcommitted
[SYCL][NFC] Get started guide clean-up
- "Table of contents" is added - A few unnecessary sections are removed - Information for testing Intel SYCL implementation with Khronos SYCL conformance test suite is added - Minor style fixes (80-char lines, markdown style, etc.) - Link to CPU runtime is updated - Link to Intel FPGA selector is added - NEOGPUDeviceSelector example is fixed - Compiler invocation example is updated - no need to link OpenCL library - Visual Studio version requirement is updated Signed-off-by: Alexey Bader <[email protected]>
1 parent 7c9087a commit 9050a98

File tree

1 file changed

+152
-145
lines changed

1 file changed

+152
-145
lines changed

sycl/doc/GetStartedWithSYCLCompiler.md

+152-145
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,64 @@
11
# Overview
2+
23
The SYCL* Compiler compiles C++\-based SYCL source files with code for both CPU
34
and a wide range of compute accelerators. The compiler uses Khronos*
45
OpenCL&trade; API to offload computations to accelerators.
56

7+
# Table of contents
68

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&reg; 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&reg; 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)
2220

23-
b. The latest/experimental Intel&reg; 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
2522

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/
2731

28-
a. `git` - for downloading the sources (Get it at https://git-scm.com/downloads)
32+
## Create SYCL workspace
2933

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.
3137

32-
c. `python` - for building the compiler and running tests (Get it at: https://www.python.org/downloads/release/python-2716/ )
38+
**Linux**
3339

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:
4040
```bash
41-
export SYCL_HOME=/export/home/workspaces/sycl_workspace
41+
export SYCL_HOME=/export/home/sycl_workspace
4242
mkdir $SYCL_HOME
4343
```
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`'
4844

49-
```bash
50-
set SYCL_HOME=%USERPROFILE%\workspaces\sycl_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%\OpenCL-Headers
72-
```
45+
**Windows**
7346

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:
7648

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`
8853

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%\OpenCL-ICD-Loader\build\OpenCL.lib
54+
```bat
55+
set SYCL_HOME=%USERPROFILE%\sycl_workspace
56+
mkdir %SYCL_HOME%
9957
```
10058

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
10760

108-
### Linux:
61+
**Linux**
10962
```bash
11063
cd $SYCL_HOME
11164
git clone https://github.com/intel/llvm -b sycl
@@ -117,62 +70,116 @@ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" \
11770
-DLLVM_ENABLE_PROJECTS="clang;llvm-spirv;sycl" \
11871
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME/llvm/sycl \
11972
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME/llvm/llvm-spirv \
120-
-DOpenCL_INCLUDE_DIR="$OPENCL_HEADERS" -DOpenCL_LIBRARY="$ICD_LIB" \
12173
$SYCL_HOME/llvm/llvm
12274

12375
make -j`nproc` sycl-toolchain
12476
```
125-
### Windows:
126-
```bash
127-
mkdir %SYCL_HOME%
77+
78+
**Windows**
79+
```bat
12880
cd %SYCL_HOME%
12981
git clone https://github.com/intel/llvm -b sycl
13082
mkdir %SYCL_HOME%\build
13183
cd %SYCL_HOME%\build
13284
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"
13494
13595
ninja sycl-toolchain
13696
```
13797

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.
14299

143-
## Build the SYCL runtime with libc++ library.
100+
## Build SYCL toolchain with libc++ library
144101

145102
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
147104
should be used.
148-
### Linux:
105+
106+
**Linux**
149107
```
150108
-DSYCL_USE_LIBCXX=ON \
151109
-DSYCL_LIBCXX_INCLUDE_PATH=<path to libc++ headers> \
152110
-DSYCL_LIBCXX_LIBRARY_PATH=<path to libc++ and libc++abi libraries>
153111
```
154-
# Test the SYCL compiler and runtime
155112

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&reg; Graphics Compute Runtime for
125+
OpenCL&trade;](https://github.com/intel/compute-runtime/releases)
126+
* Intel CPU - [Experimental Intel&reg; 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&reg; Download
132+
Center](https://downloadcenter.intel.com/product/80939/Graphics-Drivers)
133+
134+
* The experimental Intel&reg; 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**
158147
```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
164149
```
165-
### Windows:
166-
```bash
150+
151+
**Windows**
152+
```bat
167153
ninja check-all
168-
ninja check-llvm
169-
ninja check-llvm-spirv
170-
ninja check-clang
171-
ninja check-sycl
172154
```
173-
If no OpenCL GPU/CPU runtimes are available, the corresponding LIT tests are skipped
174155

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
176183

177184
A simple SYCL program consists of following parts:
178185
1. Header section
@@ -234,43 +241,43 @@ int main() {
234241

235242
```
236243

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%\build\bin;%PATH%
248-
set LIB=%SYCL_HOME%\build\lib;%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:
255245

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+
```
260263

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.
266267

268+
**Linux & Windows**
269+
```bash
270+
./simple-sycl-app.exe
271+
The results are correct!
272+
```
267273

268274
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
270277
explained in following section [Code the program for a specific
271278
GPU](#code-the-program-for-a-specific-gpu).
272279

273-
# Code the program for a specific GPU
280+
## Code the program for a specific GPU
274281

275282
To specify OpenCL device SYCL provides the abstract `cl::sycl::device_selector`
276283
class which the can be used to define how the runtime should select the best
@@ -299,7 +306,7 @@ int main() {
299306
const std::string DeviceName = Device.get_info<device::name>();
300307
const std::string DeviceVendor = Device.get_info<device::vendor>();
301308

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);
303310
}
304311
};
305312

@@ -317,7 +324,7 @@ int main() {
317324
# C++ standard
318325
- Minimally support C++ standard is c++11 on Linux and c++14 on Windows.
319326

320-
# Known Issues or Limitations
327+
# Known Issues and Limitations
321328

322329
- SYCL device compiler fails if the same kernel was used in different
323330
translation units.

0 commit comments

Comments
 (0)