Introduction to CUDA¶
Overview¶
Hardly any system today runs without GPU acceleration, so knowing how to program GPUs is essential. Only the native programming model — CUDA for NVIDIA GPUs — gives access to every feature of the hardware and lets you make full use of it. The fundamentals are not limited to NVIDIA GPUs: they also apply to other GPUs and transfer easily.
CUDA, as native programming model of NVIDIA GPUs, allows very fine-grained control over parallel execution compared to higher level programming models such as OpenMP offloading, which helps to optimise performance. In some sense a GPU works like a bee colony: many more or less independent individuals work together to achieve a common goal. In a GPU the individuals are single threads. Each thread has a unique name, and the programmer uses that name to tell each thread what to do. Since many threads typically do similar jobs, the CUDA programming model uses a set of instructions, called a kernel, which many threads execute; the thread’s name is used in some places and makes small differences for each thread. The module provides an introduction to the programming language CUDA which is used to write fast numeric algorithms for NVIDIA GPUs. Focus is on the basic usage of the language, error handling and understanding kernel functions.
After a short software-setup episode, the module has two lesson episodes — the CUDA programming model (kernels, the execution configuration, the thread hierarchy and the grid-stride loop) and the rules for kernels and device functions together with error handling — and closes with a knowledge-check quiz. All code is shown in C/C++ and CUDA Fortran side by side, and each lesson episode ends with a hands-on exercise that you download, complete and compile yourself.
Prerequisites
Programming experience in C, C++ or Fortran
The ability to edit and compile a program on the machine that has the GPU — from a Linux shell (for example this tutorial) or from an IDE that can call
nvcc/nvfortran: the exercises are downloaded, edited and compiled by youAccess to an NVIDIA GPU with CUDA Toolkit 12.x or newer installed (12.x if the GPU has compute capability 7.0, see the software-setup episode), either on your own machine or on a cluster, to compile and run the exercises
Knowledge of parallel programming is beneficial but not required
No prior experience with CUDA or GPU programming is assumed
This module is aimed at researchers, engineers and students who can already write sequential programs in C, C++ or Fortran and want to start programming NVIDIA GPUs. Basic familiarity with an editor or IDE, and with the Linux shell when working on a cluster, is needed for the exercises. Prior knowledge of parallel programming is helpful but not required.
Software setup
Learning outcomes¶
After completing this module, learners will be able to:
Explain the accelerator programming model and identify which parts of a program run on the CPU vs the GPU
Write a CUDA kernel using the
__global__specifier and launch it from host code using the triple-chevron syntax in C/C++ and the equivalent syntax in CUDA Fortran (<<<...>>>)Map thread and block indices to data elements using the built-in
threadIdx/blockIdx/blockDim/gridDimvariables, and apply the grid-stride loop pattern to handle arbitrary data sizesApply the function execution space specifiers (
__global__,__device__,__host__ __device__) correctly and respect the restrictions that apply to device codeDetect and handle CUDA errors using error-checking macros, and understand the asynchronous nature of kernel-launch error reporting
Estimated commitment: about 2 hours (115 minutes of lecture and exercises; provisional estimate, to be re-measured at the first delivery).
EVITA skill tree: SD1.2.6 GPU Programming with CUDA — the module covers the skill SD1.2.6.2.1 CUDA Programming Model and Kernels (to be defined in the skill tree). In the EVITA Common Qualification Framework it is module PP.HS7-SD1.2.6.2.1 of course PP.HS7 Programming GPUs with CUDA.
Related topics not covered here:
Memory management (managed, manual, pinned and constant memory) — covered in the next module, CUDA Memory Management
Streams and concurrency
Shared memory
Profiling
See also¶
Credit
This module is based on the CUDA course developed at HLRS, the High-Performance Computing Center Stuttgart (University of Stuttgart). Authors: Tobias Haas and Jasper Seehofer, HLRS.
If you want to reuse the material beyond the terms of the licence below, or if you find errors, please contact the authors through the module repository.
Related EVITA module: CUDA Memory Management
License
CC BY-SA for media and pedagogical material
Copyright © 2026, EVITA project, Tobias Haas, Jasper Seehofer. This material is released by EVITA project, Tobias Haas, Jasper Seehofer under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0).
Canonical URL: https://creativecommons.org/licenses/by-sa/4.0/
You are free to
Share — copy and redistribute the material in any medium or format for any purpose, even commercially.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms
Attribution — You must give appropriate credit , 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.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices
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.
This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.
MIT for source code and code snippets
MIT License
Copyright (c) 2026, EVITA project, Tobias Haas, Jasper Seehofer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.