Using Predefined Preprocessor Symbols for Intel® MKL Version-Dependent Compilation

Preprocessor symbols (macros) substitute values in a program before it is compiled. The substitution is performed in the preprocessing phase.

The following preprocessor symbols are available:

Predefined Preprocessor Symbol

Description

__INTEL_MKL__

Intel MKL major version

__INTEL_MKL_MINOR__

Intel MKL minor version

__INTEL_MKL_UPDATE__

Intel MKL update number

INTEL_MKL_VERSION

Intel MKL full version in the following format:

INTEL_MKL_VERSION = (__INTEL_MKL__*100+__INTEL_MKL_MINOR__)*100+__INTEL_MKL_UPDATE__

These symbols enable conditional compilation of code that uses new features introduced in a particular version of the library.

To perform conditional compilation:

  1. Include in your code the file where the macros are defined:
    • mkl.h for C/C++
    • mkl.fi for Fortran
  2. [Optionally] Use the following preprocessor directives to check whether the macro is defined:
    • #ifdef, #endif for C/C++
    • !DEC$IF DEFINED, !DEC$ENDIF for Fortran
  3. Use preprocessor directives for conditional inclusion of code:
    • #if, #endif for C/C++
    • !DEC$IF, !DEC$ENDIF for Fortran

Example

Compile a part of the code if Intel MKL version is MKL 10.3 update 4:

C/C++:

#include "mkl.h"
#ifdef INTEL_MKL_VERSION
#if INTEL_MKL_VERSION ==  100304
// 	Code to be conditionally compiled
#endif
#endif

Fortran:

    include "mkl.fi"
!DEC$IF DEFINED INTEL_MKL_VERSION
!DEC$IF INTEL_MKL_VERSION .EQ. 100304
* 	Code to be conditionally compiled 
!DEC$ENDIF
!DEC$ENDIF

Submit feedback on this help topic