Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Starting with mkl

renepreto
Beginner
782 Views

Hi mkl users! I've just installed mkl under fedora 9 and I have some codes that i would like to run using mkl libraries, so I have to know how to do it properly. I have tried the following example:

Program Teste

implicit none

integer n,i,incx,incy
parameter (n=4, incx=1,incy=1)
real x(n), y(n), res, sdot
external sdot

do i=1,n
x(i)=i
y(i)=2*i
enddo

res=sdot(n,x,incx,y,incy)

print*, 'sdot =',res
open (unit=1, file='resultado', status='unknown')

write(1,*)res

end

but when I try

ifort -L/opt/intel/mkl/10.0.5.025/lib/em64t teste.for

[rene@Rene Teste mkl]$ ifort -L/opt/intel/mkl/10.0.5.025/lib/em64t teste.for
/tmp/ifortF8bXCF.o: In function `MAIN__':
teste.for:(.text+0x96): undefined reference to `sdot_'

I've heard that I schould try

ifort -L/opt/intel/mkl/10.0.5.025/lib/em64t -l'librarie name' teste.for

but how do I know what the librarie name? there is no sdot there? is there an easier way?

Thanks

0 Kudos
5 Replies
Gennady_F_Intel
Moderator
782 Views

1.Hello, please try to use the following building command line:

ifort -w test.f ${MKLROOT}/libmkl_intel_lp64.a -Wl,--start-group ${MKLROOT}/libmkl_intel_thread.a ${MKLROOT}/libmkl_core.a -Wl,--end-group -L${MKLROOT} -liomp5 -lpthread -o test.out

where for example MKLPATH=/opt/intel/mkl/10.0.5.025/lib/em64t

2. more info about the MKL linking models, examples and so , you can find into userguide manual.

--Gennady

0 Kudos
renepreto
Beginner
782 Views

Hey! thanks for the answer, but when I try to open the test.out it shows the following error

error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory

but if I try the command line without the -liomp5, everything is ok! what does this lib do? thanks, and i've got the userguide and reading it already!

0 Kudos
TimP
Honored Contributor III
782 Views
Quoting - renepreto

error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory

but if I try the command line without the -liomp5, everything is ok! what does this lib do? thanks, and i've got the userguide and reading it already!

If you don't use any OpenMP threaded functions, or use the sequential stub library in place of the thread library, you don't require the OpenMP library. When you link against the OpenMP shared library, the LD_LIBRARY_PATH setting is required to find it at run time. Depending on your mkl version, there would be mklvars scripts to set the PATH variables, or (in the latest Intel compilers) it would be included in the corresponding compiler environment setting scripts.

0 Kudos
renepreto
Beginner
782 Views

thanks again! I've read this in the userguide but i am not really sure what to do. i am using mkl 10.0.5.025 and ifort 10.1.018. may someone explain me with more details?

0 Kudos
TimP
Honored Contributor III
782 Views
Quoting - renepreto

thanks again! I've read this in the userguide but i am not really sure what to do. i am using mkl 10.0.5.025 and ifort 10.1.018. may someone explain me with more details?

Running both the ifortvars script in the Fortran installation, and the mklvars script in the MKL installation, will set all the PATH variables required by those products.

0 Kudos
Reply