# Intel MKL - Difference between mkl_intel_lp64 and mkl_gf_lp64

I am currently trying to link a program against the Intel MKL 11.0 library instead of using NetLIB or OpenBLAS. Doing this I recognized the following error which I can not explain to my self at the moment. Consider the following C code example computing a complex scalar product using zdotc:

#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
double complex zdotc_(int *n, double complex *X, int *incx, double complex *Y, int *INCY );
int main ( ) {
int n = 5;
int incx = 1, incy = 1;
double complex x[5] = {1,I,2,2+I,3};
double complex y[5] = {I,3,I*3, 2+2*I, 9};
double complex ret;
ret = zdotc_(&n,x,&incx,y,&incy);
printf("n   = %d\n", n);
printf("ret = %lg + %lgi\n", creal(ret), cimag(ret));
return 0;
}

I compiled this example using the command line flags given by the MKL Advisor. I select "GNU C/C++, 32 Bit Integer, Dynamic Linking, GNU OpenMP". The resulting command line is:

gcc zdotc_test.c -o zdot_mkl_gcc -O2  -L$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm -fopenmp -m64 -I$MKLROOT/include

The output of this program is:

n   = 0
ret = 0 + 1.07933e+21i

which is obviously wrong and especially why is n altered?

If I select GNU Fortran instead of GNU C/C++, I have to replace -lmkl_intel_lp64 by -lmkl_gf_lp64 and then the correct output

n   = 5
ret = 33 + 6i

is produced.

So my question is: where are the detailed differences between those to interfaces and why does the first one produced this error?

-
You probably want to use the C interface instead of the Fortran one (it comes with MKL) as it has far fewer portability issues. For the Fortran interface you would have to deal with the Fortran calling convention, which varies with platform and compiler. – Rufflewind Jul 2 '14 at 0:38