What is MKL?

The Intel Math Kernel Library (MKL) is a set of math libraries that contains optimized BLAS, LAPACK, FFTs, ScaLAPACK and other functions. It provides developers of scientific and engineering software with a set of linear algebra, Fast Fourier Transforms and vector math functions optimized for the latest Intel architecture.

Using MKL at HPC system

Various versions of MKL are available in our HPC system. You can check the installed version by following command:

module avail mkl

To load the MKL environments with various compilers:

Compiler Serial or Multithreaded (OpenMP) program Parallel MPI program
Intel Compiler module load intel module load impi
PGI Compiler module load pgi mkl module load [MPI_version]/pgi mkl
GNU Compiler module load gcc mkl module load [MPI_version]/gcc mkl

where [MPI_version] can be openmpi or mpich.

Compile programs with Intel MKL library

It is quite simple to compile and link a C, C++, or Fortran program with Intel MKL, especially when using the Intel compilers. You should select the Intel Compiler version you would like to use. The Intel MKL comes bundled with Intel compiler and Intel MPI. Intel MKL is included when you call the initial scripts or modules for Intel compilers.

Then you can compile and link your code with appropriate link flags. In general, adding ‘-mkl‘ flag when compiling would automatically insert the correct links.

$ icc -mkl blas_test.c                         # Default, multi-threaded
$ icc -mkl=parallel blas_test.c                # Multi-threaded
$ icc -mkl=sequential blas_test.c              # Single-threaded
$ mpiicc -mkl=cluster scalapack_test.c         # Multiprocess ScaLAPACK

To link MKL with non-Intel compiler toolchain, additional environment variables and linking options are required. You can check the link parameters at Intel MKL Link Line Advisor. It is recommended to select “Intel 64”, “64-bit integer” and “Dynamic linking” for our HPC cluster systems.

Additional Information

Intel MKL Home: https://software.intel.com/mkl

Intel MKL Link Line Advisor: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
Developer Guide for Intel MKL: https://www.intel.com/content/www/us/en/develop/documentation/onemkl-linux-developer-guide/