Intel® Math Kernel Library (Intel MKL) Linkage and Distribution - Quick Reference Guide

The article describes various types of linkage models offering in Intel® Math Kernel Library (Intel MKL) and which Intel MKL libraries are required to be distributed by developers with applications.

Overview

The Intel® MKL libraries are organized by three types of library files:

Library types

Description

Folder location

Example

Dynamic Library

Dynamic runtime library

[install-dir]\redist\ia32\mkl\

mkl_intel_thread.dll, mkl_avx2.dll
mkl_core.dll
mkl_sequential.dll

Dynamic import library (windows only)

[install-dir]\mkl\lib\ia32\

mkl_intel_c_dll.lib
mkl_intel_thread_dll.lib
mkl_core_dll.lib
mkl_seqential_dll.lib

Static Library

Static library, contains all  processor-specific optimization in one package

[install-dir]\mkl\lib\ia32\

mkl_intel_c.lib
mkl_intel_thread.lib
mkl_core.lib
mkl_sequential.lib

Single Dynamic Library

Single Dynamic Library

(SDL)

[install-dir]\redist\ia32\mkl\
&[install-dir]\mkl\lib\ia32\

mkl_rt.dll
mkl_rt.lib

Note: The table addressed the 32bit windows libraries. Developers can extend them to intel64, cluster, linux* correspondingly.

Linkage Models and Example

These libraries offer various linkage models for different needs. The following are the typical four linkage models supported by the Intel® MKL:

Dynamic linkage

icl myprog.c mkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib

Static linkage

ifort myprog.f mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib

SDL linkage

cl myprog.c mkl_rt.lib

Custom dynamic linkage

First build custom dynamic library: mkl_custom.dll from mkl\tools\builder
-cl myprog.c mkl_custom.lib or 
- HMODULE dylib = LoadLibrary("mkl_custom.dll");

Note: libiomp5md.lib and libiomp5md.dll are required when threading MKL libraries are linked. They are the OpenMP Runtime library, located in [install-dir]\compiler\lib\32 and [install-dir]\redist\ia32\compiler respectively.

Above are some explicit link examples. Please read Intel MKL user guide for more details about Custom Dynamic library and SDL linkage model at section:
- Using the Single Dynamic Library
- Dynamically Selecting the Interface and Threading Layer- Building Custom Dynamic-link Libraries

Moreover, Intel® MKL provides several options for quick linking of your application. The simplest options depend on your development environment, like Intel MKL user guide section:
-Using the Qmkl Compiler Option
- Automatically Linking a Project in the Visual Studio* Integrated Development -Environment with Intel® MKL
-Using the Link-line Advisor

Quick comparison of the four linkage models 

Features

Dynamic linkage

Custom dynamic linkage

Single Dynamic Library linkage

Static linkage

Build

Link to dynamic import libraries

Build Custom DLL

Link to SDL library : mkl_rt.lib

Link to static libraries

Executable Size

Small

Smallest

Small

Medium

Distribution

Distribute Linked mkl dll and processor-specific dll.

Distribute custom DLL*

Distribute mkl_rt.dll and mkl dll as dynamic linkage

No extra distribution*

Total Binary Size

Large

Small

Large

Medium

Distribution Notes

As above table shows, dynamic linkage and SDL linkage are required to distribute the linked MKL dlls and processor-specific dlls with users’ application. Usually, in order to support different types of processors, we recommend distributing all of dlls located in [install-dir]\redist\ia32\mkl\.

For example,

 

Link line

 Distributed dll 

Dynamic linkage

icl myprog.c mkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib

mkl_intel_thread.dll
mkl_core.dll
libiomp5md.dll+
all processor-specific dlls under redist\ia32\mkl\

SDL linkage

cl myprog.c mkl_rt.lib

mkl_rt.dll
mkl_intel_thread.dll
mkl_core.dll
libiomp5md.dll+
all processor-specific dlls under redist\ia32\mkl\

+libiomp5md.dll is from redist\ia32\compiler folder

+static linkage and custom linkage don’t require extra Intel MKL library distribution. But if building with threaded library, libiomp5md.dll is required.

Processor-specific dll: Sometimes, in order to distribute a smaller application for special type of processor, user can distribute only the processor- specific optimized dll other than all processor-specific dlls under redist\ia32\mkl.

For example, mentioned in Intel MKL forum thread U517954, user only call PARDISO* function on the processor supporting Intel® Advanced Vector Extensions 2 (Intel® AVX) instruction, then  user can distribute the below 5 dlls:

mkl_rt.dll, mkl_intel_thread.dll, mkl_avx2.dll mkl_core.dll libiomp5md.dll 

+mkl_avx2.dll: Kernel optimized for Intel® Advanced Vector Extensions 2 (Intel® AVX).

Note: There are several non-processor-specific dlls, they are required only when used

libimalloc.dll

Dynamic library to support renaming of memory functions

1033\mkl_msg.dll

Catalog of Intel® Math Kernel Library (Intel® MKL) messages in English

Dynamic dll vs. Custom dll: In order to distribute a small application, the custom dll is recommended too. For example, mentioned in another MKL forum thread U517950, user is calling Pardiso and Dfeast functions. Normally, user needs to distribute the mkl_intel_thread.dll, mkl_core.dll, libiomp5md.dll and all processor-specific dlls with their application. In order to reproduce the redistribution size, the user can build custom.dll only including PARIDSO and DEFAST function based on Intel MKL custom dll builder. Then they can only distribute his application and the cutom.dll (+libiomp5md.dll). No Intel MKL library is needed.

If you're still having trouble on library linkage and distribution, you might check the reference documentation. Another option is to search the Intel MKL forum for other reports of a similar problem or post a question of your own.

Reference:

  1. User's Guide for Intel® Math Kernel Library 11.1 Update 3 for Windows* OS
  2. User's Guide for Intel® Math Kernel Library 11 for Linux*
  3. Which Intel® Math Kernel Library (Intel® MKL) libraries are "Redistributes"?
  4. A New Linking Model-Single Dynamic Library mkl_rt Since Intel® MKL 10.3
For more complete information about compiler optimizations, see our Optimization Notice.