Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6977 Discussions

incorrect results using MKL (getrf and getrs)

Danesh_Daroui
Beginner
438 Views
Dear reader,

I am performing very simple tests to port our code to MKL. At the moment we are using GMM++ free library. I have created a small 6x6 complex and non-symmetric matrix which is attached to this post as MATLAB format. I have tested to solve "Mx=b" where "b" is just a 6x1 vector of ones. The results from GMM++ is correct as expected and matches with results from MATLAB but MKL results are far different and incorrect. In my test, I directly read data from GMM++ matrix and put in in column-major format and then call MKL as below:



[cpp]Msize=6;

for (int i=0; i for (int j=0; j MKL_M[j*Msize+i]=M(i, j);

// MKL solution to solve "YV=I" matrix equation
int info;
int ipiv[Msize];
int nrhs=1;
char transa='N';

zgetrf(&Msize, &Msize, MKL_M, &Msize, ipiv, &info);
zgetrs(&transa, &Msize, &nrhs, MKL_M, &Msize, ipiv, &x[0], &Msize, &info);[/cpp]

I have checked my code and everything seems to be OK! Do you find any error in my code? By the way, I know that the coefficient matrix "M" is "Mx=b" is close to singular as I got warnings from MATLAB so the results can be in accurate but MKL's results are totally different from GMM++ and MATLAB that shows there is something wrong! I was also curious to know if it can be related to linking options that I use? Maybe I am linking my code to wrong libraries or what? Any help would be appreciated.

Thanks,

D.

0 Kudos
1 Reply
mecej4
Honored Contributor III
438 Views
Do you find any error in my code?

It is difficult to give an answer, in view of these facts

A. you have not shown:

(i) parts of the code that matter a lot: declarations of variables, initialization of data.

(ii) information on which versions of Intel C, OS, MKL used, how the compilation was done.

(iii) the results that you state are wrong and, if known, the correct results.

B. The more third party software that is necessary for looking into your problem, the fewer will be the number of responses elicited.

I have checked my code and everything seems to be OK!

If the "OK" is expected to apply to the parts of the code that you did not show, what can one say beyond "..if you say so, maybe", regardless of whether or not the code as a whole is in error ?

RECOMMENDATIONS:

Unless you are familiar with calling Fortran routines from C, you should find it less error-prone to use the LapackE interface, which is available in MKL. See

http://netlib.org/lapack/#_standard_c_language_apis_for_lapack

If you want to try to get your correct code to work:

(i) You could try printing out (or otherwise checking) the values of the arguments passed to ZGETRF before that routine is called.

(ii) You could look at the examples provided with MKL to see if you can pattern your code after one of them.
0 Kudos
Reply