• Stars
    star
    454
  • Rank 96,373 (Top 2 %)
  • Language
    HTML
  • License
    Creative Commons ...
  • Created about 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SYCL Academy, a set of learning materials for SYCL heterogeneous programming

SYCL Academy

SYCL Academy SYCL Academy

This repository provides materials that can be used for teaching SYCL. The materials are provided using the "Creative Commons Attribution Share Alike 4.0 International" license.

What is SYCL?

If you're not familiar with SYCL or would like some further resources for learning about SYCL below are a list of useful resources:

How to use the Materials

To use these materials simply clone this repository including the required submodules.

git clone --recursive https://github.com/codeplaysoftware/syclacademy.git

The lectures are written in reveal.js, and can be found in Lesson_Materials, in the sub-directory for each topic. To view them simply open the index.html file in your browser. Your browser will have a "Full Screen" mode that can be used to run the presentation, use the right and left cursors to move forward and backward in the presentation.

The exercises can be found in Code_Exercises in the sub-directory for each topic. Each exercise has a markdown document instructing what to do in the exercise, a source file to start with and a solution file to provide an example implementation to compare against.

Contributing to SYCL Academy

Contributions to the materials are very gratefully received and this can be done by submitting a Pull Request with any changes. If you can, follow the instructions here to generate a pdf file for any lecture slides you change. Please limit the scope of each Pull Request so that they can be reviewed and merged in a timely manner.

List of Contributors

Codeplay Software Ltd., Heidelberg University, Intel, Xilinx and University of Bristol.

Supporting Organizations

Abertay University, Universidad de Concepcion, TU Dresden, University of Edinburgh, Federal University of Sao Carlos, University of Glasgow, Heriot Watt University, Universitat Innsbruck, Universidad de Mรกlaga, University of Salerno and University of the West of Scotland.

Lesson Curriculum

The SYCL Academy curriculum is divided up into a number of short lessons consisting of slides for presenting the material and a more detailed write-up, each accompanied by a tutorial for getting hands on experience with the subject matter.

Each of the lessons are designed to be self contained modules in order to support both academic and training style teaching environments.

A playlist of video content is also available. Though note that these slides and exercises may have changed since these videos were created so they may not match completely.

Lesson Title Slides Exercise Source Solution ComputeCpp DPC++ hipSYCL
01 What is SYCL slides exercise source solution Yes Yes Yes
02 Enqueueing a Kernel slides exercise source solution Yes Yes Yes
03 Managing Data slides exercise source solution Yes Yes Yes
04 Handling Errors slides exercise source solution Yes Yes Yes
05 Device Discovery slides exercise source solution Yes Yes Yes
06 Data Parallelism slides exercise source solution Yes Yes Yes
07 Introduction to USM slides exercise source solution Yes Yes Yes
08 Using USM slides exercise source solution Yes Yes Yes
09 Asynchronous Execution slides exercise source solution Yes Yes Yes
10 Data and Dependencies slides exercise source solution Yes Yes Yes
11 In Order Queue slides exercise source solution Yes Yes Yes
12 Advanced Data Flow slides exercise source solution Yes Yes Yes
13 Multiple Devices slides exercise source solution Yes Yes Yes
14 ND Range Kernels slides exercise source solution Yes Yes Yes
15 Image Convolution slides exercise solution Yes Yes Yes
16 Coalesced Global Memory slides exercise source solution Yes Yes Yes
17 Vectorization slides exercise source solution Yes Yes Yes
18 Local Memory Tiling slides exercise source solution Yes Yes Yes
19 Further Optimisations slides exercise source solution Yes Yes Yes

Building the Exercises

The exercises can be built for ComputeCpp CE (minimum v2.6.0), DPC++ and hipSYCL.

Supported Platforms

Below is a list of the supported platforms and devices for each SYCL implementations, please check this before deciding which SYCL implementation to use. Make sure to also install the specified version to ensure that you can build all of the exercises.

Implementation Supported Platforms Supported Devices Required Version
ComputeCpp Windows 10 Visual Studio 2019 (64bit)*
Ubtuntu 18.04 (64bit)
Intel CPU (OpenCL)
Intel GPU (OpenCL)
CE 2.7.0
DPC++ Intel DevCloud
Windows 10 Visual Studio 2019 (64bit)
Red Hat Enterprise Linux 8, CentOS 8
Ubtuntu 18.04 LTS, 20.04 LTS (64bit)
Refer to System Requirements for more details
Intel CPU (OpenCL)
Intel GPU (OpenCL)
Intel FPGA (OpenCL)
Nvidia GPU (CUDA)**
2021.4
hipSYCL Any Linux CPU (OpenMP)
AMD GPU (ROCm)***
Nvidia GPU (CUDA)
Latest develop branch

