- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi forum,
I am sorry for posting a lame question but I am just starting to use Fortran. I translated some of my programs from MATLAB and I want to see what the improvement in speed will be. So far using ifort -O3 I can get them to run about 5 times faster and now I want to use BLAS to see if there will be further improvement.
Unfortunately, I haven't yet figured out how to link with BLAS95 correctly. I have built the BLAS95 routines with ifort and have the mkl95_blas.mod and mkl95_precision.mod in the standard dir ../lib/emt64t.
Suppose I want to run the simpliest program using just gemm:
program myprog
use mkl95_precision
use mkl95_blas
implicit none
real(8), dimension(2,2) ::a,b,c
!/ matrices defined here
call gemm(a,b,c)
end program myprog
Could you please tell me which options (-L, -I paths, libraries) should I invoke with ifort to get it working (I only want BLAS95 for a start). Because I am lost as I always get the error:
/tmp/ifortbs5xfm.o: In function `MAIN__':
myprog.f90:(.text+0x204): undefined reference to `dgemm_mkl95_'
Hope somebody will help me get started
Cheers,
Tomasz
I am sorry for posting a lame question but I am just starting to use Fortran. I translated some of my programs from MATLAB and I want to see what the improvement in speed will be. So far using ifort -O3 I can get them to run about 5 times faster and now I want to use BLAS to see if there will be further improvement.
Unfortunately, I haven't yet figured out how to link with BLAS95 correctly. I have built the BLAS95 routines with ifort and have the mkl95_blas.mod and mkl95_precision.mod in the standard dir ../lib/emt64t.
Suppose I want to run the simpliest program using just gemm:
program myprog
use mkl95_precision
use mkl95_blas
implicit none
real(8), dimension(2,2) ::a,b,c
!/ matrices defined here
call gemm(a,b,c)
end program myprog
Could you please tell me which options (-L, -I paths, libraries) should I invoke with ifort to get it working (I only want BLAS95 for a start). Because I am lost as I always get the error:
/tmp/ifortbs5xfm.o: In function `MAIN__':
myprog.f90:(.text+0x204): undefined reference to `dgemm_mkl95_'
Hope somebody will help me get started
Cheers,
Tomasz
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tomasz and all others
I seem to have the same background and be in the same situation as Tomasz, and I only saw his post after I had completed my own, which I allow myself to post in this thread.
I have tried long and hard to link my own Fortran 95 program with the BLAS and LAPACK implementations of the Intel MKL 10.0.3.020, but without success.
This is an excerpt from my program:
program main
use mkl95_blas
use mkl95_lapack
implicit none
integer,parameter::dp=kind(1.0d0)
real(kind=dp),dimension(10)::test,test2
integer::i
test1 = (/ (i*1.d0,i=1,10) /)
test2 = 0
call copy(test1,test2)
end program main
When I compile I get the following error:
/home/tjoff/programming/fortran/workspace/Liftlin/src/Main.f90:120: undefined reference to `dcopy_mkl95_'
make: *** [all] Error 1
Excerpt from my Makefile:
MKLPATH = /opt/intel/mkl/10.0.3.020/lib/em64t
MKLINCLUDE = /opt/intel/mkl/10.0.3.020/include
all:
ifort -o a.out main.f90 $(LINKFLAGS)
where i have tried various values for $(LINKFLAGS), e.g.
LINKFLAGS = -L$(MKLPATH) -I$(MKLINCLUDE) -lmkl_lapack95
-Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a
$(MKLPATH)/libmkl_intel_thread.a $(MKLPATH)/libmkl_core.a -Wl,--end-group
-lguide -lpthread
which according to the Users guide should be "static linking of user code myprog.f, Fortran 90 LAPACK interface1, and parallel Intel
MKL supporting LP64 interface", which i suppose is what I want.
I have tried both static and dynamic linking as given in the Users guide, but it all results in the above error.
I have checked the following:
- ifort runs perfectly
- in my .bashrc file I have the line
source /opt/intel/mkl/10.0.3.020/tools/environment/mklvarsem64t.sh
and the environment variables all seem right to me
- The instructions in the User Guide section "Fortran 90 Interfaces and Wrappers to LAPACK and BLAS" have been followed, and the directory /opt/intel/mkl/10.0.3.020/include contains
the files mkl95_blas.mod, mkl95_lapack.mod and mkl95_precision.mod as well as some .f77, f.90 and .h files.
The directory /opt/intel/mkl/10.0.3.020/lib/em64t also contains mkl95_blas.mod, mkl95_lapack.mod and mkl95_precision.mod as well as all the .a and .so files.
I will be very grateful for any hints
regards, Jakob
I seem to have the same background and be in the same situation as Tomasz, and I only saw his post after I had completed my own, which I allow myself to post in this thread.
I have tried long and hard to link my own Fortran 95 program with the BLAS and LAPACK implementations of the Intel MKL 10.0.3.020, but without success.
This is an excerpt from my program:
program main
use mkl95_blas
use mkl95_lapack
implicit none
integer,parameter::dp=kind(1.0d0)
real(kind=dp),dimension(10)::test,test2
integer::i
test1 = (/ (i*1.d0,i=1,10) /)
test2 = 0
call copy(test1,test2)
end program main
When I compile I get the following error:
/home/tjoff/programming/fortran/workspace/Liftlin/src/Main.f90:120: undefined reference to `dcopy_mkl95_'
make: *** [all] Error 1
Excerpt from my Makefile:
MKLPATH = /opt/intel/mkl/10.0.3.020/lib/em64t
MKLINCLUDE = /opt/intel/mkl/10.0.3.020/include
all:
ifort -o a.out main.f90 $(LINKFLAGS)
where i have tried various values for $(LINKFLAGS), e.g.
LINKFLAGS = -L$(MKLPATH) -I$(MKLINCLUDE) -lmkl_lapack95
-Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a
$(MKLPATH)/libmkl_intel_thread.a $(MKLPATH)/libmkl_core.a -Wl,--end-group
-lguide -lpthread
which according to the Users guide should be "static linking of user code myprog.f, Fortran 90 LAPACK interface1, and parallel Intel
MKL supporting LP64 interface", which i suppose is what I want.
I have tried both static and dynamic linking as given in the Users guide, but it all results in the above error.
I have checked the following:
- ifort runs perfectly
- in my .bashrc file I have the line
source /opt/intel/mkl/10.0.3.020/tools/environment/mklvarsem64t.sh
and the environment variables all seem right to me
- The instructions in the User Guide section "Fortran 90 Interfaces and Wrappers to LAPACK and BLAS" have been followed, and the directory /opt/intel/mkl/10.0.3.020/include contains
the files mkl95_blas.mod, mkl95_lapack.mod and mkl95_precision.mod as well as some .f77, f.90 and .h files.
The directory /opt/intel/mkl/10.0.3.020/lib/em64t also contains mkl95_blas.mod, mkl95_lapack.mod and mkl95_precision.mod as well as all the .a and .so files.
I will be very grateful for any hints
regards, Jakob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you build the Fortran 95 wrapper files (for BLAS) you should get these three files
libmkl_blas95.a
mkl95_blas.mod
mkl95_precision.mod
If you move the "*.mod" files to /opt/intel/mkl/include and the "*.a" file to /opt/intel/mkl/lib/32 then you simply use
ifort -I/opt/intel/mkl/include my_example.f90 -L/opt/intel/mkl/lib/32 -lmkl_blas95 -lmkl -lguide -lpthread
Btw Matlab (specially under windoze) also seems to use MKL underneath so you may not see large speedups wrt to blas/lapack calls. See http://www.mathworks.com/support/solutions/data/1-JDIO3.html?solution=1-JDIO3
libmkl_blas95.a
mkl95_blas.mod
mkl95_precision.mod
If you move the "*.mod" files to /opt/intel/mkl/include and the "*.a" file to /opt/intel/mkl/lib/32 then you simply use
ifort -I/opt/intel/mkl/include my_example.f90 -L/opt/intel/mkl/lib/32 -lmkl_blas95 -lmkl -lguide -lpthread
Btw Matlab (specially under windoze) also seems to use MKL underneath so you may not see large speedups wrt to blas/lapack calls. See http://www.mathworks.com/support/solutions/data/1-JDIO3.html?solution=1-JDIO3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot tabrezali! I tried your advice, and now both BLAS and LAPACK are working for me:
ifort -o a.out main.f90 -I/opt/intel/mkl/10.0.3.020/include -L/opt/intel/mkl/10.0.3.020/lib/em64t -lmkl_blas95 -lmkl_lapack95 -lmkl -lguide -lpthread
It seems that I was missing before was the -lmkl option.
Again, thanks for answering, it was really helpful.
Best regards, Jakob
ifort -o a.out main.f90 -I/opt/intel/mkl/10.0.3.020/include -L/opt/intel/mkl/10.0.3.020/lib/em64t -lmkl_blas95 -lmkl_lapack95 -lmkl -lguide -lpthread
It seems that I was missing before was the -lmkl option.
Again, thanks for answering, it was really helpful.
Best regards, Jakob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you sure your lapack95 calls are working correctly because I think it is more like "-lmkl_lapack95 -lmkl_lapack ...".
Basically the 95 stuff just gets added before what you need otherwise. Playing around or refering the docs will get you there.
Basically the 95 stuff just gets added before what you need otherwise. Playing around or refering the docs will get you there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot, works beautifully now! It looks like the Intel Fortran Compiler matrix multiplication is quite good on its own, as I don't see that much improvement from using MKL. But on the whole the program runs significantly faster then in MATLAB (much faster for loops, similar for matrix multiplications).
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page