Intel MKL 11.1 Getting Started

This article is intended to help the users to get started on intel® MKL fast.  Please click the topic you are interested from the below table.



Preparation stage

•        Installation Guide

•        System Requirements

Implementation stage

•        Set build environment variable

•        Write your first intel® MKL program

•        Use intel® MKL source code example

•        Link intel® MKL Advisor, which is new!

Run stage

•        Set run time environment variable

Advanced stage

•        Multi-threading (Multi-Core) Support

•        Building a Custom Dynamic (Shared) Library


Before getting started, it may be helpful to take a look at the following links available online for the latest information regarding the intel® MKL library:

•         Intel® MKL Main Product Page

•         Intel® MKL 11.1 Release Notes

•        Intel® MKL 11.1 Bug Fixes

Links to documentation, help, and code samples can be found on the main Intel MKL product page. For technical support visit the Intel MKL technical support forum and review the articles in the Intel MKL knowledgebase.

Please register your product using your preferred email address. This helps Intel recognize you as a valued customer in the support forum and insures that you will be notified of product updates. You can read Intel's Online Privacy Notice Summary if you have any questions regarding the use of your email address for software product registration.

Environment Variables

A script (batch file on Windows, shell script on other platforms) located in the <mkl install directory>\mkl\bin\ directory can be used to set the MKLROOT, LIB, INCLUDE and any required system-specific environment variables to point to the appropriate MKL library directories. Use of this script is an optional, but convenient, means by which to configure your development system for compiling and linking with intel® MKL.

You run the script with a single input that specifies the primary processor architecture of interest. For example, mklvars.bat ia32 configures the environment variables for compiling and linking a 32-bit Intel MKL application. Likewise, mklvars.bat intel64 configures your development environment to build 64-bit intel® MKL applications.

Note: in the text that follows, <arch> refers to the primary processor architecture, such as ia32 or intel64 and <MKLROOT> refers to the Intel MKL installation directory. Additionally, '\' and '/' are used interchangeably as directory separators.

An alternate architecture-specific script file is located in the <MKLROOT>\bin\<arch> directory that can be run without any input parameters. It calls the mklvars script mentioned above with the appropriate architecture as an input parameter.

Once defined, you can reference the MKLROOT variable within your makefiles and/or project files to locate the header and library files necessary to compile and link applications using Intel MKL.

Before running the build scripts provided with the Intel MKL example programs you must first be sure to set the MKLROOT environment variable to point to the MKL installation directory on your system. MKLROOT must point to that directory which contains the Intel MKL bin, lib, include and tools directories. The sample build scripts will reference the MKLROOT environment variable in order to locate Intel MKL and any additional tools required.

On a Windows system the following batch files are available to configure the environment for building Intel MKL applications:

C:\Program Files (x86)\Intel\ComposerXE-2013\mkl\bin\mklvars.bat  <arch>


IA-32 Intel® Architecture:  C:\Program Files (x86)\Intel\ComposerXE-2013\mkl \bin\ia32\mklvars_ia32.bat
Intel® 64 Architecture:  C:\Program Files (x86)\Intel\ComposerXE-2013\mkl \bin\intel64\mklvars_intel64.bat

On a Linux* system the following shell scripts are available to configure the environment for building Intel MKL applications:

/opt/intel/composerxe-2013/mkl/bin/  <arch>


IA-32 Intel® Architecture:  /opt/intel/composerxe-2013/mkl/bin/bin/ia32/
Intel® 64 Architecture:  /opt/intel/composerxe-2013/mkl/bin/intel64/

Write your first MKL program

Download the sample code (mkl_lab_solution.c) here.

Step1: Include Files

Intel MKL functions and structures are defined within several header files for C and interface files and modules for Fortran. These can be found in the <MKLROOT>\include directory and for Fortran several nested directories depending on architecture and interface. The "mkl.h" and "" files include all of these. The environment variable scripts can be used to point to the appropriate directories.

Step 2: Calling Intel MKL Functions

