Linking order, why does it Matters?

Linking order, why does it Matters?

I compiled using the commands:

ifort -i_dynamic ../Bands.f90 -L/opt/mkl72/lib/32/ -lmkl_lapack64 -lmkl_ia32 -lmkl_lapack32
AND
ifort -i_dynamic ../Bands.f90 -L/opt/mkl72/lib/32/ -lmkl_lapack32 -lmkl_ia32 -lmkl_lapack64

getting a lot of 'undefined references' related with mkl_lapack32 for the first command and with mkl_lapack64 for the second. instead when writing:

ifort -i_dynamic ../Bands.f90 -L/opt/mkl72/lib/32/ -lmkl_lapack32 -lmkl_lapack64 -lmkl_ia32

it compiles very nice. Why is that? where can I find a short explanation about such kind of interdependences or options that shouldn't be used together?. Finally which would be the most complete command that a common student, as I am, should use in order to link all the available Lapack subroutines once and for all (needed or not) in a pentium 4 computer, in order to get the maximum performance?.

Message Edited by xavmontoya on 12-16-2004 08:01 AM

3 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

The notes which come with MKL should include some working examples, but maybe not much explanation of reasons. You are responsible for choosing the MKL libraries built for the same ABI as your compilation (apparently all 32-bit, in your example). There is no possibility of a mixture of libraries working together, e.g. Itanium and 32-bit. lapack depends on BLAS, and all BLAS functions are in the mkl library, so the libraries are specifically designed to link in that order.
Apparently, you are not running the x86_64 system, where ld checks architecture types in the libraries, and automatically skips over functions which don't match the requirement.

The Linux linker makes a single pass through libraries. Since LAPACK functions make calls to the BLAS the libraries which contain BLAS must be on the link line after the LAPACK libraries. So the third option you mention works correctly since the BLAS functions are in libmkl_ia32.a.

In the message above tim18 talks about Itanium vs 32-bit libraries. In fact all the libraries you are calling are 32-bit libraries because of your use of "-L/opt/mkl72/lib/32/". This directory contains only 32-bit libraries. The number '64' in the mkl_lapack64 does NOT refer to the Itanium architecture, but rather to the fact that this library contains double precision (64-bits)LAPACK functions.

If you want to link all LAPACK functions you can either do it dynamically and reference the following

libmkl_lapack64.so (or -lmkl_lapack64) - contains double prec. LAPACK
libmkl_lapack32.so (or -lmkl_lapack32) - contains single prec. LAPACK
libmkl.so (or -lmkl) - contains BLAS

or you can link statically and reference the following

libmkl_lapack.a (or -lmkl_lapack) - contains LAPACK
libmkl_ia32.a (or -lmkl_ia32) - contains BLAS

or some combination (you happen to be linking LAPACK dynamically and BLAS statically). As mentioned, in all cases LAPACK libraries must appear before the BLAS library. The third link line you mention shouldbe successful for allLAPACK and BLAS functions.

Todd

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!