Community
cancel
Showing results for 
Search instead for 
Did you mean: 
comput
Beginner
173 Views

Link errors for MKL function from mkl_scalapack.h with C++

Jump to solution


Hello,
I hope you could help please in this problem.
I try to compile a small C++ function that calls the MKL function "pdgesvd" from the header "mkl_scalapack.h".
The C++ code is:

#include "mkl_scalapack.h"
int main()
{
// defining the variables ...

    pdgesvd(jobu, jobvt, m, n,
            a, ia, ja, desca,
            s, u, iu, ju, descu,
            vt, ivt, jvt, descvt,
            work, lwork, info);

    return 0;
}

The link fails with the errors in the attached file "link_errors.pdf".

I have run the script:
source /intel/bin/compilervars.sh -arch intel64 -platform linux

I got the compilation/link options from the online "Intel® Math Kernel Library Link Line Advisor" (the options attached in the snapshot intel_advisor.jpg) and compiling as below:

g++ -O main.cpp \
-DMKL_ILP64 -m64 -I${MKLROOT}/include \
${MKLROOT}/lib/intel64/libmkl_scalapack_ilp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_cdft_core.a ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group -liomp5 -lpthread -lm -ldl

I would appreciate any assistance,

Thank you.

0 Kudos
1 Solution
Ying_H_Intel
Employee
173 Views

Hi Comput,

​The link errors are mainly MPI related symbols.  You can resolve them by adding MPI runtime library in the command line. For example, if you use Intel MPI

source /opt/intel/bin/compilervars.sh intel64
source /opt/intel/impi/201x.x.0xx/intel64/bin/mpivars.sh  (replace the x with your MPI version)

mpiicc  -DMKL_ILP64 -m64 -I${MKLROOT}/include  -Wl,--start-group  "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_blacs_intelmpi_ilp64.a "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_intel_ilp64.a "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_core.a "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_intel_thread.a -Wl,--end-group -L "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/../compiler/lib/intel64" -liomp5 -mt_mpi -lm -ldl

​Best Regards,
​Ying

View solution in original post

4 Replies
Ying_H_Intel
Employee
174 Views

Hi Comput,

​The link errors are mainly MPI related symbols.  You can resolve them by adding MPI runtime library in the command line. For example, if you use Intel MPI

source /opt/intel/bin/compilervars.sh intel64
source /opt/intel/impi/201x.x.0xx/intel64/bin/mpivars.sh  (replace the x with your MPI version)

mpiicc  -DMKL_ILP64 -m64 -I${MKLROOT}/include  -Wl,--start-group  "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_blacs_intelmpi_ilp64.a "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_intel_ilp64.a "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_core.a "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64"/libmkl_intel_thread.a -Wl,--end-group -L "/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/../compiler/lib/intel64" -liomp5 -mt_mpi -lm -ldl

​Best Regards,
​Ying

View solution in original post

comput
Beginner
173 Views

Hello Ying,
Thank you for your reply.

I tried as you suggested and it compiles now:
source /intel/compilers_and_libraries_2018.3.222/linux/mpi/intel64/bin/mpivars.sh
source /intel/bin/compilervars.sh -arch intel64 -platform linux
 

g++ -O main.cpp \
-DMKL_ILP64 -m64 -I${MKLROOT}/include \
${MKLROOT}/lib/intel64/libmkl_scalapack_ilp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_cdft_core.a ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group -liomp5 -lpthread -lm -ldl -L/intel/compilers_and_libraries_2018.3.222/linux/mpi/intel64/lib -lmpi_mt

However the MPI library is dynamic, not static.

I had tried all the above commands (including the mpivars.sh) before posting to the forum, but I had tried linking with the static libmpi_mt.a instead of the dynamic libmpi_mt.so and it was giving link errors. It still gives those link errors with the static MPI library.


Namely, if instead of the dynamic MPI library:
-L/intel/compilers_and_libraries_2018.3.222/linux/mpi/intel64/lib -lmpi_mt

using instead the static one, that gives link errors:
/intel/compilers_and_libraries_2018.3.222/linux/mpi/intel64/lib/libmpi_mt.a
I think this is not important, but I attach anyway those errors in the file "static_mpi_link_errors.pdf" just in case it is useful to know.

It is not a problem for me to use the dynamic MPI library as long as the dynamic MPI library would not give errors on run-time (the same errors with the static MPI library).
From a quick run with all the pointer arguments of the function "pdgesvd" set to zero, it runs without any link errors. Only it gives a segmentation fault, which is expected since the arguments are set to zero at the moment (I need some time to study the arguments from the manual).

I think the problem is solved.
I would let you know if there is any difference on the run-time.

Best regards and thank you very much for your help.

Ying_H_Intel
Employee
173 Views

Hello Comput, 

You are welcomed.  About the static link, for intel mpi .  Generally, we use the    mpicc   xxx -static_mpi   and let them to help find needed libraries, include mpi's static librares. 

for example,  we have mkl  cluster sample under mkl install folder (you can test them too).  

[yhu5@hsw-ep01 pblasc]$ mpicc   -o pblas1_d_example source/pblas1_d_example.c -L/opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64  -L/opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64 -Wl,--start-group /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_scalapack_lp64.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_sequential.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_core.a -Wl,--end-group -static_mpi -lpthread -lm -ldl

and if you use gcc directly, then you have to add all needed libraries manually, for example

gcc   -o pblas1_d_example source/pblas1_d_example.c -L/opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64  -L/opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64 -Wl,--start-group /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_scalapack_lp64.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_sequential.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread /opt/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/lib/libmpi_mt.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/lib/libmpigi.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/lib/libmpigf.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/lib/libmpicxx.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/lib/libmpigc4.a /opt/intel/compilers_and_libraries_2018.2.199/linux/mpi/intel64/lib/libmpifort.a -lm -ldl -lrt

Best Regards,
Ying 

comput
Beginner
173 Views

This is useful to know, thank you.
Best regards,
Compute

Reply