Search code examples
linkerfortranopenmpintel-mkl

Link MKL statically in MPI program


I have a Fortran MPI program that uses openMP and MKL. On my personal computer I would compile with the Intel compiler by calling something like mpiifort Program.F90 -i8 -qmkl -fopenmp -o run, and then run the program as mpirun ./run.

I would like to run this program on a cluster, where I have access to Intel MPI but no other libraries. Hence I need to link MKL statically. From the Intel MKL Link Line Advisor I obtain the following,

-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl

This line is set up such that MKL will parallelize with openMP, which I want for my code. However if I try to run this code on the cluster, I get the error: error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory. Seemingly my attempt to link parallelized MKL has not been fully static, since it still tries to link dynamically. Is there any way in which I can circumvent this problem, i.e. link the openMP threaded version of MKL in a fully static way?

Thanks!


Solution

  • It seems that here is an issue while loading the shared libraries. Please use libiomp5.a as pointed out by Victor Eijkhout. It is present under /opt/intel/lib/intel64. This helps to link the openMP threaded version of MKL in a complete statical way as per your requirement.