skip to content
 

A high performance maths library for Intel CPUs. It comes in two versions, the basic MKL and the Cluster MKL which includes ScaLAPACK and BLACS. The most recent versions (10.0 onwards) combine the two. More recently this has ceased to be a standalone product and is now part of Intel OneAPI.

Instructions for users: 

Load the appropriate mkl module, and then link your code using an appropriate link line. This varies with almost every version of the library, and also depends on exactly what you're trying to do. However the recent versions of the Intel Fortran and C compilers are smart enough to insert the correct link line automatically if you use the -mkl flag when compiling, so unless you want to do something unusual it's best to stick with that. 

If you do want something unusal then Intel's https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor is very useful. Or failing that, consult the table below which documents options for some very old versions.

Version Link line
6.0 -lmkl -lmkl_lapack32 -lguide -lpthread
6.1 -lmkl -lmkl_lapack32 -lguide -lpthread
7.0 -lmkl -lguide -lpthread
7.2.1 -lmkl_lapack -lmkl -lguide -lpthread -lm
9.1 -lmkl_lapack -lmkl -lguide -lpthread -lm
9.1 (serial version) -lmkl_lapack -lmkl -lm
10.0 (backwards compatible linking) -lmkl_lapack -lmkl -lguide -lpthread -lm
10.0 and 10.1 (equivalent layered linking example) -lmkl_lapack -lmkl

-lmkl_intel_thread -lmkl_core -lguide -lpthread -lm

10.0 and 10.1 (Cluster example) -lmkl_scalapack_core -lmkl_blacs_openmpi -lmkl_lapack -lmkl

-lmkl_intel_thread -lmkl_core -lguide -lpthread -lm

Never load the MKL modules automatically in your shell startup files. The reason is that if your machine ever loses network access it will lock up because the MKL module sets LD_LIBRARY_PATH to include a network directory. 

Using the LAPACK and BLAS interfaces

Intel ship LAPACK and BLAS interfaces for Fortran 77 and Fortran 95 with version 10.2 and up. For older versions of MKL they have to be compiled. We have done this for the older versions using icc and ifort. The interfaces are not compatible over all compilers so source code is provided in the $MKLROOT/interfaces directory if you want to build a version for another compiler family than Intel.

Here's an example of statically linking the Fortran 95 interface to lapack:

 ifort -I $MKLPATH -o syevd syevd.f90  $MKLPATH/libmkl_lapack95.a \ -Wl,--start-group $MKLPATH/libmkl_intel_lp64.a $MKLPATH/libmkl_lapack.a \ $MKLPATH/libmkl_intel_thread.a $MKLPATH/libmkl_core.a -Wl,--end-group \ -lguide -lpthread 

You need to do this in the code to pick up the module files

 use mkl95_lapack use mkl95_precision 

Using the FFT routines

Intel completely changed the way you use FFT somewhere between versions 7 and 9 of the library. To use them from Fortran under version 9 and above you need to copy the $MKLINCLUDE/mkl_dfti.f90 file into your Fortran project and compile it (ifort -c mkl_dfti.f90) so you can then use the module (USE MKL_DFTI) in your own code.

Licence Details: 

This is proprietary software. The Department's licence for Intel Fortran and Intel C/C++ covers it. 

Documentation: 

MKL has extensive HTML and PDF documentation. The file mkluse.htm is particularly useful as it contains an explanation of the possible link lines. In more recent versions this information has been rolled into the user's guide which is userguide.pdf in the same directory. You can locate the documentation directory by doing a module help on your chosen MKL module.

Source: 

The library can be downloaded from https://software.intel.com/en-us/mkl. It requires a licence.

Admin notes: 

Installing new versions

The MKL comes bundled with Intel Fortran and Intel C these days, so the install script we use for those also installs it. See the docs for Intel OneAPI.

Licences

Recently Intel rolled the MKL into the ifort/icc/OneAPI licence so we now get it as part of those packages and can use whatever version they allow.

Building library interfaces

The more recent versions of the library have a set of wrappers that enable you to replace FFTW and other libraries with MKL seamlessly. For some reason you actually have to build these interfaces yourself in some versions; they aren't shipped ready-built (apparently these libraries call functions in the compiler runtime library, so must be compiled with the exact same compiler as you use them with). The install script we use for Intel C/Fortran/OneAPI takes care of it.

System status 

System monitoring page

Can't find what you're looking for?

Then you might find our A-Z site index useful. Or, you can search the site using the box at the top of the page, or by clicking here.