Should I expect different behaviour of cblas_zdotc_sub from the libmkl_intel_lp64 and libmkl_gf_lp64 libraries? The latter gives me an unexpected result. Please see the attached program. I get
$ gcc testjuliamkl.c -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -L /opt/intel/mkl/lib/intel64/ -lpthread -lm -ldl -Wl,-rpath=/opt/intel/mkl/lib/intel64/
$ gcc testjuliamkl.c -lmkl_gf_lp64 -lmkl_core -lmkl_sequential -L /opt/intel/mkl/lib/intel64/ -lpthread -lm -ldl -Wl,-rpath=/opt/intel/mkl/lib/intel64/
and the same happens if I use icc.
Both libmkl_gf_lp64 and libmkl_intel_lp64 are LP64 interface library, but mkl_intel_lp64 is for the Intel compilers and GCC compiler, while libmkl_gf_lp64.a is only for GUN fortran compiler. So the combination gcc + mkl_gf_lp64 doesn't give valid result.
The link advisor <<http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor>> may be helpful on these complex combination.
sorry to resurrect such an old post but I don't understand where the problem is. This a C code making a call to CBLAS function which has nothing to do with the Fortran compiler and the BLAS Fortran interface. Can anybody provide more insight on this problem?
More generally, if I have a mixed C and Fortran code with calls to CBLAS in the C part and call to standard BLAS in the Fortran part, is it safe to link with libmkl_gf_lp64 when gcc+gfortran are used?
It's not clear whether you have assured that the gfortran libraries have been linked for the mkl_gf case, as well as linking with gcc -fopenmp or some other means of assuring that libgomp is in use rather than libiomp5. If you would show your ldd results, we might be able to rule out some possible problems in that area.
thanks for your response.
I am not concerned about OpenMP; to make things simple, we can actually limit the discussion to the case where sequential MKL is used.
As far as I understand, the difference between libmkl_intel_lp64 and libmkl_gf_lp64 comes from the different ways that gfortran and ifort handle subroutines/functions arguments and results. Because CBLAS routines are supposed to be called in a C code, I would expect the CBLAS interface to be the same in libmkl_intel_lp64 and libmkl_gf_lp64. As a result, the code posted by Andreas Jensen should work if linked with either libmkl_intel_lp64 or libmkl_gf_lp64 using either icc or gcc. Is this correct?
Now, to go back to my previous question. Assume I have the three files attached. As you can see, in f_sub there is a call to a BLAS routine, in c_sub there is a call to a CBLAS routine and the main program calls both f_sub and c_sub. I compile compile f_sub.f90 using gfortran and c_sub.c using gcc. Now, if I link like this
gcc main_c.c f_sub.o c_sub.o -L$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lm -lgfortran
I have a segfault in f_sub which I understand because f_sub compiled with gofrtran, uses the BLAS ifort interface. If, instead, I link like this
gcc main_c.c f_sub.o c_sub.o -L$MKLROOT/lib/intel64 -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lm -lgfortran
everything works fine although, according to what said by Andreas and Ying above, it shouldn't ecause I should get a wrong result in c_sub.
Can you help me make some sense out of all this?