* See here for troubleshooting when using ComputeCpp with Visual Studio post toolset version 14.26.

** Supported in open source project only

*** See here for the official list of GPUs supported by AMD for ROCm. We do not recommend using GPUs earlier than gfx9 (Vega 10 and Vega 20 chips).

Install SYCL implementations

First you'll need to install your chosen SYCL implementation and any dependencies they require.

Installing ComputeCpp

To set up ComputeCpp download the ComputeCpp CE package and follow the getting started instructions.

Installing DPC++

To set up DPC++ follow the getting started instructions.

You can also use a Docker* image.

If you are using the Intel DevCloud then the latest version of DPC++ will already be installed and available in the path.

Installing hipSYCL

You will need a hipSYCL build from September 2021 or newer. Refer to the hipSYCL installation instructions for details on how to install hipSYCL.

Pre-requisites

Before building the exercises you'll need:

  • One of the platforms in the support matrix above, depending on which SYCL implementation you are wishing to build for.
  • A C++17 or above tool-chain.
  • An appropriate build system for the platform you are targeting (CMake, Ninja, Make, Visual Studio).

Configuring using CMake (ComputeCpp CE and hipSYCL only)

Clone this repository, there are some additional dependencies configured as git sub-modules so make sure to clone those as well. Then simply invoke CMake as follows:

mkdir build

cd build

cmake ../ -G<cmake_generator> -A<cmake_arch> -D<sycl_implementation>=ON

For <cmake_generator> / <cmake_arch> we recommend:

  • Visual Studio 16 2019 / x64 (Windows)
  • Ninja / NA (Windows or Linux)
  • Make / NA (Linux)

For sycl_implementation this can be one of:

  • SYCL_ACADEMY_USE_COMPUTECPP
  • SYCL_ACADEMY_USE_HIPSYCL

You can also specify the additional optional options:

-DSYCL_ACADEMY_INSTALL_ROOT=<path_to_sycl_impl_install_root>

For <path_to_sycl_impl_install_root> we recommend you specify the path to the root directory of your SYCL implementation installation, though this may not always be required.

-DSYCL_ACADEMY_ENABLE_SOLUTIONS=ON

This will enable building the solutions for each exercise as well as the source files. This is disabled by default.

Additional cmake arguments for hipSYCL

When building with hipSYCL, cmake will additionally require you to specify the target platform using -DHIPSYCL_TARGETS=<target specification>. <target specification> is a list of backends and devices to target, for example -DHIPSYCL_TARGETS="omp;hip:gfx900,gfx906" compiles for CPUs with the OpenMP backend and for AMD Vega 10 and Vega 20 GPUs using the HIP backend. Available backends are:

  • omp - OpenMP CPU backend
  • cuda - CUDA backend for NVIDIA GPUs. Requires specification of targets of the form sm_XY, e.g. sm_70 for Volta, sm_60 for Pascal
  • hip - HIP backend for AMD GPUs. Requires specification of targets of the form gfxXYZ, e.g. gfx906 for Vega 20, gfx900 for Vega 10
  • spirv - use clang SYCL driver to generate spirv (experimental)

Compiling directly (DPC++ only)

If you are using DPC++ there is no CMake integration, but it is very simple to use the DPC++ compiler directly.

First you have to ensure that your environment is configured to use DPC++ (note if you are using the Intel DevCloud then you don't need to do this step).

On Linux simply call the setvars.sh which is available in /opt/intel/oneapi for sudo or root users and ~/intel/oneapi/ when installed as a normal user.

For root or sudo installations: source /opt/intel/oneapi/setvars.sh

For normal user installations: source ~/intel/oneapi/setvars.sh

On Windows the script is located in <dpc++_install_root>\setvars.bat

Where <dpc++_install_root> is wherever the oneAPI directory is installed.

Once that's done you can invoke the DPC++ compiler as follows:

icpx -fsycl -I<syclacademy_root>/External/Catch2/single_include -o a.out source.cpp

Where <syclacademy_root> is the path to the root directory of where you cloned this repository. Note that on Windows you need to add the option /EHsc to avoid exception handling error.

Troubleshooting for ComputeCpp on Windows

If you are using ComputeCpp with a more recent version of Visual Sutdio 2019 which has a toolset version greater than 14.26 you may encounter compilation errors in the C++ STL it's likely due to an unsupported version of the Visual Studio toolset, if you encounter this the solution is to configure the project to use an earlier troolset version, you can use the following steps to do this.

  • As a pre-requisite, open the Visual Studio 2019 Installer, select "Modify" and then open the "Individual components" tab and check the following components:
    • MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.26)
    • C++/CLI support for v142 build tools (14.26)
  • First we recommend opening the root directory of the SYCL Academy repository in Visual Studio 2019 and configuring CMake this way rather than running CMake on the command line as this makes configurating the toolset version easier.
  • Ensure that you are building in Release mode.
  • Next, add the following option to the CMake configuration:
    • -DCOMPUTECPP_DEVICE_COMPILER_FLAGS=-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
  • Open CMakeSettings.json in the root directory and add the following:
  "environments": [
    {
      "VCToolsVersion" :  "14.26"
    }
  ],

Working on the Exercises

Once you have a working SYCL compiler, you are ready to start writing some SYCL code. To find the first exercise:

cd Code_Exercises/Exercise_01_Compiling_with_SYCL/

And read the README.md for further instructions.

Each exercise directory contains:

  • README.md, which contains instructions of how to complete a given exercise, as well as directions for compilation.
  • source.cpp, a placeholder file where your code implementation should be written.
  • solution.cpp, where a solution has been implemented in advance.

Once you have completed any given exercise make sure to compare your implementation against the corresponding solution.cpp.

Online Interactive Tutorial

Hosted by tech.io, this SYCL Introduction tutorial introduces the concepts of SYCL. The website also provides the ability to compile and execute SYCL code from your web browser.

SYCL and the SYCL logo are trademarks of the Khronos Group Inc.

More Repositories

1

computecpp-sdk

Collection of samples and utilities for using ComputeCpp, Codeplay's SYCL implementation
C
322
star
2

portBLAS

An implementation of BLAS using the SYCL open standard.
C++
256
star
3

visioncpp

A machine vision library written in SYCL and C++ that shows performance-portable implementation of graph algorithms
C++
156
star
4

portDNN

portDNN is a library implementing neural network algorithms written using SYCL
C++
108
star
5

oneapi-construction-kit

C++
68
star
6

SYCL-ML

SYCL-ML is a C++ library, implementing classical machine learning algorithms using SYCL.
C++
61
star
7

SYCL-For-CUDA-Examples

Examples for using SYCL on CUDA
Shell
52
star
8

llvm-leg

Codeplay's tutorial LLVM LEG backend - as presented at the 2014 LLVM Developers' Meeting in San Jose.
C++
37
star
9

LPGPU2-CodeXL

LPGPU2 CodeXL power performance analysis and feedback tool for GPUs
C++
35
star
10

sycl-for-cuda

Codeplay project for contributions to the LLVM SYCL implementation
C++
30
star
11

standards-proposals

Repository for publicly sharing proposals in various standards groups
C++
27
star
12

portFFT

portFFT is a library implementing Fast Fourier Transforms using SYCL
C++
14
star
13

sycl-info

Tool to show information about available SYCL implementations
C++
11
star
14

cuda-to-sycl-nbody

C++
11
star
15

lldb-msp430

Codeplay's tutorial LLDB-MSP430 - as presented at the 2016 EuroLLVM Developers' Meeting in Barcelona.
C++
10
star
16

parallelts-range-exploration

Repository to exchange current work with rangesTS and Parallel STL
C++
8
star
17

SYCL-samples

A collection of samples written using the SYCL standard for C++.
C++
8
star
18

blog-ray

SYCL enabled ray tracer
C++
6
star
19

sycl-project-list

SYCL Open Source Projects List
4
star
20

sycl.tech-website

Angular front-end for the SYCL.tech website.
TypeScript
3
star
21

sycl.tech-content

Content for the SYCL.tech Website
Python
3
star
22

CUDA_to_SYCL_examples

Example code for the guide
C++
3
star
23

py_gen

Python library for generating C++ code
Python
3
star
24

sycl-crowd-simulation

A crowd simulation algorithm implemented using C++ and SYCL.
Python
3
star
25

mlir-sycl

C++
3
star
26

syclops-website

SYCLOPS Research Project Website
HTML
2
star
27

TensorOpt

C++
2
star
28

SYCLcompat

1
star
29

clang-leg

Codeplay's tutorial Clang LEG changes - as presented at the 2014 LLVM Developers' Meeting in San Jose.
C++
1
star
30

onnxruntime

Codeplay's fork of the onnxruntime open source project adding a SYCL backend providing DNN model support across various SYCL-enabled hardware targets.
C++
1
star
31

computecpp-cmake-template

CMake
1
star
32

Template-Repo

Makefile
1
star