SpECTRE  v2025.08.19
GPU support

Table of Contents

Overview

Warning
GPU support is experimental and this page will be updated as the implementation matures.

SpECTRE supports GPU acceleration through the Kokkos library.

Build configuration

To enable GPU support, set the CMake option -D SPECTRE_KOKKOS=ON when configuring the build. Either point CMake to a Kokkos installation with -D Kokkos_ROOT=path/to/kokkos or set -D SPECTRE_FETCH_MISSING_DEPS=ON to fetch Kokkos automatically and build it as part of SpECTRE. You also have to select a parallelization backend for Kokkos and possibly more configuration options like the GPU architecture to build for. Read the Kokkos documentation for details on how to configure Kokkos. Here's an example for fetching Kokkos automatically and building it as part of SpECTRE with the CUDA backend:

cmake -D SPECTRE_KOKKOS=ON \
-D SPECTRE_FETCH_MISSING_DEPS=ON \
-D Kokkos_ENABLE_CUDA=ON \
...

Here's an example for using an existing Kokkos installation:

cmake -D SPECTRE_KOKKOS=ON \
-D Kokkos_ROOT=path/to/kokkos/build \
-D CMAKE_CXX_COMPILER=path/to/kokkos/bin/nvcc_wrapper \
...

When building Kokkos separately with the CUDA backend, you have to set the following configuration options:

  • Kokkos_ENABLE_CUDA_CONSTEXPR=ON
  • Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE