- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a very simple test file for calling dgemv in my C-Application: useblas.c
I compile and link it in this way:
icc -I/opt/intel/Compiler/11.1/069/mkl/include -g -c useblas.c
ifort -nofor_main -L/opt/intel/Compiler/11.1/069/mkl/lib/intel64 -lpthread -openmp -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -g useblas.o -lm
When executing the a.out file i get a segmentation fault in line 27 (which is the function call of dgemv):
Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaaba31f7 in dgemv_ ()
from /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_lp64.so
(gdb) bt
#0 0x00002aaaaaba31f7 in dgemv_ ()
from /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_lp64.so
#1 0x00000000004012c5 in main () at useblas.c:27
My code was running on: Intel Xeon CPU X7460 @ 2.66GHz.
A ldd give me the following:
$ ldd a.out
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003921000000)
libmkl_intel_lp64.so => /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_lp64.so (0x00002aaaaaad6000)
libmkl_intel_thread.so => /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_thread.so (0x00002aaaaaed0000)
libmkl_core.so => /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_core.so (0x00002aaaabf35000)
libm.so.6 => /lib64/libm.so.6 (0x0000003920800000)
libiomp5.so => /opt/intel/Compiler/11.1/069/lib/intel64/libiomp5.so (0x00002aaaac2f4000)
libc.so.6 => /lib64/libc.so.6 (0x0000003920400000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003925c00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003920c00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003920000000)
What's wrong? Or is there Bug? Btw, the same code works fine with "AMD Core Math Library (ACML)" and the intel compiler.
Cheers,
Tim
I have a very simple test file for calling dgemv in my C-Application: useblas.c
I compile and link it in this way:
icc -I/opt/intel/Compiler/11.1/069/mkl/include -g -c useblas.c
ifort -nofor_main -L/opt/intel/Compiler/11.1/069/mkl/lib/intel64 -lpthread -openmp -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -g useblas.o -lm
When executing the a.out file i get a segmentation fault in line 27 (which is the function call of dgemv):
Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaaba31f7 in dgemv_ ()
from /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_lp64.so
(gdb) bt
#0 0x00002aaaaaba31f7 in dgemv_ ()
from /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_lp64.so
#1 0x00000000004012c5 in main () at useblas.c:27
My code was running on: Intel Xeon CPU X7460 @ 2.66GHz.
A ldd give me the following:
$ ldd a.out
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003921000000)
libmkl_intel_lp64.so => /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_lp64.so (0x00002aaaaaad6000)
libmkl_intel_thread.so => /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_intel_thread.so (0x00002aaaaaed0000)
libmkl_core.so => /opt/intel/Compiler/11.1/069/mkl/lib/intel64/libmkl_core.so (0x00002aaaabf35000)
libm.so.6 => /lib64/libm.so.6 (0x0000003920800000)
libiomp5.so => /opt/intel/Compiler/11.1/069/lib/intel64/libiomp5.so (0x00002aaaac2f4000)
libc.so.6 => /lib64/libc.so.6 (0x0000003920400000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003925c00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003920c00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003920000000)
What's wrong? Or is there Bug? Btw, the same code works fine with "AMD Core Math Library (ACML)" and the intel compiler.
Cheers,
Tim
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tim,
please try C intreface of dgemv (cblas_dgemv )
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Gennady,
thanks for the hint. Using the C interface works fine. But why cant i use the Fortran lib directly. And why does this work with acml?
Cheers,
Tim
thanks for the hint. Using the C interface works fine. But why cant i use the Fortran lib directly. And why does this work with acml?
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Calling the Fortran library from C is possible but the calling conventions are not the same. See the Mixed Language Programming chapters in the Intel Fortran Users' Guide.
Depending on the compilers and platform used, it may be possible to make it appear as if you are calling one library routine from either C or Fortran. For example, if in C you have dgemv(...), in the compiled code there may be a reference to _dgemv, where as a corresponding call in Fortran may result in a reference to _DGEMV. The linker matches up the reference with the appropriate library routine. Users who know only one of the two languages may find this method easier to use.
On the other hand, one may want the Fortran library routine to be called directly from C, without going through a C wrapper around the Fortran library routine. In this case, one has to know how the two languages correspond as to types, call by value/call by reference, etc.
Depending on the compilers and platform used, it may be possible to make it appear as if you are calling one library routine from either C or Fortran. For example, if in C you have dgemv(...), in the compiled code there may be a reference to _dgemv, where as a corresponding call in Fortran may result in a reference to _DGEMV. The linker matches up the reference with the appropriate library routine. Users who know only one of the two languages may find this method easier to use.
On the other hand, one may want the Fortran library routine to be called directly from C, without going through a C wrapper around the Fortran library routine. In this case, one has to know how the two languages correspond as to types, call by value/call by reference, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem is that Fortran expects call by reference and some of your parameters to DGEMV are call-by-value. Changing your BLAS call to:
dgemv("N", &m, &n, α, a, &n, x, &one, β, y, &one);
works fine.
dgemv("N", &m, &n, α, a, &n, x, &one, β, y, &one);
works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the Fortran Lapack routines are called directly from C, it should be kept in mind that C and Fortran have different conversions for representing two-dimensional arrays. The difference may not matter if a full, symmetric matrix is being passed but, in all other cases, care is necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would throw my 2 cents in this discussion: Tim, as an additional info please look at the MKL User'sGuide. See Chapter7,Mixed-language Programming with Intel MKL. You can find there link to the 2 examples ( 7.2 and 7.3) show how to call Fortran routines fromC-languageprograms.
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the detailed information and explanations. Now I understood how to use the MKL in the correct way. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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