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

mkl_dcsrgemv core dump

Camuso__Marco
Beginner
916 Views

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
MariaZh
Employee
916 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
Gennady_F_Intel
Moderator
912 Views

Hi Marco,

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


0 Kudos
Gennady_F_Intel
Moderator
873 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
Reply