Building GROMACS with Intel mkl

GROMACS version: 2019.6
GROMACS modification: No

Greetings,

I am having an issue on building gromacs with intel mkl libraries (both 2020 and 2018 versions).
I’ve installed the Intel parallel studio xe on ubuntu 18.04 as root (in /opt/intel directory) and I’ve sourced the psxevars.sh, mklvars.sh and compilervars.sh and also added mkl library paths to LD_LIBRARY_PATH variables.
But in building process of gromacs (using cmake command) it raises an error in which it does not able to recognize mkl libraries. It says that it could not find “DftiCreateDescriptor”.
by the way I used gcc/g++ compilers in the build process

Here is the last lines of CMAKEERROR file
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_392d6.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=DftiCreateDescriptor CMakeFiles/cmTC_392d6.dir/CheckFunctionExists.c.o -o cmTC_392d6
CMakeFiles/cmTC_392d6.dir/CheckFunctionExists.c.o: In function main': CheckFunctionExists.c:(.text+0x10): undefined reference to DftiCreateDescriptor’
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_392d6.dir/build.make:97: recipe for target ‘cmTC_392d6’ failed
make[1]: *** [cmTC_392d6] Error 1
make[1]: Leaving directory ‘/home/alisufali/Softwares/gromacs-2019.6/build2/CMakeFiles/CMakeTmp’
Makefile:126: recipe for target ‘cmTC_392d6/fast’ failed
make: *** [cmTC_392d6/fast] Error 2

You manually have to specify MKL_LIBRARIES if you want to use GROMACS with GCC+MKL. cmake should have said

Linking with MKL was requested, but was not successful: The include path to
mkl.h in MKL_INCLUDE_DIR, and the link libraries in MKL_LIBRARIES= need to
match what the MKL documentation says you need for your system: Use full
paths to library files, in the right order, and separated by semicolons.

See also https://gitlab.com/gromacs/gromacs/-/issues/3557

so to build GROMACS with intel mkl it will be much easier to build it with intel icc and icpc compilers (in non-mpi mode)?
I tried the first time to build gromacs with intel compilers but cuda 10.2 had a big problem with it.

Yes using MKL is only easy together with ICC for GROMACS. You need to use ICC 19.1 to compile all of GROMACS with CUDA. Because CUDA only support <=19.1 and GROMACS only >=19.1. You can also use CUDA_HOST_COMPILER to use a different compiler for the CUDA files.

If you want to use GCC+MKL you can get the required linker flags from the MKL link advisor: https://software.intel.com/content/www/us/en/develop/articles/intel-mkl-link-line-advisor.html