Intel MKL - shawfdong/hyades GitHub Wiki
Intel MKL (Math Kernel Library) includes highly vectorized and threaded Linear Algebra, Fast Fourier Transforms (FFT), Vector Math and Statistics functions. Cluster-based versions of LAPACK, FFT and sparse solver are also included to support MPI-based distributed memory computing[1].
Intel MKL has the following functional categories:
- Linear algebra: including optimized BLAS, BLACS, LAPACK, ScaLAPACK, PBLAS, sparse BLAS, sparse solvers such as PARDISO, iterative sparse solvers, and Parallel Direct Sparse Solver for Clusters.
- Fast Fourier Transforms: Multidimensional (up to 7D) FFTs, FFTW interfaces, Cluster FFT
- Vector Mathematical Functions (VML)
- Statistical Functions (VSL)
- Data fitting
- others: including Vector Random Number Generators, Poisson Solvers, Optimization Solvers
- Intel Math Kernel Library - Documentation
- Intel MKL 11.2 Reference Manual | PDF version
- Intel MKL 11.2 for Linux User's Guides | PDF version
- Tutorials
Intel MKL is a vast and complex library, with a bewildering array of components, interfaces and options; so linking with it can be tricky. There is a whole chapter in the User's Guide, Chapter 3: Linking Your Application with the Intel Math Kernel Library, that is devoted to this topic. That chapter should be consulted to learn the gory details of linking with Intel MKL. Here we list some basic linking examples.
The most common usage scenario is to link with sequential (serial) version of Intel MKL. For starters, you can use the following linking options:
-lmkl_intel_lp64 -lmkl_core -lmkl_sequentialwhich will use the LP64 interface (32-bit integer) and link with the dynamic libraries.
For example, to compile an example program for LAPACK by NAG and link with sequential version of Intel MKL:
$ ifort -o lapackpgm.x lapackpgm.f \ -lmkl_intel_lp64 -lmkl_core -lmkl_sequential
A shortcut is to use the -mkl=sequential option for Intel compilers:
$ ifort -o lapackpgm.x lapackpgm.f -mkl=sequential
If you want to link with the static libraries, use:
-Wl,--start-group \ ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a \ ${MKLROOT}/lib/intel64/libmkl_core.a \ ${MKLROOT}/lib/intel64/libmkl_sequential.a \ -Wl,--end-groupor
-static \ -Wl,--start-group -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -Wl,--end-groupor
-static -mkl=sequentialNote the linker option --start-group archives --end-group causes the specified archives to be searched repeatedly until no new undefined references are created[2]. The option is necessary because there are circular references among the libraries.
To link dynamically with multi-threaded version of Intel MKL, use the following linking options:
-lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -openmpor use Intel compilers option -mkl=parallel or -mkl.
To link statically, use:
-Wl,--start-group \ ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a \ ${MKLROOT}/lib/intel64/libmkl_core.a \ ${MKLROOT}/lib/intel64/libmkl_intel_thread.a \ -Wl,--end-group -openmpor use Intel compilers option -static -mkl=parallel or -static -mkl.
A quick way to link with the Intel MKL cluster components, like BLACS, CDFT (cluster FFT), ScaLAPACK, is to use Intel compilers option -mkl=cluster for Intel MPI. For example:
$ mpiifort -o mpipgm.x mpipgm.f -mkl=cluster
Intel MKL also provides another option for quick linking of your application: Single Dynamic Library (SDL). To use SDL, link with libmkl_rt.so (-lmkl_rt. For example:
$ ifort -o lapackpgm.x lapackpgm.f -lmkl_rtSDL enables you to select the interface and threading library for Intel MKL at run time. By default, linking with SDL provides:
- Intel LP64 interface on systems based on the Intel 64 architecture, like Hyades
- Intel threading
Here we only cover the basic scenario of linking with Intel MKL. For more complex scenarios, please use the online tool Intel MKL Link Line Advisor or the command-line tool mkl_link_tool to determine the libraries and options to specify on your link or compilation line.
Intel MKL Link Line Advisor is an online tool. The tool requests information about your system and on how you intend to use Intel MKL (link dynamically or statically, use threaded or sequential mode, etc.). It then automatically generates the appropriate link line for your application.
- latest version of Intel Math Kernel Library Link Line Advisor
- local copy of Intel Math Kernel Library Link Line Advisor
-L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -lpthread -lmwhich is appropriate to be included in a Makefile[3]. However, when you use those options in a command line, you should replace all $(MKLROOT) with ${MKLROOT}, because $(MKLROOT) means command substitution in Bash[4] and Bash will try to execute MKLROOT as a command! And it is not necessary to specify the paths for MKL libraries and headers, because they are already in the default search paths on Hyades; so you can simply remove them from the command-line.
Using the command-line Link tool provided by Intel MKL can simplify building your application with Intel MKL. The tool not only provides the options, libraries, and environment variables to use, but also performs compilation and building of your application.
The tool mkl_link_tool is installed in the $MKLROOT/tools directory. To learn more about the tool, run:
$ $MKLROOT/tools/mkl_link_tool --helpor consult the knowledge base article on Intel MKL Command-line Link Tool.