Skip to content

Intel MKL FFTW wrappers

imkl-FFTW provides FFTW2 and FFTW3 compatible interfaces backed by Intel MKL's FFT engine. Code written for FFTW can use MKL's optimized implementation without source changes; just relink.

Loading the module

module load imkl-FFTW/2023.1.0-iimpi-2023a

To see all installed versions across clusters, check the software catalog or run module spider imkl-FFTW.

Compiling

Since this module provides FFTW3-compatible headers and MKL-backed libraries, compile exactly as you would for FFTW:

# Using Intel compiler (recommended)
icc -o fft_example fft_example.c -qmkl

# Using GCC
gcc -o fft_example fft_example.c -I${MKLROOT}/include/fftw -lfftw3xc_intel -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lm

The FFTW3 headers (fftw3.h) are provided by the module. Existing code using #include <fftw3.h> and linking -lfftw3 should work without modification.

Example: complex 1D transform using FFTW3 API
#include <fftw3.h>
#include <stdio.h>

int main() {
    int N = 8;
    fftw_complex *in  = fftw_malloc(sizeof(fftw_complex) * N);
    fftw_complex *out = fftw_malloc(sizeof(fftw_complex) * N);

    for (int i = 0; i < N; i++) {
        in[i][0] = i;     /* real */
        in[i][1] = 0.0;   /* imaginary */
    }

    fftw_plan plan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
    fftw_execute(plan);

    printf("Results of FFT:\n");
    for (int i = 0; i < N; i++)
        printf("  out[%d] = (%f, %f)\n", i, out[i][0], out[i][1]);

    fftw_destroy_plan(plan);
    fftw_free(in);
    fftw_free(out);
    return 0;
}

When to use imkl-FFTW vs plain FFTW

Use imkl-FFTW when you are already on an Intel toolchain and want MKL-optimized FFT without changing your FFTW3 source code. Use plain FFTW with GCC/foss toolchains.

Batch job example

mkl_fftw.slurm
#!/bin/bash
#SBATCH --qos=regular
#SBATCH --job-name=mkl_fftw
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=4G
#SBATCH --time=00:30:00
#SBATCH --output=%x.%j.out
#SBATCH --error=%x.%j.err

module load imkl-FFTW/2023.1.0-iimpi-2023a

./fft_example

See also