Mac LP64 zgesv returns a wrong answer if MKL is linked statically. It seems
this only happens on I7 CPU.
If you compile and run zgesv.c (attached), you will see something like below,
but I expect x_exact == x. With MKL dynamic linking, everything seems to be ok.
$ ./zgesv
MKL Version = 10.2.3
Processor optimization : Intel Core i7 Processor
CPU frequency = 2.26 GHz
x_exact[0] = {1.000000, 0.000000}
x_exact[1] = {1.000000, 0.000000}
x_exact[2] = {1.000000, 0.000000}
info = 0
x[0] = {0.705114, 0.421455}
x[1] = {0.346944, 0.484740}
x[2] = {0.314761, -0.157588}
Test machine : MacPro 8-core 2.26GHz Nehalem.
MKL link : $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_intel_thread.a $(MKLPATH)/libmkl_core.a -L$(MKLPATH) -liomp5
Could you check this on your side? Thanks.
Jaewon
-----------------------------------------------------------------------
/* zgesv.c */
#include
#include
#include
#include "mkl.h"
#include "mkl_service.h"
#include "mkl_lapack.h"
static void print_mklinfo()
{
MKLVersion ver;
MKLGetVersion(&ver);
printf("\\nMKL Version = %d.%d.%d\\n", ver.MajorVersion, ver.MinorVersion, ver.UpdateVersion);
printf("Processor optimization : %s\\n", ver.Processor);
printf("CPU frequency = %.2f GHz\\n\\n", getcpufrequency());
}
static void run_zgesv()
{
char trans = 'N';
MKL_INT i, n = 3, nrhs = 1, lda = 3, ldb = 3, info, ipiv[3];
MKL_INT incx = 1, incy = 1;
MKL_Complex16 alpha = {1., 0.}, beta = {0., 0.}, b[3];
MKL_Complex16 a[9] = {
{-2., 1.}, {0., -1.}, {0.5, 0.25},
{1., -1.}, {-2., 1.}, {0., -1.},
{0., 0.}, {1., -1.}, {-2., 1.}};
MKL_Complex16 x_exact[3] = {{1., 0.}, {1., 0.}, {1., 0.}};
for (i = 0; i < n; i++)
printf("x_exact[%d] = {%f, %f}\\n", i, x_exact[i].real, x_exact[i].imag);
printf("\\n");
zgemv(&trans, &n, &n, &alpha, a, &lda, x_exact, &incx, &beta, b, &incy);
zgesv(&n, &nrhs, a, &lda, ipiv, b, &ldb, &info);
printf("info = %d\\n", info);
for (i = 0; i < n; i++)
printf("x[%d] = {%f, %f}\\n", i, b[i].real, b[i].imag);
printf("\\n");
}
int main()
{
print_mklinfo();
run_zgesv();
return 0;
}




