Skip to content

Commit 41b10a0

Browse files
committed
Reformatted "Get started guide" to simplify the reading.
Signed-off-by: Alexey Bader <[email protected]>
1 parent 9b838d9 commit 41b10a0

File tree

1 file changed

+61
-24
lines changed

1 file changed

+61
-24
lines changed

sycl/doc/GetStartedWithSYCLCompiler.md

+61-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Overview
22

3-
The SYCL* Compiler compiles C++\-based SYCL source files with code for both CPU and a wide range of compute accelerators. The compiler uses Khronos* OpenCL&trade; API to offload computations to accelerators.
3+
The SYCL* Compiler compiles C++\-based SYCL source files with code for both CPU
4+
and a wide range of compute accelerators. The compiler uses Khronos*
5+
OpenCL&trade; API to offload computations to accelerators.
46

57
# Before You Begin
68

@@ -9,31 +11,48 @@ Software requirements:
911
Installing OpenCL 2.1 compatible software stack:
1012
1. OpenCL headers:
1113

12-
a. Download the OpenCL headers from [github.com/KhronosGroup/OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers) to your local machine. e.g. `/usr/local/include/CL` with environment var `$OPENCL_HEADERS`.
14+
a. Download the OpenCL headers from
15+
[github.com/KhronosGroup/OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers)
16+
to your local machine. e.g. `/usr/local/include/CL` with environment var
17+
`$OPENCL_HEADERS`.
1318
2. OpenCL runtime for CPU and GPU:
1419

