High-performance, multithreaded mathematics libraries for linear algebra, fast Fourier transforms, vector math, and more.
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.
All OSC users may use the Intel MKL for academic purposes.
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.
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.
||Include flags for C|
||Include flags for Fortran|
||Use multithreaded MKL with 32-bit integers. This is the standard configuration.|
||Use multithreaded MKL with 64-bit (“ILP64”) integers.|
||Use single-threaded (“
||Use single-threaded MKL with 64-bit integers.|
-mkl” option when linking in place of
_SEQ” variables from the list above.
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_INT64 if using 64-bit integers). These variables will allow your programs to use the BLAS and LAPACK wrappers for MKL.
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.
||Compile variable for C programs.|
||Compile variable for Fortran programs.|
||Linking variable for double-precision FFTW2 C programs.|
||Linking variable for double-precision FFTW2 Fortran programs.|
||Linking variable for single-precision FFTW2 C programs.|
||Linking variable for single-precision FFTW2 Fortran programs.|
||Linking variable for FFTW3 C programs.|
||Linking variable for FFTW3 Fortran programs.|
The following examples use the Intel compilers, though they should work using the GNU and Portland Group compilers as well.
Compiling a Fortran77 program with MKL:
ifort -c my_prog.f ifort -o my_prog my_prog.o $MKL_LIBS
Compiling a C program with MKL:
icc -c my_prog.c icc -o my_prog my_prog.o $MKL_LIBS
Compiling a module-based Fortran90/95 program with MKL:
ifort -c my_prog.f95 $MKL_F95FLAGS ifort -o my_prog my_prog.o $MKL_F95LIBS $MKL_LIBS
Compiling a C program with the double-precision FFTW2 wrapper:
icc -c $MKL_FFTW_CFLAGS -DMKL_DOUBLE my_prog.c icc -o my_prog my_prog.o $MKL_FFTW2_D_CLIBS $MKL_LIBS
Compiling a Fortran77 program with the FFTW2 wrapper:
ifort -c $MKL_FFTW_FFLAGS my_prog.f ifort -o my_prog my_prog.o $MKL_FFTW2_S_FLIBS $MKL_LIBS
Compiling a C program with the FFTW3 wrapper:
icc -c $MKL_FFTW_CFLAGS my_prog.c icc -o my_prog my_prog.o $MKL_FFTW3_CLIBS $MKL_LIBS
Compiling a Fortran program with the FFTW3 wrapper:
ifort -c $MKL_FFTW_FFLAGS my_prog.f ifort -o my_prog my_prog.o $MKL_FFTW3_CLIBS $MKL_LIBS
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
When running an MKL program, you need to be sure to take the following steps.
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:
PPNPERNODE=$(expr $(cat $PBS_NODEFILE | wc -l) / $(uniq $PBS_NODEFILE | wc -l)) export OMP_NUM_THREADS=$PPNPERNODE