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

mkl_?csrcoo converter function

Bounrajbanditt_K_
1,096 Views

Hi, 

I am trying to get this matrix format converter function to work in C. I checked and edited my program many times as well as checked the documentation but I always end up with the error:

INTEL MKL ERROR: Parameter 1 was incorrect on entry to MKL_DCSRCOO

which refers to the job array. I want to transform a sparse matrix in COO format to CSR format for use in PARDISO. 

I decided to test it out on the example matrix included under the Storage Format example of the mkl-2017-developer-reference-c.pdf

Here is my code snippet below:

int main () 
{
	MKL_INT job[6];
	MKL_INT n = 5;
	MKL_INT nnz = 13;
	MKL_INT info = 0; 

	double *acsr = calloc(nnz, sizeof(double));
	MKL_INT *ja = calloc(nnz, sizeof(MKL_INT));
	MKL_INT *ia = calloc(n+1, sizeof(MKL_INT));

	double acoo[] = { 1, -1, -3, -2, 5, 4, 6, 4, -4, 2, 7, 8, -5 };
	MKL_INT rowind[] = { 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5 };
	MKL_INT colind[] = { 1, 2, 4, 1, 2, 3, 4, 5, 1, 3, 4, 2, 5 };


	job[0] = 1;
	job[1] = 1;
	job[2] = 1;
	job[5] = 0;

	mkl_dcsrcoo(job, &n, acsr, ja, ia, &nnz, acoo, rowind, colind, &info);

	getchar(); 
	return 0; 
}

I am using the 2017 version of mkl. 
 

0 Kudos
1 Solution
mecej4
Honored Contributor III
1,096 Views

If you open a Parallel Studio command prompt from the Start menu, and type "cl" (for the Visual C compiler) or "icl" (for the Intel C compiler), you will see the version of the compiler displayed.

I find that if I set up %INCLUDE% so that the Intel C-compiler's non-MKL-related include files are never used, the problems do not occur with older Visual C compilers. That is, if you use the Visual C compiler, and target x64, do not let it search for include files that came with the Intel C compiler, except for the MKL include files, and use an older version of the Visual compiler than 19.11.25507.1 .

UPDATE: I think that the real cause of the problems is that job[3] and/or job[4] are undefined. Some versions of the MKL documentation make no mention of what should go into job[3] (it is intended to specify whether the upper or lower triangle or the whole of the dense matrix is to be filled in), and says that job[4] should be set equal to nzmax in the case when job[0]=0. If this conjecture is correct, the bug should be easy to fix for the MKL team.

In the meantime, please set job[3] and job[4] to zero and see if that makes the problem go away.

View solution in original post

0 Kudos
9 Replies
mecej4
Honored Contributor III
1,096 Views

I don't see any problem with the code snippet, provided you add the needed #include directives (at least stdio.h and mkl.h). What OS and which version/release of MKL/C compiler?

0 Kudos
Bounrajbanditt_K_
1,096 Views

Version/Release is 17.0.0.109 / 20160721. The initial release of Intel Parallel XE 2017.

Here are my includes in case it might help:

 

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <mkl_lapacke.h>

#include "mkl.h"
#include "mkl_pardiso.h"
#include "mkl_types.h"
#include <time.h>

 

I am using Windows 7 Professional 64-bit (6.1, Build 7601) 

With processor: Intel(R) Xeon(R) CPU E5-1620 v3 @ 3.50GHz (8CPUs)

0 Kudos
mecej4
Honored Contributor III
1,096 Views

I see the error, along with some compiler messages regarding redefinition of some macros in <math.h>, only when I use the Visual C compiler targeting x64, with the optimization option /Ot. No errors with the Intel C compiler. or with /Od with the Visual C compiler. No errors with either compiler when targeting x86. (See #6)

0 Kudos
Bounrajbanditt_K_
1,096 Views

I felt like I experimented with a variety of the above options to no avail, the error still persists.  

I am using Microsoft Visual Studio Community 2015 and I found out that the Intel Parallel Studio XE 2017 installed with it is Update 1 with Version 17.0.71.14. 

I'm not sure which compiler I'm using or how to switch but I did target x86 as well as messed with various optimization options with the same result. 

Appreciate the assistance thus far though. 

0 Kudos
mecej4
Honored Contributor III
1,097 Views

If you open a Parallel Studio command prompt from the Start menu, and type "cl" (for the Visual C compiler) or "icl" (for the Intel C compiler), you will see the version of the compiler displayed.

I find that if I set up %INCLUDE% so that the Intel C-compiler's non-MKL-related include files are never used, the problems do not occur with older Visual C compilers. That is, if you use the Visual C compiler, and target x64, do not let it search for include files that came with the Intel C compiler, except for the MKL include files, and use an older version of the Visual compiler than 19.11.25507.1 .

UPDATE: I think that the real cause of the problems is that job[3] and/or job[4] are undefined. Some versions of the MKL documentation make no mention of what should go into job[3] (it is intended to specify whether the upper or lower triangle or the whole of the dense matrix is to be filled in), and says that job[4] should be set equal to nzmax in the case when job[0]=0. If this conjecture is correct, the bug should be easy to fix for the MKL team.

In the meantime, please set job[3] and job[4] to zero and see if that makes the problem go away.

0 Kudos
mecej4
Honored Contributor III
1,096 Views

Here are some details regarding the MKL bug. Stepping into the MKL routines in the VS debugger, I found the following lines of assembler:

00007FFDF93FDB70  cmp         dword ptr [rcx+8],1    #  job[2] > 1 ?
00007FFDF93FDB74  ja          00007FFDF93FDB4A  
00007FFDF93FDB76  cmp         dword ptr [rcx+10h],0  #  job[4] < 0 ?
00007FFDF93FDB7A  jl          00007FFDF93FDB4A  
00007FFDF93FDB7C  cmp         dword ptr [rcx+14h],3  #  job[5] > 3 ?
00007FFDF93FDB80  ja          00007FFDF93FDB4A  

Note that RCX contains the first argument to mkl_dcsrcoo, which is the pointer to the JOB array. In the example code, JOB = [1, 1, 1, ?, ?, 0]. The second compare instruction queries the value of JOB[4], which is not defined. If the junk value happens to be negative, things go wrong. I think that the manual should make it clear that JOB[4] should be set to zero, or the MKL code should be fixed.

0 Kudos
Ying_H_Intel
Employee
1,096 Views

Hello, 

Please refer to MKL example dconverters.c, which be default in MKL install directory .   and it  provided the sample code about the function. 

for example 

MKL_INT job[8];

 job[0]=1;
      job[5]=2;
      mkl_scsrcoo (job,&n, Acsr, AJ,AI,&nnz,Acoo, ir,jc,&info); 

If it is still issue, please submit your question to our official support channel: Online Service Center - Intel Support

Best Regards

Ying

0 Kudos
Bounrajbanditt_K_
1,096 Views

Yes you are right mecej4, it seems I need to initialize job[3] and job[4] to 0.  I was a bit confused as job[3] wasn't mentioned in the documentation and job[4] is used for when job[0] = 0 so I thought I can ignore it. I cannot express my gratitude enough.

 

Thank you both for the help.

0 Kudos
mecej4
Honored Contributor III
1,096 Views

Glad to hear that the suggestion worked.

0 Kudos
Reply