For this first exercise you simply need to install a SYCL implementation and the SYCL Academy dependencies and then verify your installation by comping a source file for SYCL.
To install a SYCL implementation, follow the instructions in the README.md of the SYCL Academy repository.
Depending on the SYCL implementation used, the steps to verify your environment might vary.
With AdaptiveCpp, you can skip this step. If you suspect later that your environment might not be set up correctly, you can run acpp-info -l
in the bin
directory of your AdaptiveCpp installation. It will then print the backends and devices that it sees, for example:
$ acpp-info -l
=================Backend information===================
Loaded backend 0: OpenCL
Found device: Intel(R) UHD Graphics 620 [0x5917]
Found device: ComputeAorta x86_64
Found device: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Loaded backend 1: OpenMP
Found device: hipSYCL OpenMP host device
Loaded backend 2: CUDA
Found device: NVIDIA GeForce MX150
Loaded backend 3: Level Zero
Found device: Intel(R) UHD Graphics 620 [0x5917]
If you have not already installed SYCLAcademy, follow this guide to perform the installation.
Go to the Compiling_with_SYCL directory: From the syclacademy directory
cd build/Code_Exercises/Compiling_with_SYCL
and continue to 4
Once you have confirmed your environment is setup and available you are ready to compile your first SYCL application from source code.
First fetch the tutorial samples from GitHub.
Clone this repository ensuring that you include sub-modules.
git clone --recursive https://github.com/codeplaysoftware/syclacademy.git
mkdir build
cd build
Then open the source file for this exercise and include the SYCL header file
"sycl/sycl.hpp"
.
Make sure before you do this you define SYCL_LANGUAGE_VERSION
to 2020
, to
enable support for the SYCL 2020 interface.
Once that is done build your source file with your chosen build system.
Once you've done that simply build the exercise with your chosen build system and invoke the executable.
If you are using DevCloud via SSH:
If you haven't done so already, follow this guide to build the exercise directory structure.
From the syclacademy directory
cd build/Code_Exercises/Compiling_with_SYCL
and execute:
* ```make Compiling_with_SYCL_source``` - to build source.cpp
* ```make Compiling_with_SYCL_solution``` - to build the solution provided
* ```make``` - to build both
In Intel DevCloud, to run computational applications, you will submit jobs to a queue for execution on compute nodes,
especially some features like longer walltime and multi-node computation is only available through the job queue.
Please refer to the [guide][devcloud-job-submission].
So wrap the binary into a script `job_submission`
#!/bin/bash ./Compiling_with_SYCL_source
and run:
```sh
qsub -l nodes=1:gpu:ppn=2 -d . job_submission
The stdout will be stored in job_submission.o<job id>
and stderr in job_submission.e<job id>
.
Using CMake to configure then build the exercise:
mkdir build
cd build
cmake .. "-GUnix Makefiles" -DSYCL_ACADEMY_USE_DPCPP=ON
-DSYCL_ACADEMY_ENABLE_SOLUTIONS=OFF -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
make Compiling_with_SYCL_source
Alternatively from a terminal at the command line:
icpx -fsycl -o Compiling_with_SYCL_source -I../External/Catch2/single_include ../Code_Exercises/Compiling_with_SYCL/source.cpp
./Compiling_with_SYCL_source
For AdaptiveCpp:
# <target specification> is a list of backends and devices to target, for example
# "omp;generic" compiles for CPUs with the OpenMP backend and GPUs using the generic single-pass compiler.
# The simplest target specification is "omp" which compiles for CPUs using the OpenMP backend.
cmake -DSYCL_ACADEMY_USE_ADAPTIVECPP=ON -DSYCL_ACADEMY_INSTALL_ROOT=/insert/path/to/AdaptiveCpp -DACPP_TARGETS="<target specification>" ..
make Compiling_with_SYCL_source
alternatively, without CMake:
cd Code_Exercises/Compiling_with_SYCL
/path/to/AdaptiveCpp/bin/acpp -o Compiling_with_SYCL_source -I../../External/Catch2/single_include --acpp-targets="<target specification>" source.cpp
./Compiling_with_SYCL_source