Intel MKL
The Intel® Math Kernel Library (Intel® MKL) provides optimized parallel math routines, particularly tuned for Intel CPUs. The MKL provides the following
The Intel MKL’s module intel-oneapi-mkl
and can be loaded (after loading the compiler and MPI modules you want to use first) by
module load intel-oneapi-mkl
Compiling And Linking
To link a library, the compiler and linker need at minimum
- name of and path to the include files
- name of and path to the library
The FFTW3 library’s include files have the standard names, but are in a different place than the other MKL-related include files. But the FFTW3 functions are included in the MKL libraries, so searching for the typical FFTW3 libraries by 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 module automatically sets the MKLROOT
environmental variable.
Additional useful environmental variables are:
export MKLPATH=$MKLROOT/lib
export MKLINCLUDE=$MKLROOT/include
export MKLFFTWINCLUDE=$MKLROOT/include/fftw
Intel MKL provides a convenient online tool for determining the compilation and linker flags to use at [https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor](Intel oneAPI Math Kernel Library Link Line Advisor)
The following should link a Fortran program myprog.f
calling FFTW3 routines:
ifx 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:
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.