Calling Intel MKL function is as simple as calling any C function or FORTRAN function in your program. MKL provide both FORTRAN and C interface for most routines. Please see the MKL manual to find the function list you hope to use.

For example. compute C=A*B, A is mxn matrix, B is nxk matrix.

sgemm(transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc)


Step 3: Linking Intel® MKL library with your program

The dynamic library dispatcher and static library mechanisms in Intel MKL are designed to make the process of calling Intel MKL functions as simple as calling any library.  Multiple SIMD-optimized versions of each function are concealed behind a single entry point. But you don't need to worry about the optimized code for get started, just make sure link the right libraries for your application.

Please click the intel®  MKL link line advisor to find the needed libraries, example

Under Windows*: 
The command line is like below,
>C:\Program Files (x86)\Intel\ComposerXE-2013\mkl\bin\mklvars.bat" ia32
>cl.exe mkl_lab_solution.c mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib

If with Intel Composer XE, as intel mkl is intergrated to it. The command line is simpler,
> icl.exe mkl_lab_solution.c /Qmkl

If with Microsoft* Visual Studio, please refer to Compile and Link MKL with Microsoft* Visual C/C++*

Under Linux:
if with gcc
$source /opt/intel/mkl/bin/ ia32
$gcc -m32 mkl_lab_solution.c -lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm

If with Intel Composer XE, the command line is easy
$ source /opt/intel/composer_xe_2013/bin/ ia32
$ icc mkl_lab_solution.c -mkl
$ icc mkl_lab_solution.c -mkl

Step 4: Run the executable program
You can set run-time environment as above discription. If you have done with script, you can run the executable program directly.
$ source /opt/intel/mkl/bin/ ia32
$ ./a.out
Enter matrix size N=1024
Dgemm_multiply(). Elapsed time = 0.49 seconds

or set LD_LIBRARY_PATH under linux and PATH under windows.
$ export LD_LIBRARY_PATH=opt/opt/intel/composer_xe_2013/mkl/lib/ia32:$LD_LIBRARY_PATH
$ ./a.out

Intel® MKL Source Code Sample

1.    Intel® MKL provide source code samples, almost for each function, like blas, lapack, FFT etc, both c and Fortran source code. You may find them under the <MKL install Dir> /examples

2.    Intel® MKL knowledge base also provide many source code sample, please explore sample there, for example,

•   How to build intel® MKL application in Intel Visual Fotran (MSVC*2005)

•   LAPACK Examples

•   Using Intel® MKL in your C# program

Multi-threading (Multi-Core) Support

Intel MKL 11.0 uses the Intel OpenMP library to implement multi-threading within the library thus supporting multiple hardware threads or cores. In some cases you can use OpenMP environment variables and APIs to control the OpenMP threading behavior within Intel MKL. In addition, dedicated Ifunctions have been introduced to control threading behavior of  behavior of Intel MKL functions independent of the OpenMP controls.  For detailed information regarding OpenMP and Intel MKL, please refer to the reference manuals and the following knowledgebase articles:

Intel® MKL 10.x Threading

Note: You must include the appropriate OpenMP shared-library file in your PATH. There are known incompatibilities between various versions of the OpenMP libraries. If you encounter problems, make sure that there is only one version of OpenMP located in your PATH environment variable.

Building a Custom Dynamic (Shared) Library

Please see the following knowledgebase article and the Intel MKL documentation for information on building a custom dynamic library:

Intel® MKL User's Guide - Chapter 5

Optimization Notice in English

For more complete information about compiler optimizations, see our Optimization Notice.

1 comment



I am relatively new to Intel MKL and the above documentation was really helpful to me ..I installed Intel MKL in my computer with Windows 7 ...and now needs to set the environment variables..

In this document u have explained about the environment variables.. I could find the file 'mklvars_ia32' in my MKL root directory .... but I didn't get the point how can one set the root, lib and include ....

In ur second paragraph u mentioned as ''You run the script with a single input that specifies the primary processor architecture of interest'' ... so where and how to run the script ?

Can u please elaborate on the steps to set the environment variables ?

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.