How to Build an Intel® MKL Application with Intel® Visual Fortran Compiler

This document describes the steps to build an Intel® MKL application with Intel® Visual FORTRAN Compiler, which is integrated with Microsoft Visual Studio* 2010

Software Requirement:

1. Intel® Visual Fortran Compiler XE 12.1 for Windows and later version
The compiler is required to be installed and integrated to Microsoft Visual Studio* 2010 properly.

2. Intel® MKL 11.0 for windows
You can install the stand-alone Intel® MKL version separately or the use the Intel® MKL which is included in the Intel® Visual Fortran Compiler XE version. 

3. Microsoft* Visual Studio 2010 (MSVS* 2010)
If you are building  a 64 bit application, please install the MSVS* 2010 package which supports 64bit application development. (it is supported by default by MSVS* 2010).

Step1 :  Select whether you are building  ia32 or intel64 application
Depending on the target machine you need your application to run on, select
ia32 : 32 bit application for IA-32 architecture
intel64: 64 bit application for Intel® 64 architecture

More information about what ia32 and Intel® 64 architecture,, please see this article.

When building ia32 or intel64 application within Microsoft VS* 2010 environment, please check the configuration manager=> active platform.  It should be “Win32" or "X64" (which correspond to intel64).

Step 2: Select the libraries to link from  Intel® MKL 
Please check the on-line KB article Intel® Math Kernel Library Link Line Advisor to find the libraries to link for your application based on your platform preferences.

Online linkline advisor will list the libraries you need to link against from Intel® MKL.
For example,
for an ia32 windows application:
"mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib" are common libraries for a 64bit windows application : "mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib" 

Step 3: How to link Intel® MKL in your project manually?
Please follow the steps in how to use Intel® MKL in Microsoft VS* to add the include path, library path and mkl libraries as the linkline advisor listed.  

3.1) For example, add include path manually



3.2)Add the path of library manually


Please take care of the library path and enter the right directory:
<MKL install dir>\ia32,  for ia32 application
<MKL install dir>\intel64, for X64 application
they can't be mixed. 

3.3) Add required libraries manually

Step 4: Link Intel® MKL in your project automatically - One quick option  (optional)

Please notes * Step 4 (optional) and the step3 are equivalent in most of case. So please use only one of them, don’t mix both. 

The recent MKL version have provided one "build" menu in MSVS* 2010 environment.  See below screenshot in MSVS* 2010, Open Project Pages >> Fortran >> Libraries >> Using Intel Math Kernel Library, click the one you need, like /Qmkl:parallel or /Qmkl:sequential. Then all of environment setting and required libraries are ready in your project. Please go ahead to build and run the application.

 

Sample Code:

The attached zip file contain an  MSVS 2010 project (Intel® FORTRAN Compiler XE 12.1 IA32 application) for your reference. DFT_VF_sample.zip, which does Real 1d DFT.

Notes:

  1. Please note: some interface libraries (i.e mkl_lapack95.lib mkl_blas95.lib fftw3xc_ms) are not Intel® MKL standard libraries, so the "one option" don't support it.  You may add them manually if you need to use them.

  2. About Compaq*Visual Fortran (CVF) support and port from 32bit to 64bit (Optional for those who used CVF)
    CVF and Intel Fortran compiler use different calling convention by default:
    CVF: stdcall
    Intel Visual Fortran, C Compiler: cdecl (default interface of the Microsoft Visual C* application)

    1) Intel® MKL support both of them on ia32 platform, but if you are porting from CVF to Intel® Fortran, you may take care of the required library: mkl_intel_s or mkl_intel_c.lib
  • Using the CVF compiler
    The CVF compiler will link with mkl_intel_s[_dll].lib if routines are compiled with the default interface. However, if you compile with the option /iface=(cref,nomixed_str_len_arg), please link with mkl_intel_c[_dll].lib .
  • Using the Intel® Visual Fortran compiler
    The Intel® Fortran compiler will link with mkl_intel_c[_dll].lib by default. But if the /Gm option is used, please call mkl_intel_s  [_dll].lib (/Gm enables CVF and Powerstation calling convention compatibility, so does /iface:cvf).

   2) Intel® MKL doesn’t provide intel64 and IA64 CVF interface support.  So if you are porting CVF 32bit to 64bit application with Intel Fortran compiler and Intel MKL, please note, you must link "mkl_intel_lp64|ilp64, mkl_intel_thread, mkl_core.lib" and remove the compiler option /Gm or /iface:cvf.

Troubleshooting:


when build the project, you may get
1. fatal error LNK1104: cannot open file 'mkl_xxx.lib'
please make sure the library is in the library path and the path you mark in step 3 or step 4 is right

2. "error #7002: Error opening the compiled module file.  Check INCLUDE paths. [MKL_DFTI]."
Please add the header file mkl_dfti.f90 in your code, for example,

! Include to build module MKL_DFTI
INCLUDE 'mkl_dfti.f90'
before the code line
USE MKL_DFTI

Or copy the mkl_dfti.f90 file to the source directory of your project and include it in your Project. 

Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.