SYCL

SYCL is a C++ abstraction layer for programming heterogeneous hardware with a single-source approach. SYCL is built on top of standard ISO C++17 and provides a high-level and cross-platform route for heterogeneous programming.

In this workshop, you will learn to:

  • Use the hipSYCL compiler to generate executable for multiple hardware targets.

  • Write hardware-agnostic code to express parallelism using the queue, command group, and kernel abstractions.

  • Use buffer and accessors to handle memory across devices.

  • Evaluate drawbacks and advantages of unified shared memory.

Prerequisites

Before attending this workshop, please make sure that you have access to a machine with the hipSYCL compiler (v0.9.1) and CMake (>=3.14) installed.

This workshop is organized in collaboration with CSC and IZUM. We will work on the exercises using the Vega supercomputer, a EuroHPC Joint Undertaking petascale system.

30 min

What is SYCL?

30 min

Device discovery

30 min

Queues, command groups, and kernels

30 min

Data management with buffers and accessors

30 min

Data management with unified shared memory

40 min

Expressing parallelism with SYCL

40 min

The task graph: data, dependencies, synchronization

20 min

Heat equation mini-app

40 min

Buffer-accessor model vs unified shared memory

Who is the course for?

This course is for students, researchers, engineers, and programmers that have heard of SYCL and want to learn how to use it effectively with projects they are working on. This course assumes no previous experience with SYCL, however, participants should have some prior experience with or knowledge of the following:

About the course

This lesson material is developed by the EuroCC National Competence Center Sweden (ENCCS), CSC, and IZUM. It is taught in ENCCS workshops. It is aimed at researchers and developers who are curious about SYCL and how it can help them leverage heterogeneous hardware effectively. This lesson targets SYCL 2020. Each lesson episode has clearly defined learning objectives and includes multiple exercises along with solutions, and is therefore also useful for self-learning. The lesson material is licensed under CC-BY-4.0 and can be reused in any form (with appropriate credit) in other courses and workshops. Instructors who wish to teach this lesson can refer to the Instructor’s guide for practical advice.

Graphical and text conventions

We adopt a few conventions which help organize the material.

Function signatures

These are shown in a text block marked with a wrench emoji:

The signature can be hidden by clicking the toggle.

Function arguments

The description of the function arguments will appear in a separate text box. It will be marked with a laptop emoji:

The description is hidden and will be shown by clicking the toggle.

Type-along

The text and code for these activities are in a separate text box, marked with a keyboard emoji:

The content can be hidden by clicking the toggle.

See also

Credits

The lesson file structure and browsing layout is inspired by and derived from work by CodeRefinery licensed under the MIT license. We have copied and adapted most of their license text.

Instructional Material

This instructional material is made available under the Creative Commons Attribution license (CC-BY-4.0). The following is a human-readable summary of (and not a substitute for) the full legal text of the CC-BY-4.0 license. You are free to:

  • share - copy and redistribute the material in any medium or format

  • adapt - remix, transform, and build upon the material for any purpose, even commercially.

The licensor cannot revoke these freedoms as long as you follow these license terms:

  • Attribution - You must give appropriate credit (mentioning that your work is derived from work that is Copyright (c) Roberto Di Remigio and individual contributors and, where practical, linking to https://enccs.se), provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

  • No additional restrictions - You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

With the understanding that:

  • You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.

  • No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

Software

Except where otherwise noted, the example programs and other software provided with this repository are made available under the OSI-approved MIT license.