15-
a. OpenCL runtime for GPU: follow instructions on [github.com/intel/compute-runtime/releases](https://github.com/intel/compute-runtime/releases) to install.
20+
a. OpenCL runtime for GPU: follow instructions on
21+
[github.com/intel/compute-runtime/releases](https://github.com/intel/compute-runtime/releases)
22+
to install.
1623

17-
b. OpenCL runtime for CPU: follow instructions under section "Intel&reg; CPU Runtime for OpenCL. Applications 18.1 for Linux* OS (64bit only)" on [https://software.intel.com/en-us/articles/opencl-drivers#cpu-section](https://software.intel.com/en-us/articles/opencl-drivers#cpu-section) and click on orange "Download" button to download & install.
24+
b. OpenCL runtime for CPU: follow instructions under section "Intel&reg; CPU
25+
Runtime for OpenCL. Applications 18.1 for Linux* OS (64bit only)" on
26+
[https://software.intel.com/en-us/articles/opencl-drivers#cpu-section](https://software.intel.com/en-us/articles/opencl-drivers#cpu-section)
27+
and click on orange "Download" button to download & install.
1828

1929
# Build the SYCL compiler
2030

21-
Download the LLVM* repository with SYCL support to your local machine folder e.g. `$HOME/sycl` (assuming environment var `$SYCL_HOME`) folder using following command:
31+
Download the LLVM* repository with SYCL support to your local machine folder
32+
e.g. `$HOME/sycl` (assuming environment var `$SYCL_HOME`) folder using
33+
following command:
2234

23-
```
35+
```bash
2436
git clone https://github.com/intel/llvm -b sycl $HOME/sycl
2537
```
2638

27-
Follow regular LLVM build instructions under: [llvm.org/docs/CMake.html](https://llvm.org/docs/CMake.html). To build SYCL runtime use modified CMake command below:
39+
Follow regular LLVM build instructions under:
40+
[llvm.org/docs/CMake.html](https://llvm.org/docs/CMake.html). To build SYCL
41+
runtime use modified CMake command below:
2842

29-
```
43+
```bash
3044
mkdir $SYCL_HOME/build
3145
cd $SYCL_HOME/build
32-
cmake -DCMAKE_BUILD_TYPE=Release -DOpenCL_INCLUDE_DIR=$OPENCL_HEADERS -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_EXTERNAL_PROJECTS="sycl;llvm-spirv" -DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME/sycl -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME/llvm-spirv -DLLVM_TOOL_SYCL_BUILD=ON -DLLVM_TOOL_LLVM_SPIRV_BUILD=ON $SYCL_HOME/llvm
46+
cmake -DCMAKE_BUILD_TYPE=Release -DOpenCL_INCLUDE_DIR=$OPENCL_HEADERS \
47+
-DLLVM_ENABLE_PROJECTS="clang" -DLLVM_EXTERNAL_PROJECTS="sycl;llvm-spirv" \
48+
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME/sycl \
49+
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME/llvm-spirv \
50+
-DLLVM_TOOL_SYCL_BUILD=ON -DLLVM_TOOL_LLVM_SPIRV_BUILD=ON $SYCL_HOME/llvm
3351
make -j`nproc` check-all
3452
```
3553

36-
After the build completed, the SYCL compiler/include/libraries can be found under `$SYCL_HOME/build` directory.
54+
After the build completed, the SYCL compiler/include/libraries can be found
55+
under `$SYCL_HOME/build` directory.
3756

3857
# Creating a simple SYCL program
3958

@@ -48,7 +67,7 @@ A simple SYCL program consists of following parts:
4867

4968
Creating a file `simple-sycl-app.cpp` with the following C++ SYCL code in it:
5069

51-
```
70+
```c++
5271

5372
#include <CL/sycl.hpp>
5473

@@ -103,15 +122,16 @@ The SYCL Compiler supports two types of compilation:
103122

104123
1. Simplified one step that compiles to binary directly
105124

106-
```
125+
```bash
107126
clang++ -std=c++11 -fsycl simple-sycl-app.cpp -o simple-sycl-app -lsycl -lOpenCL
108127
```
109128

110-
2. Manual two steps compilation that compiles device (to SPIR-V) and host code separately (to binary)
129+
2. Manual two steps compilation that compiles device (to SPIR-V) and host code
130+
separately (to binary)
111131

112132
a. Compile the device code from the C++ file into the SPIR-V file:
113133

114-
```
134+
```bash
115135
clang++ --sycl -Xclang -fsycl-int-header=simple-sycl-app-int-header.h -c simple-sycl-app.cpp -o kernel.spv
116136
# NOTE: The section "-Xclang -fsycl-int-header=simple-sycl-app-int-header.h"
117137
# generates `integration header` file.
@@ -121,30 +141,45 @@ The SYCL Compiler supports two types of compilation:
121141

122142
b. Compile host code from the same C++ file into an executable:
123143

124-
```
144+
```bash
125145
clang++ -std=c++11 -include simple-sycl-app-int-header.h simple-sycl-app.cpp -o simple-sycl-app -lsycl -lOpenCL
126146
# NOTE: The section "-include simple-sycl-app-int-header.h" includes
127147
# integration header file, which is produced by the device compiler.
128148
```
129149

130-
This `simple-sycl-app` application doesn't specify SYCL device for execution, so SYCL runtime will first try to execute on OpenCL GPU device first, if OpenCL GPU device is not found, it will try to run OpenCL CPU device; and if OpenCL CPU device is also not available, SYCL runtime will run on SYCL host device.
150+
This `simple-sycl-app` application doesn't specify SYCL device for execution,
151+
so SYCL runtime will first try to execute on OpenCL GPU device first, if OpenCL
152+
GPU device is not found, it will try to run OpenCL CPU device; and if OpenCL
153+
CPU device is also not available, SYCL runtime will run on SYCL host device.
131154

132155
To run the `simple-sycl-app`:
133156

134157
LD_LIBRARY_PATH=$SYCL_HOME/build/lib ./simple-sycl-app
135158
The results are correct!
136159

137-
NOTE: SYCL developer can specify SYCL device for execution using device selectors (e.g. `cl::sycl::cpu_selector`, `cl::sycl::gpu_selector`) as explained in following section [Code the program for a specific GPU](#code-the-program-for-a-specific-gpu).
160+
NOTE: SYCL developer can specify SYCL device for execution using device
161+
selectors (e.g. `cl::sycl::cpu_selector`, `cl::sycl::gpu_selector`) as
162+
explained in following section [Code the program for a specific
163+
GPU](#code-the-program-for-a-specific-gpu).
138164

139165
# Code the program for a specific GPU
140166

141-
To specify OpenCL device SYCL provides the abstract `cl::sycl::device_selector` class which the can be used to define how the runtime should select the best device.
167+
To specify OpenCL device SYCL provides the abstract `cl::sycl::device_selector`
168+
class which the can be used to define how the runtime should select the best
169+
device.
142170

143-
The method `cl::sycl::device_selector::operator()` of the SYCL `cl::sycl::device_selector` is an abstract member function which takes a reference to a SYCL device and returns an integer score. This abstract member function can be implemented in a derived class to provide a logic for selecting a SYCL device. SYCL runtime uses the device for with the highest score is returned. Such object can be passed to `cl::sycl::queue` and `cl::sycl::device` constructors.
171+
The method `cl::sycl::device_selector::operator()` of the SYCL
172+
`cl::sycl::device_selector` is an abstract member function which takes a
173+
reference to a SYCL device and returns an integer score. This abstract member
174+
function can be implemented in a derived class to provide a logic for selecting
175+
a SYCL device. SYCL runtime uses the device for with the highest score is
176+
returned. Such object can be passed to `cl::sycl::queue` and `cl::sycl::device`
177+
constructors.
144178

145-
The example below illustrates how to use `cl::sycl::device_selector` to create device and queue objects bound to Intel GPU device:
179+
The example below illustrates how to use `cl::sycl::device_selector` to create
180+
device and queue objects bound to Intel GPU device:
146181

147-
```
182+
```c++
148183
#include <CL/sycl.hpp>
149184

150185
int main() {
@@ -174,12 +209,14 @@ int main() {
174209

175210
# Known Issues or Limitations
176211

177-
- SYCL device compiler fails if the same kernel was used in different translation units.
212+
- SYCL device compiler fails if the same kernel was used in different
213+
translation units.
178214
- SYCL host device is not fully supported.
179215
- SYCL works only with OpenCL implementations supporting out-of-order queues.
180-
- `math.h` header is conflicting with SYCL headers. Please use `cmath` as a workaround for now like below:
216+
- `math.h` header is conflicting with SYCL headers. Please use `cmath` as a
217+
workaround for now like below:
181218

182-
```
219+
```c++
183220
//#include <math.h> // conflicting
184221
#include <cmath>
185222
```

0 commit comments

Comments
 (0)