OpenACC/CUDA training for beginners

Prerequisites

Before attending this workshop, please make sure that you have access to an HPC cluster with Nvidia GPUs and the PGI compiler. Alternatively, you can use a cloud service like Google Colab which offers access to GPUs in the cloud. See the Setup section for further details.

Who is the course for?

This course is for students, researchers, engineers and programmers who would like to quickly get started with GPU programming using OpenACC and/or CUDA. Some previous experience with C/C++ or Fortran is required, and the lesson furthermore assumes that participants have some familiarity with the following topics:

  • Logging in to supercomputers and using a bash terminal

  • Compiling C/C++ or Fortran codes using compilers and makefiles

Tentative schedule

Day 1

9:00 - 9:10

Introduction to ENCCS

9:10 - 9:40

Introduction to accelerators

9:40 - 9:50

Break

9:50 - 10:20

Introduction to OpenACC

10:20 - 10:30

Break-out rooms

10:30 - 10:40

Break

10:40 - 11:10

Introduction to OpenACC (cont.)

11:10 - 11:40

Break-out rooms

11:40 - 12:00

Wrap-up of day 1

Day 2

9:00 - 9:10

Follow-ups from day 1

9:10 - 9:50

Introduction to CUDA

9:50 - 10:00

Break-out rooms

10:00 - 10:10

Break

10:10 - 10:35

Real-life example

10:35 - 10:50

Break-out rooms

10:50 - 11:00

Break

11:00 - 11:30

Improve the code

11:30 - 11:50

Break-out rooms

11:50 - 12:00

Wrap-up

About the course

This lesson is an introduction to GPU programming using the directive-based OpenACC paradigm and language-extension-based CUDA. The course consists of lectures, type-along and hands-on exercises. Topics covered include the architecture of the GPU accelerators, basic usage of OpenACC and CUDA, and how to control data movement between CPUs and GPUs. Basic optimization of the code will also be covered.

After the course the participants should have the basic skills needed for utilising OpenACC or CUDA with new or existing programs.

The participants are assumed to have knowledge of Fortran and/or C programming languages. Since participants will be using HPC clusters to run the examples, fluent operation in a Linux/Unix environment is assumed.

See also

There are many excellent resources online for learning OpenACC and CUDA. To name only few:

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.

Several examples and exercises in this lesson have been adapted from the following sources:

Instructional Material

This lesson material has been developed by Artem Zhmurov (ENCCS, PDC), Jing Gong (ENCCS) and others at ENCCS.

All ENCCS 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

  • to 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) ENCCS 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 by ENCCS are made available under the OSI-approved MIT license.