Building Kokkos-FFT
This section describes how to build Kokkos-FFT with some advanced options.
In order to build Kokkos-FFT, we use CMake with following compilers.
Kokkos and backend FFT libraries are also necessary.
Available CMake options for Kokkos-FFT are listed.
Compiler versions
Kokkos-FFT relies on quite basic functionalities of Kokkos, and thus it is supposed to work with compilers used for Kokkos. However, we have not tested all the listed compilers there and thus recommend the following compilers which we use frequently for testing.
gcc 10.4.0+- CPUsIntelLLVM 2024.2.1+- CPUs, Intel GPUsnvcc 12.2.0+- NVIDIA GPUsrocm 6.3.0+- AMD GPUs
Note
A compatible C++ compiler that supports at least C++20 is necessary.
Install Kokkos-FFT with CMake
Let’s assume Kokkos is installed under <path/to/kokkos> with OpenMP backend. We build and install Kokkos-FFT under <path/to/Kokkos-FFT>.
export KOKKOSFFT_INSTALL_PREFIX=<path/to/Kokkos-FFT>
cmake -B build_KokkosFFT \
-DCMAKE_CXX_COMPILER=<your c++ compiler> \
-DCMAKE_PREFIX_PATH=<path/to/kokkos> \
-DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX}
cmake --build build_KokkosFFT -j 8
cmake --install build_KokkosFFT
Here is an example to use Kokkos-FFT in the following CMake project.
---/
|
└──<project_directory>/
|--CMakeLists.txt
└──hello.cpp
The CMakeLists.txt would be
cmake_minimum_required(VERSION 3.23)
project(kokkos-fft-as-library LANGUAGES CXX)
find_package(Kokkos CONFIG REQUIRED)
find_package(KokkosFFT CONFIG REQUIRED)
add_executable(hello-kokkos-fft hello.cpp)
target_link_libraries(hello-kokkos-fft PUBLIC Kokkos::kokkos KokkosFFT::fft)
The code can be built as
cmake -B build \
-DCMAKE_CXX_COMPILER=<your c++ compiler> \
-DCMAKE_PREFIX_PATH="<path/to/kokkos>;<path/to/Kokkos-FFT>"
cmake --build build -j 8
Install Kokkos-FFT with Spack
Kokkos-FFT can also be installed with [spack](https://spack.io). For example, the recipe for H100 GPU with cufft is as follows:
git clone --depth=2 --branch=v1.1.0 https://github.com/spack/spack.git
source spack/share/spack/setup-env.sh # For bash
spack install kokkos-fft device_backend=cufft ^kokkos +cuda +wrapper cuda_arch=90
We have two main parameters to configure Spack:
host_backend: Enable device backend FFT library (fftw-serialorfftw-openmp)device_backend: Enable device backend FFT library (cufft,hipfft, oronemkl)
The code can be built as
spack load kokkos kokkos-fft
cmake -B build
cmake --build build -j 8
CMake options
We rely on CMake to build Kokkos-FFT, more specifically CMake 3.22+. Here is the list of CMake options.
For FFTs on Kokkos device only, we do not need to add extra compile options but for Kokkos ones.
In order to use Kokkos-FFT from both host and device, it is necessary to add KokkosFFT_ENABLE_FFTW=ON.
This option may be useful, for example FFT is used for initialization at host.
However, to enable this option, we need a pre-installed FFTW for FFT on host, so it is disabled in default
if one of the device backend is enabled.
(see minimum working example).
Description |
Default |
|
|---|---|---|
|
Build internal Kokkos instead of relying on external one. |
OFF |
|
Build Kokkos-FFT examples |
OFF |
|
Build Kokkos-FFT tests |
OFF |
|
Build benchmarks for Kokkos-FFT |
OFF |
|
Use FFTW for Host backend |
ON (if none of Kokkos devices is enabled, otherwise OFF) |
|
Use cufft for CUDA backend |
ON (if |
|
Use rocfft for HIP backend |
OFF |
|
Use hipfft for HIP backend |
ON (if |
|
Use oneMKL for SYCL backend |
ON (if |
Note
To enable Kokkos-FFT on both host and device, set KokkosFFT_ENABLE_FFTW=ON.
Multiple device tpls cannot be enabled at the same time. In addition, at least one tpl must be enabled to configure.
For example, it is allowed to set KokkosFFT_ENABLE_CUFFT=OFF even if Kokkos_ENABLE_CUDA=ON as long as KokkosFFT_ENABLE_FFTW=ON.
Kokkos backends
Kokkos-FFT requires Kokkos 4.7+. For the moment, we support following backends for CPUs and GPUs.
A FFT library dedicated to Kokkos Device backend (e.g. cufft for CUDA backend) is automatically used.
If CMake fails to find a backend FFT library, see How to find fft libraries?.
We may support experimental backends like OPENACC in the future.
CMake option |
Description |
Backend FFT library |
|---|---|---|
|
Serial backend targeting CPUs |
|
|
C++ threads backend targeting CPUs |
|
|
OpenMP backend targeting CPUs |
|
CMake option |
Description |
Backend FFT library |
|---|---|---|
|
CUDA backend targeting NVIDIA GPUs |
|
|
HIP backend targeting AMD GPUs |
|
|
SYCL backend targeting Intel GPUs |
|