Skip to content

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

License

Notifications You must be signed in to change notification settings

blasvicco/syclacademy

 
 

SYCL Academy

SYCL Academy

This repository provides materials that can be used for teaching SYCL 1.2.1. 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:

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

Supporting Organizations

Abertay University, Heriot Watt University, University of Edinburgh, TU Dresden, University of the West of Scotland, Universitat Innsbruck, Universidad de Concepcion and University of Salerno.

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.

Lesson Title Slides Exercise Source Solution ComputeCpp DPC++ hipSYCL
1 Introduction to SYCL slides exercise NA NA Yes Yes Yes
2 SYCL Topology Discover & Queue Creation slides exercise source solution Yes Yes Yes
3 SYCL Kernel Functions slides exercise source solution Yes Yes Yes
4 Managing Data in SYCL slides exercise source solution Yes Yes Yes
5 Image Grayscale (Optional) NA exercise source solution Yes Yes Yes
6 Matrix Transpose (Optional) NA exercise source solution Yes Yes Yes
7 Unified Shared Memory Extension (Optional) NA exercise source solution Yes Yes No

How to use the Materials

To use these materials simply clone this repository.

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.

Building the Exercises

The exercises can be built for ComputeCpp CE, DPC++ and hipSYCL.

Supported Platforms

Below is the supported platforms and devices for each SYCL implementations, see 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.0.0
DPC++ Intel DevCloud
Windows 10 Visual Studio 2019 (64bit)
Ubtuntu 18.04 (64bit)
Intel CPU (OpenCL)
Intel GPU (OpenCL)
Intel FPGA (OpenCL)
Nvidia GPU (CUDA)
2021.1-beta05
hipSYCL Any Linux CPU (OpenMP)
AMD GPU (ROCm)*
Nvidia GPU (CUDA)
Latest master

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

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 April 26th 2020 or newer. The easiest way to install a recent distribution of hipSYCL is to use the daily package repositories. Binary packages are provided for Ubuntu 18.04, CentOS 7 and Arch Linux. See here for an explanation of the packages that you need.

If you do not need the ROCm backend, a recent distribution can also be installed using the spack package manager:

spack install hipsycl@master +cuda

If you do not need the CUDA backend, you can remove +cuda.

Of course, you can also build hipSYCL from source manually.

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_PLATFORM=cpu|rocm|cuda and, when compiling for GPU, the target architecture using -DHIPSYCL_GPU_ARCH=arch.

  • For NVIDIA GPUs, arch is of the form sm_XX. For example, sm_60 for Pascal GPUs (GeForce GTX 1000 series).
  • When compiling for AMD GPUs, arch is of the form gfxXXX. For example, gfx900 for Vega 10 chips (Vega 56 and Vega 64) or gfx906 (Radeon VII).

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 when is available in /opt/intel/inteloneapi when installed as root or sudo and ~/intel/inteloneapi/ otherwise.

source /opt/intel/inteloneapi/setvars.sh

or

source ~/intel/inteloneapi/setvars.sh

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

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

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

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

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.

Setting up Computers for SYCL

Machine Setup Instructions

ComputeCpp, a SYCL v1.2.1 conformant implementation by Codeplay Software provides setup instructions on developer.codeplay.com. There is more detailed information about what hardware is supported by ComputeCpp on the Platform Support page.

Other SYCL implementations can be found on the SYCL community website sycl.tech.

Setting up a Docker Container for Lab Machines

In order to more easily deploy a SYCL implementation onto a bank of machines in a university lab for example, a Docker container can be used to deploy on these machines. This ensures all the dependencies that are needed are installed on each machine.

An example of how to set up a Docker container:

For Intel CPU or GPU

Now create a DockerFile that uses these packages, an example of how this might be done is below. Please note this file is not tested or maintained regularly but shows the elements that need to be installed.

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y ninja-build
RUN apt-get install -y g++
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN apt-get install -y software-properties-common

RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN apt-get update

RUN python3 -m pip install cmake

# install Intel OpenCL drivers from downloaded package
RUN tar -xvf l_opencl_p_18.1.0.015.tgz
RUN cd l_opencl_p_18.1.0.015
RUN chmod +x install.sh
RUN ./install.sh

# Download the Khronos OpenCL headers
RUN git clone https://github.com/KhronosGroup/OpenCL-Headers.git
RUN mv OpenCL-Headers/CL/ /opt/khronos/opencl/include

# Set up the ICD Loader
RUN mkdir -p /etc/OpenCL/vendors/ \
    && echo "$OCL_LIB/libintelocl.so" > /etc/OpenCL/vendors/intel.icd

# Create a directory for ComputeCpp
RUN mkdir /usr/local/computecpp
RUN cd /usr/local/computecpp

# Copy the ComputeCpp release package and extract it to /usr/local/computecpp
RUN cp Ubuntu-16.04-64bit.tar.gz . 
RUN tar -xvf Ubuntu-16.04-64bit.tar.gz

# Add the ComputeCpp location to the path on the machine
ENV PATH=OCL_INC:OCL_LIB:/usr/local/computecpp/bin:/usr/local/computecpp/include:/usr/local/computecpp/lib:${PATH}

ENV CC=gcc-8
ENV CXX=g++-8

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

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 33.8%
  • CSS 31.7%
  • HTML 28.3%
  • C++ 4.9%
  • CMake 1.3%