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

Help, mkl_dcsrgemv

Hi and thanks for the attention! I'm a beginner and i would like to use the mkl library for my thesis. I must use the function mkl_dcsrgemv, but there are always the error: "segmentation error(core dump created)". The code used is the following and i don't see the error. Someone can help me?

code:

#include <stdio.h>

#include "mkl.h"

int main() {

   double *val,*x,*y;
   int *I,*J;
   int k;
   int M;
   char transa='N';
   M=4;
   
   val=(double *) calloc(M,sizeof(double));
   x=(double *) calloc(M,sizeof(double));
   y=(double *) calloc(M,sizeof(double));


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

}

0 Kudos
3 Replies
Highlighted
Moderator
111 Views

which version of mkl do you use?

I release only all dynamically allocated arrays and linked against mkl 2020. it works

$ ./a.out

 il vettore y:
 2.000000        4.000000
 2.000000        4.000000
 2.000000        4.000000
 2.000000        0.000000
 

0 Kudos
Highlighted
Black Belt
111 Views

Since I is of length M, valid subscripts for I are integers from 0 to M-1, inclusive.

You are attempting to store into I[M+1], which is an invalid memory access.

0 Kudos
Highlighted
Moderator
108 Views

are there any updates? Do you still see the segfault?


0 Kudos