You are here

MKL - Intel Math Kernel Library

Availability & Compatibility

OSC supports single-process use of MKL for LAPACK and BLAS levels one through three. For multi-process applications, we also support the ScaLAPACK, FFTW2, and FFTW3 MKL wrappers. MKL modules are available for the Intel, gnu, and PGI compilers.

Version

Glenn

Oakley

Ruby

Statewide Software

10.0.3

X

10.3.0

X

X

X

11.2.0

X

Restrictions

All OSC users may use the Intel MKL for academic purposes.

Usage

Set-up

To configure your environment for the Intel MKL, load the “mkl” module:

module load mkl

This step is required for both building and running MKL applications. Exception: The "mkl" module is usually not needed when using the Intel compilers; just use the "-mkl" flag on the compile and link steps.

Building With MKL (Oakley)

The Oakley MKL module will automatically configure your environment to locate the appropriate include files. When linking, however, you have a variety of options to choose from depending on your needs. These options come in the form of environment variables defined by the module. Which variable you include when linking will determine what particular configuration of MKL you get.

Environment Variable

Function

$MKL_CFLAGS

Include flags for C

$MKL_FFLAGS

Include flags for Fortran

$MKL_LIBS

Use multithreaded MKL with 32-bit integers. This is the standard configuration.

$MKL_LIBS_INT64

Use multithreaded MKL with 64-bit (“ILP64”) integers.

$MKL_LIBS_SEQ

Use single-threaded (“SEQuential”) MKL with with 32-bit integers.

$MKL_LIBS_SEQ_INT64

Use single-threaded MKL with 64-bit integers.

Notes:

64-bit integers are not supported by the FFTW2 wrappers. (See below.)

The Intel compilers are specially configured for Intel MKL. If you are using this toolchain, you can use the “-mkl” option when linking in place of $MKL_LIBS.

The default, multithreaded MKL libraries will automatically run in a single thread if they are called from an OpenMP parallel region. If you want to force single-threaded behavior throughout your program, choose one of the “_SEQ” variables from the list above.

Fortran 95 BLAS/LAPACK Wrappers

To compile Fortran 95 programs with modules, add the $MKL_F95FLAGS variable to your compilation step. If you need 64-bit integers, use the $MKL_F95_FLAGS_INT64 instead. When linking, you will also need to use $MKL_F95LIBS (or $MKL_F95LIBS_INT64 if using 64-bit integers). These variables will allow your programs to use the BLAS and LAPACK wrappers for MKL.

FFTW Wrappers

A number of “wrappers” are provided in the form of environment variables that allow you to use FFTW APIs with MKL. Variables ending in FLAGS should be included with your compilation step, while variables ending in LIBS should be included in your linking step.

Environment Variable

Function

$MKL_FFTW_CFLAGS

Compile variable for C programs.

$MKL_FFTW_FFLAGS

Compile variable for Fortran programs.

$MKL_FFTW2_D_CLIBS

Linking variable for double-precision FFTW2 C programs.

$MKL_FFTW2_D_FLIBS

Linking variable for double-precision FFTW2 Fortran programs.

$MKL_FFTW2_S_CLIBS

Linking variable for single-precision FFTW2 C programs.

$MKL_FFTW2_S_FLIBS

Linking variable for single-precision FFTW2 Fortran programs.

$MKL_FFTW3_CLIBS

Linking variable for FFTW3 C programs.

$MKL_FFTW3_FLIBS

Linking variable for FFTW3 Fortran programs.

Notes:

FFTW3 is the default wrapper and should be picked up by your linker automatically. If you would prefer to use FFTW2, use the appropriate linking variable.

The FFTW2 wrappers do not support 64-bit (“ILP64”) integers.

Examples

The following examples use the Intel compilers, though they should work using the GNU and Portland Group compilers as well.

Advanced Usage

If you are already familiar with building MKL applications with your chosen build tool (GCC, Intel, or PGI) and you do not wish to use the convenience variables discussed above, you may wish to use the $MKLROOT variable instead. This variable points to the installation directory for Intel MKL. All include files can be found in $MKLROOT/include, for example, and the libraries are in $MKLROOT/lib/intel64.

Running MKL Programs

When running an MKL program, you need to be sure to take the following steps.

Load the mkl module:

module load mkl

If running with parallel MKL, set OMP_NUM_THREADS to match the number of cores per node in your process. In the bash shell, you can accomplish this with: