Linking the MKL version of fftw3

Environment variables

To link a library, the compiler and linker need at minimum

name of and path to the include files

For fftw3, the include files have standard names, but are in a different place than the other MKL-related include files.

name of and path to the library:

The fftw3 library is merged the other MKL libraries. Hence, searching for the typical fftw3 - filenames gives a negative result. This may be of importance for cmake - or configure -scripts trying to explore the system to generate the appropriate compiler- und linker options.

The intel modules define an environment variable MKLROOT that can be used to simplify the handling of path names.

module load intel
MKLPATH=$MKLROOT/lib/intel64_lin
MKLINCLUDE=$MKLROOT/include
MKLFFTWINCLUDE=$MKLROOT/include/fftw

Compiling and dynamic linking

The following should link a FORTRAN program myprog.f calling fftw3 - routines:

ifort myprog.f -I$MKLINCLUDE -I$MKLFFTWINCLUDE -L$MKLPATH -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm

For a configure script one has to explore its environment variables to fetch compiler and linker flags to the configuration process. This may be for example:

module load intel
export CFLAGS=" -fPIC -O3 -I$MKLINCLUDE -I$MKLFFTWINCLUDE -Wl,-rpath=$LD_RUN_PATH"
export LIBS="-L$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm"

Note,

-Wl,-rpath=$LD_RUN_PATH

ensures that the path to the MKL is stored in the binary. This ensures that no compiler module is needed during runtime and the originally specified library version is used.

Compiling and static linking

To be described …

Known issues

The linking with OpenMP* threadedIntel® oneAPI Math Kernel Library failed for the nfft - tools.