Segmentation fault while matrix multiplication using openMp?

Posted by harshit on Stack Overflow See other posts from Stack Overflow or by harshit
Published on 2010-03-26T23:19:23Z Indexed on 2010/03/26 23:23 UTC
Read the original article Hit count: 593

Filed under:

My matrix multiplication code is

int matMul(int ld, double** matrix)

{

//local variables initialize

omp_set_num_threads(nthreads);

#pragma omp parallel private(tid,diag,ld) shared(i,j,k,matrix)

{ /* Obtain and print thread id */

tid = omp_get_thread_num();

for ( k=0; k<ld; k++)  {
if (matrix[k][k] == 0.0) {
  error = 1;
  return error;
}
diag = 1.0 / matrix[k][k];

#pragma omp for

for ( i=k+1; i < ld; i++) {

  matrix[i][k] = diag * matrix[i][k];

}
for ( j=k+1; j<ld; j++) {

  for ( i=k+1; i<ld; i++) {

    matrix[i][j] = matrix[i][j] - matrix[i][k] * matrix[k][j];

  }

}

}

}
return error;

}

I assume that it is because of matrix object only but why will it be null even though it is passed as a parameter..

© Stack Overflow or respective owner

Related posts about openmp