Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
153 Views

mkl_dcsrgemv core dump

Hi, i must use the function mkl_dcsrgemv but there are always the segmentation error. This is the code:

#include <stdio.h>

#include "mkl.h"

typedef struct {
    int dimmat,nz;
    int *I; int *J; double *val;
}csr;

int main() {

   double *x,*y;
   csr *w;
   int k;
   int M;
   char transa='t';
   M=4;
   
   w->val=(double *) calloc(M,sizeof(double));
   x=(double *) calloc(M,sizeof(double));
   y=(double *) calloc(M,sizeof(double));


   w->I=(int *) calloc (M+1,sizeof(int));
   w->J=(int *) calloc(M,sizeof(int));
   
   for(k=0;k<M;++k){
   
      w->val=2;
      x=2;
      w->J=k+1;
      w->I=k+1;   
   }
   
   w->I[M+1]=M+1;
   
  mkl_dcsrgemv(&transa,&M,w->val,w->I,w->J,x,y);
 
  printf("\n il vettore y: \n");
 
  for(k=0;k<M;++k){
    
      printf(" %lf \t %g \n",w->val,y);
  }
  return 0;

}

I don't see the error. Help please.

0 Kudos
3 Replies
Highlighted
Employee
153 Views

Hi Marco,
I think you may have an error because you didn't allocate the w struct itself, but trying to use it.

csr *w;
...
w->val=(double *) calloc(M,sizeof(double));

Best regards,
Maria

0 Kudos
Highlighted
Moderator
150 Views

Hi Marco,

any progress with this problem? Did you try to apply what Maria suggested?


0 Kudos
Highlighted
Moderator
110 Views

You could try to apply the suggestion to allocate the structure W as was proposed by Maria.

You may also try to use the latest version of mkl 2020 update 2 which available for download.

0 Kudos