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

By Ying Hu,

Published:06/09/2011   Last Updated:06/30/2015

Introduction
The Intel® Compiler option “-mkl”, “Qmkl” options provide users a quick and efficient way to link Intel® Math Kernel Library (Intel® MKL) in an application. With the option, users are free from complex link command, and just need to add simple options to link Intel MKL.

-mkl, Qmkl: 
It is a compiler option, tells the compiler to link to certain parts of Intel MKL.

Linux* and OS X*:
-mkl[=lib]
Windows*:
/Qmkl[:lib]

Argument
[lib]: Indicates which Intel MKL library files should be linked. Possible values are:

  • parallel
    Tells the compiler to link using the threaded libraries in Intel MKL. This is the default if the option is specified with no lib.
     
  • sequential
    Tells the compiler to link using the sequential libraries in the Intel MKL.
     
  • cluster
    Tells the compiler to link using the cluster-specific libraries and the sequential libraries in the Intel MKL. Cluster-specific libraries are not available for OS X*.

Default:
OFF  The compiler does not link to the Intel MKL.

The below example are using Intel Fortran Compiler for Linux*, 64bit as sample. You may find the other equivalents for Windows* and OS X* by Intel® Math Kernel Library Link Line Advisor

Command line example
-mkl  (same as -mkl:parallel) 

$ ifort -o test test.f90 -mkl  [-static-intel]  if static linking.

-mkl:sequential
$ifort -o test test.f90 -mkl:sequential  [-static-intel] if static linking.

-mkl:cluster
$ifort -o test test.f90 -mkl:cluster  [-static-intel] if static linking
 

Intel MKL package also contains IDE integration with Microsoft Visual Studio*, which is an easy to add Intel MKL into the applications. Check the article here to learn more information:
/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-compiling-and-linking-with-microsoft-visual-cc.html

Note:  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 combination, please also refer to Intel® Math Kernel Library Link Line Advisor
 

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804