Requests for technical support from the VASP group should be posted in the VASP-forum.

Linking gfortran with Intel MKL

From Vaspwiki
Jump to navigationJump to search

To improve on the execution time VASP can be build with the GNU compiler suite in combination with Intel's Math Kernel Library [1]. This can reduce the execution time on Intel machines by a factor of 2 to 3 for typical DFT calculations.

This guide assumes that MKL is installed and the proper environment variables are set [2]. Furthermore, please note that your chosen MPI installation should be compatible with Intel MKL.

Note that following steps will yield a version of VASP without OpenMP support.

  • Extract the VASP tar ball
tar -xzvf vasp.VERSION.tar.gz 
cd vasp.VERSION
  • This example uses the GNU compilers "gfortran, gcc and g++" in combination with IntelMKL and IntelMPI.
# Precompiler options
            -DMPI -DMPI_BLOCK=8000 -Duse_collective \
            -DscaLAPACK -DCACHE_SIZE=4000 \
            -Davoidalloc -Duse_bse_te \

CPP        = gcc -E -P -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)

# make sure MKLROOT is set in your environment
FC         = mpif90 -m64 -I$(MKLROOT)/include
FCL        = mpif90 -m64 -I$(MKLROOT)/include

FREE       = -ffree-form -ffree-line-length-none 

FFLAGS     = -w 
OFLAG      = -O2 -mtune=native -m64
DEBUG      = -O0
# linking to MKL as recommended by
LLIBS      += -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_scalapack_lp64 -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl
INCS       = -I$(MKLROOT)/include/fftw

OBJECTS    = fftmpiw.o fftmpi_map.o  fftw3d.o  fft3dlib.o 

OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o

# For what used to be vasp.5.lib
CPP_LIB    = $(CPP)
FC_LIB     = $(FC)
CC_LIB     = gcc

OBJECTS_LIB= linpack_double.o getshmem.o 

# For the parser library
CXX_PARS   = g++  
LIBS       += parser
LLIBS      += -Lparser -lparser -lstdc++

# Normally no need to change this
SRCDIR     = ../../src
BINDIR     = ../../bin

Other MPI installations should be checked for compatibility to Intel MKL and the linking variable LLIBS should be adapted according to the Intel linking advisor.

  • Finally, build std, gam and ncl versions of VASP
make std gam ncl

After a successful build the corresponding executables are found in ./bin.