开发者

Collapse clause being ignored in #pragma omp for

开发者 https://www.devze.com 2023-03-03 07:09 出处:网络
I have the following C code using OpenMP: #pragma omp parallel default(none) private(i, j, k) shared(lb0, ub0, lb1, ub1, lb2, ub2, g, current, update, diff, dg)

I have the following C code using OpenMP:

  #pragma omp parallel default(none) private(i, j, k) shared(lb0, ub0, lb1, ub1, lb2, ub2, g, current, update, diff, dg)
  #pragma omp for collapse(3)
  for( i = lb0; i <= ub0; i++ ) {
    for( j = lb1; j <= ub1; j++ ) {
      for( k = lb2; k <= ub2; k++ ) {
    g->data[ update ][ i ][ j ][ k ] = 
      ONE_SIXTH * ( g->data[ current ][ i + 1 ][ j     ][ k     ] +
            g->data[ current ][ i - 1 ][ j     ][ k     ] +
            g->data[ current ][ i     ][ j + 1 ][ k     ] +
            g->data[ current ][ i     ][ j - 1 ][ k     ] +
            g->data[ current ][ i     ][ j     ][ k + 1 ] +
            g->data[ current ][ i     ][ j     ][ k - 1 ] );
    diff = fabs( g->data[ update ][ i ][ j ][ k ] - g->data[ current ][ i ][ j ][ k ] );
    dg = dg > diff ? dg : diff;
      }
    }
  }

As far as I am aware, I am following the rules for using the collapse clause with the #pragma omp for directive, but when I compile it I get the following error:

grid.c: In function ‘grid_update’:
grid.c:202: error: e开发者_StackOverflow社区xpected ‘#pragma omp’ clause before ‘collapse’
make: *** [grid.o] Error 1

What am I doing wrong here? I've tried putting #pragma omp collapse as a separate directive, but that doesn't work either.


I think collapse was new in OpenMP 3 (2008); is it possible you're using an older compiler that doesn't support it - something older than (say) gcc 4.4?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号