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/tce/packages/mkl/mkl-<version> on TOSS 4 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 2022.1.0 on TOSS 3 the compile/link flags would be:

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

The MKL installation contains many examples. Below shows how one could build and run the dgemmx example:

cd /usr/workspace/$USER
mkdir mkl_examples && cd mkl_examples
cp -r /usr/tce/packages/mkl/mkl-2022.1.0/examples/* ./
tar xf examples_core_c.tgz
cd c
mkdir build && cd build
ml intel/2023.2.1-magic mkl
cmake -DCMAKE_C_COMPILER=icx ..
make -j
./blas-cblas_dgemmx ../blas/data/cblas_dgemmx.d

Complete MKL documentation is in either the documentation directory of the installation, depending on the MKL version.