mkl_dss zero base ordering in c

mkl_dss zero base ordering in c

Hi, I'm trying to write a C code that solve a sparse system with dss_mkl, here it follows

#include "mkl_dss.h"
#include "mkl_types.h"

#define N 3
#define N2 (N*N)
#define NNZ (N*(N+2*(N-1))+2*(N-1)*N)

static int* ri;
static int* ci;
static double* a;

int main(){
int i,j,k;
ri=malloc((N2+1)*sizeof(int));
ci=malloc((NNZ)*sizeof(int));
a=malloc(NNZ*sizeof(double));
k=0;
ri[0]=0;
for(i=0;i<N2;i++){
ri[i+1]=ri[i];
for(j=0;j<N2;j++){
if(j-i==-N&&i>0){a[k]=1.;ci[k]=j;ri[i+1]++;k++;}
if(j-i==-1&&i%N>0){a[k]=1.;ci[k]=j;ri[i+1]++;k++;}
if(j-i==0){a[k]=-4.;ci[k]=j;ri[i+1]++;k++;}
if(j-i==1&&i%N<N-1){a[k]=1.;ci[k]=j;ri[i+1]++;k++;}
if(j-i==N&&i<N2-1){a[k]=1.;ci[k]=j;ri[i+1]++;k++;}
}
}
for(k=0;k<N2+1;k++) printf("%4d ",ri[k]);
printf("\n");
for(k=0;k<NNZ;k++) printf("%4d ",ci[k]);
printf("\n");
for(k=0;k<NNZ;k++) printf("%4.1f ",a[k]);
printf("\n");

int error;
_MKL_DSS_HANDLE_t handle;
int options=MKL_DSS_DEFAULTS;
error=dss_create(handle,options);

int n2=N2;
int nnz=NNZ;
int symmetry=MKL_DSS_NON_SYMMETRIC;
error=dss_define_structure(handle,symmetry,ri,n2,n2,ci,nnz);

int reorder_opts=MKL_DSS_DEFAULTS;
error=dss_reorder(handle,reorder_opts,0);
}

I successful compiled this with "icc -mkl poisson2d.c". When I run this I get the following error

"MKL-DSS-DSS-Error, preordering failed (matrix types 11, 13 only)"

Can anyone help me? Where I am doing a mistake?

Thank You.

2 Beiträge / 0 neu
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Hi,
Your ci and ri arrays start from zero element so change options for dss_create from MKL_DSS_DEFAULTS to MKL_DSS_ZERO_BASED_INDEXING:

_MKL_DSS_HANDLE_t handle;
int options=MKL_DSS_DEFAULTS;
error=dss_create(handle,options);

----->

_MKL_DSS_HANDLE_t handle;
int options=MKL_DSS_ZERO_BASED_INDEXING;
error=dss_create(handle,options);

With best regards,