Beginner's problems with example programs

Beginner's problems with example programs

OS: Fedora linux 16
Arch: Intel 64 bits (core 2 duo)
Compiler prod. (from ifort -V): Intel Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.4.319 Build 20120410

A very basic and nave question, from an absolute beginner on MKL...
I need access to lapack (or lapack95) routines in order to implement another routine that evaluates the Whittaker function. Since the Composer XE pack provides the lapack routines with the MKL, I decided to try it.
Problem is, I never used MKL before...

So, I took a look around and found both in the MKL user guide and in this sticky thread:
http://software.intel.com/en-us/forums/showthread.php?t=82826&o=a&s=lr
that the simplest way to link with MKL libraries is to simply use the -mkl option.
With the intention to test the access, I'm trying to compile and link the program geevab.f90, which can be found in the $MKLROOT/examples directory.

Using only the aforementioned compiler option, the program compiles all right, but the linking fails:
$ifort geevab.f90 -mkl
/tmp/ifortuA610Z.o: In function `MAIN__':
geevab.f90:(.text+0x7a9): undefined reference to `sgeev_mkl95_'
geevab.f90:(.text+0xe97): undefined reference to `cgeev_mkl95_'

The error is exactly the same if I employ the dynamic linking model referred in the thread:
ifort -mkl geevab.f90 -lmkl_rt -o geevab

Using the Link Line Advisor, the result is even worse. The compilation line I used, suggested by the advisor, is:
ifort -i8 -I$(MKLROOT)/include/intel64/ilp64 -I$(MKLROOT)/include geevab.f90 $(MKLROOT)/lib/intel64/libmkl_lapack95_ilp64.a -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_ilp64.a $(MKLROOT)/lib/intel64/libmkl_sequential.a $(MKLROOT)/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -o geevab

In this case, I get even more error messages.

What am I doing wrong? Do I have to first generate the libraries before being able to actually use them? I assumed that they were already provided, along with the rest of the compiler system.

Thanks.

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

If you follow literally the link advisor recommendation for static linkage, you must assure that MKLROOT (if you spelled it that way) is set to point to where MKL include files and libraries are installed. With recent ifort versions, the compilers environment script should take care of it (check spelling). If your error messages mention that name, it must not be set correctly.
You couldn't use -mkl with -i8, as that would choose lp64 include and library files (32-bit integers in BLAS and LAPACK calls). If you switch -i8 on and off, you must recompile everything, but in your Fortran source, where you specify integer size explicitly, -i8 won't take effect.
-lpthread -lm should be superfluous.
Dynamic library linking is easier to get started. You don't need to write out so much stuff with possibility of typos.
If you wrote your link line literally the way you have quoted, you would need to add \ at the end of the first 2 lines.
As you can see, it gets cumbersome to try to answer your question without more specifics.

Thank you for your prompt reply.

Quoting TimP (Intel)
If you follow literally the link advisor recommendation for static linkage, you must assure that MKLROOT (if you spelled it that way) is set to point to where MKL include files and libraries are installed. With recent ifort versions, the compilers environment script should take care of it (check spelling). If your error messages mention that name, it must not be set correctly.
You couldn't use -mkl with -i8, as that would choose lp64 include and library files (32-bit integers in BLAS and LAPACK calls). If you switch -i8 on and off, you must recompile everything, but in your Fortran source, where you specify integer size explicitly, -i8 won't take effect.
-lpthread -lm should be superfluous.
Dynamic library linking is easier to get started. You don't need to write out so much stuff with possibility of typos.
If you wrote your link line literally the way you have quoted, you would need to add \ at the end of the first 2 lines.
As you can see, it gets cumbersome to try to answer your question without more specifics.

In fact, it all came down to a typo. The advisor suggested the compiler and linker options citing the environment variable as ($MKLROOT). All I had to do was to remove the parentheses:

$ifort -i8 -I$MKLROOT/include/intel64/ilp64 -I$MKLROOT/include geevab.f90 $MKLROOT/lib/intel64/libmkl_lapack95_ilp64.a -Wl,--start-group $MKLROOT/lib/intel64/libmkl_intel_ilp64.a $MKLROOT/lib/intel64/libmkl_sequential.a $MKLROOT/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -o geevab

worked all right. Thanks for pointing this out.
I'll try and use these options now to compile the whittaker function routine.

But again, it would be much nicer if I could do everything using a (much) smaller number of compiler and linker options. Why do you think my first attempts using the -mkl and -lmkl_rt options were unsuccessful?

Faça login para deixar um comentário.