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

mkl_dss zero base ordering in c

Fabio_G_
Beginner
950 Views

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;
    for(j=0;j<N2;j++){
        if(j-i==-N&&i>0){a=1.;ci=j;ri[i+1]++;k++;}
        if(j-i==-1&&i%N>0){a=1.;ci=j;ri[i+1]++;k++;}
        if(j-i==0){a=-4.;ci=j;ri[i+1]++;k++;}
        if(j-i==1&&i%N<N-1){a=1.;ci=j;ri[i+1]++;k++;}
        if(j-i==N&&i<N2-1){a=1.;ci=j;ri[i+1]++;k++;}
    }
    }
    for(k=0;k<N2+1;k++) printf("%4d ",ri);
    printf("\n");
    for(k=0;k<NNZ;k++) printf("%4d ",ci);
    printf("\n");
    for(k=0;k<NNZ;k++) printf("%4.1f ",a);
    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.

0 Kudos
1 Reply
Alexander_K_Intel2
950 Views
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, Alexander Kalinkin
0 Kudos
Reply