Using Intel® MKL in Intel® Compiler - mkl, Qmkl options

Introduction
-mkl, Qmkl compiler option was introduced since Intel® Compiler 11.1.  It provided users a quick and efficient way to use Intel® MKL in an application. Intel® mkl library is organized by 4-layered architectures, which requires users to include multiple header files, include multiple libraries, add the path for header files and library files in the compiler line or IDE environment step by step.  With the option, users are free from complex link command and environment setting:just simply add "-mkl" or click one button, all of environment setting and required libraries are ready. 

-mkl, Qmkl: 
It is a compiler option, tells the compiler to link to certain parts of the Intel® Math Kernel Library (Intel® MKL).

IDE Equivalent


Windows: Libraries > Use Intel® Math Kernel Library,
Linux: None
Mac OS X: Libraries > Use Inte®l Math Kernel Library

Syntax

Linux and Mac OS X:

-mkl[=lib]

Windows:

/Qmkl[:lib]

Argument

lib

Indicates the part of the library that the compiler should link to. Possible values are:

parallel
using threaded libraries
This is the default if the option is specified with no lib.

It is equivalent to
"-lmkl_solver_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5" and conrresponding lib and include environment variable setting

sequential
using non-threaded libraries

equivalent to
"-lmkl_solver_lp64_sequential  -lmkl_intel_lp64 -lmkl_sequential -lmkl_core" and corresponding environment variable setting

cluster
using cluster mkl and sequential mkl libraries

equivalent to
"-lmkl_solver_lp64 -lmkl_intel_lp64
-lmkl_cdft_core -lmkl_scalapack_lp64
-lmkl_blacs_intelmpi_lp64
-lmkl_sequential -lmkl_core and corresponding environment variable settings

Default

OFF

The compiler does not link to the Intel® MKL.


Above the table and the below example are using Intel Fortran Compiler for linux, 64bit as sample. You may find the other equivalents for Windows  and Mac OS by Intel® Math Kernel Library Link Line Advisor

Command line example
-mkl  (same as -mkl:parallel) 
$ /opt/intel/Compiler/11.1/0xx/bin/intel64/ifort -o test test.f90 -mkl  [-static-intel]  if static linking.
$ source /opt/intel/Compiler/11.1/0xx/bin/ifortvars.sh intel64
$./test

-mkl:sequential
$ /opt/intel/Compiler/11.1/0xx/bin/intel64/ifort -o test test.f90 -mkl:sequential  [-static-intel] if static linking.

-mkl:cluster
$ /opt/intel/Compiler/11.1/0xx/bin/intel64/ifort -o test test.f90 -mkl:cluster  [-static-intel] if static linking

Build IDE one button option
Intel® Visual Fortran for Windows, for example the figure of Step 4.2



Intel® C++ Compiler for Windows:

mkl_in_c1.JPG


Known issue:

Via the option, users can free from the project setting, library selection.  But it only covers several common combinations. For special library usage or combination, one may add some options manually. For example,

1. Fortran 95 Interface library
If compiler reports unresolved symbols/references:  _*_mkl95, then you may add these libraries: mkl_blas95.lib mkl_blas95_lp64.lib mkl_lapack95.lib manually. For example,  the link line is like:
$ ifort -o test test.f90 -mkl -L$mklpath/lib/em64t -lmkl_lapack95

If compiler ask mkl95_lapack.mod or mkl95_blas.mod module file, then please add the including path manually,
$ /opt/intel/Compiler/11.1/0xx/bin/intel64/ifort -o test test.f90 -mkl -I$mklpath/include/em64t/lp64

2. ilp 64 support
If you are using 64bit integer in 64bit application, the quick compiler option or one button haven't covered it yet. Please add the library manually according to Intel® Math Kernel Library Link Line Advisor

For more more complex combination, please also refer to Intel® Math Kernel Library Link Line Advisor

*The option is only valid for Intel® C++ Compiler and Fortran Compiler 11.1 and later.
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.