Difference between revisions of "Development/MKL"

From bwHPC Wiki
Jump to: navigation, search
m
Line 1: Line 1:
{{Softwarepage}}
+
{{Softwarepage|numlib/mkl}}
   
 
{| width=600px class="wikitable"
 
{| width=600px class="wikitable"

Revision as of 15:28, 21 December 2021

The main documentation is available via module help numlib/mkl on the cluster. Most software modules for applications provide working example batch scripts.


Description Content
module load numlib/mkl
License Commercial. See EULA.
Citing n/a
Links Intel MKL Homepage | Online-Documentation
Graphical Interface No

1 Description

Intel MKL (Math Kernel Library) is a library of optimized math routines for numerical computations such as linear algebra (using BLAS, LAPACK, ScaLAPACK) and discrete Fourier Transformation. With its standard interface in matrix computation and the interface of the popular fast Fourier transformation library fftw, MKL can be used to replace other libraries with minimal code changes. In fact a program which uses FFTW without MPI doesn't need to be changed at all. Just recompile it with the MKL linker flags.

2 Compiling and linking

Compilation is possible with both GCC and Intel compilers but it is easier for Intel compilers, so this case is explained here. After loading the compiler and the library module with

$ module load compiler/intel
$ module load numlib/mkl

you can include the MKL header file in your program:

#include <mkl.h>

Compilation is simple:

$ icpc -c example_mkl.c

When linking the program you have to tell the compiler to link against the mkl library:

$ icpc example_mkl.o -mkl

With the -mkl switch the intel compiler automatically sets the correct linker flags but you can specify them explicitly for example to enable static linking or when non-intel compilers are used. Information about the different options can be found at https://software.intel.com/en-us/node/438568 and especially helpful is the MKL link line advisor at https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor. By default $MKL_NUM_THREADS is set to 1 and so only one thread will be created, but if you feel the need to run the computation on more cores (after benchmarking) you can set $MKL_NUM_THREADS to a higher number.

2.1 FFTW Interface to Intel Math Kernel Library (MKL)

Sometimes, FFTW is not available on your cluster. You can use the MKL library instead and include the FFTW functions, too.

Intel Math Kernel Library (MKL) offers FFTW2 and FFTW3 interfaces to Intel MKL Fast Fourier Transform and Trigonometric Transform functionality. The purpose of these interfaces is to enable applications using FFTW to gain performance with Intel MKL without changing the program source code. To include the proper header files use the compiler option

-I${MKL_INC_DIR}/fftw

If you want to link dynamically against the fftw functions you can just use the flag

-mkl

but when using static linking you have to link against the correct library in the directory

${MKL_HOME}/interfaces/

See the corresponding webpages: