Intel's threaded Math Kernel Library (MKL) is a set of math libraries containing optimized BLAS, LAPACK, ScaLAPACK, FFT and other routines in the LC Linux environment. MKL is available only on LC machines with x86-based chips. Various versions of MKL are available in /usr/local/tools/mkl-<version> on CHAOS 5 systems and in /usr/tce/packages/mkl/mkl-<version> on TOSS 3 systems, where <version> is a specific version. MKL contains libraries built for specific configurations, which can make it difficult to determine the appropriate compile/link flags to use.

Intel has a web-based tool for determining your link line depending on compiler, architecture, etc. This tool is available at: http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor. Select "Linux" for the operating system and "Intel 64" for the architecture. We suggest setting -Wl,-rpath= to the same directory specified with the -L flag when using dynamic libraries to avoid requiring LD_LIBRARY_PATH to be set at runtime. As a concrete example, with the Intel or GNU C compiler with 32-bit integers and non-threaded, dynamic library MKL version 2018.0 on TOSS 3 the compile/link flags would be:

-I/usr/tce/packages/mkl/mkl-2018.0/include -L/usr/tce/packages/mkl/mkl-2018.0/lib -Wl,-rpath=/usr/tce/packages/mkl/mkl-2018.0/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm

To use the Intel compiler with 32-bit integers and the threaded implementation of MKL, the compiler/link flags will be:

-I/usr/tce/packages/mkl/mkl-2018.0/include -L/usr/tce/packages/mkl/mkl-2018.0/lib -Wl,-rpath=/usr/tce/packages/mkl/mkl-2018.0/lib -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl

Complete MKL documentation is in either the doc or Documentation directory of the installation, depending on the MKL version. When using the multi-threaded MKL libraries, the Linux environment variable OMP_NUM_THREADS controls the number of threads spawned by the MKL routines (by default, MKL sets the number of threads equal to the number of cores on the node).