Building the Library¶
This page outlines the process of building the dtFFT library using CMake, including compiler requirements, configuration options, and integration instructions for downstream projects.
The library supports both host and GPU environments, leveraging modern Fortran and optional dependencies like CUDA, FFTW3, MKL, cuFFT, and VkFFT.
Prerequisites¶
Since dtFFT is primarily written in Fortran, a modern Fortran compiler (2008 standard or later) is required. The library has been successfully tested with:
GNU Fortran (gfortran): Version 12 and above
Intel Fortran (ifort / ifx): Version 18 and above
NVHPC Fortran (nvfortran): Version 24.5 and above
Currently, dtFFT can only be built using CMake (version 3.20 or higher recommended). Ensure CMake is installed and available in your PATH before proceeding.
Requirements:
CMake: Version 3.20 or higher
Modern Fortran compiler: 2008 standard or later
MPI: Message Passing Interface (MPI) implementation
Caliper (optional): For performance profiling and analysis
For CUDA support:
CUDA-aware MPI: Required for GPU acceleration
NCCL (optional): NVIDIA Collective Communications Library (automatically linked if
nvfortranis used)nvfortran (optional): NVHPC Fortran compiler (enables additional features like NCCL and cuFFTMp)
NVTX3 (optional): NVIDIA Tools Extension for profiling and debugging
Configuration Options¶
The build process is controlled via CMake options, listed below. These options enable or disable features such as GPU support, FFT library integration, and additional utilities.
Set them using -D<OPTION>=<VALUE> during CMake configuration.
Option |
Possible Values |
Default |
Description |
|---|---|---|---|
|
|
|
Enables CUDA support. Requires |
|
|
|
Enables FFTW3 support. Requires the |
|
|
|
Enables MKL DFTI support. Requires the |
|
|
|
Enables cuFFT support. Automatically sets |
|
|
|
Enables VkFFT support. Requires the |
|
|
|
Builds the library’s test suite. |
|
|
|
Enables code coverage analysis (gfortran only). |
|
|
|
Builds a shared library instead of a static one. |
|
|
|
Uses the Fortran |
|
|
|
Builds the C and C++ APIs alongside the Fortran API. |
|
|
|
Enables persistent MPI communications for multiple plan executions.
Communications are initialized on the first call to |
|
|
|
Enables profiling. Uses NVTX3 with CUDA support or Caliper otherwise (requires |
|
|
|
Requires the |
|
|
|
Disables use of NCCL shipped with HPC-SDK. NCCL Backends will be unavailable |
|
|
|
Disables use of NVSHMEM-based backends shipped with HPC-SDK. |
|
|
|
Enable error checking for all GPU libraries calls |
Building the Library¶
Configure the Build: Run CMake to generate build files, specifying the installation prefix and desired options. For example:
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install -DDTFFT_WITH_CUDA=ON -DDTFFT_WITH_CUFFT=ON
Replace /path/to/install with your target installation directory.
Note
CUDA support in dtFFT does not replace the host version but extends it. For more details, refer to the guide
here and the environment variable DTFFT_PLATFORM.
Build the Library: Compile the library using:
cmake --build build --target install
This compiles and installs dtFFT to the specified prefix.
Integration with CMake Projects¶
Once installed, dtFFT can be integrated into other CMake projects using find_package. Example configuration:
find_package(dtfft REQUIRED)
add_executable(my_prog my_prog.c)
target_link_libraries(my_prog PRIVATE dtfft)
The dtfft target automatically sets include directories and links required libraries. Specify the installation path when configuring your project:
cmake -S . -B build -Ddtfft_DIR=/path/to/install/lib[64]/cmake/dtfft ..
The installation also provides the following CMake variables for conditional compilation:
DTFFT_WITH_CUDA: Indicates CUDA supportDTFFT_WITH_C_CXX_API: Indicates C/C++ API availabilityDTFFT_WITH_MPI_MODULE: Indicates use of thempimodule