我有使用OpenMP的以下C代码:
#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;
}
}
}
据我所知,我遵循使用带有#pragma omp for directive的collapse子句的规则,但是当我编译它时,我收到以下错误:
grid.c: In function ‘grid_update’:
grid.c:202: error: expected ‘#pragma omp’ clause before ‘collapse’
make: *** [grid.o] Error 1
我在这里做错了什么?我已经尝试将#pragma omp collapse
作为单独的指令,但这也不起作用。
答案 0 :(得分:2)
我认为在OpenMP 3(2008)中崩溃是新的;你是否有可能使用不支持它的旧编译器 - 比gcc 4.4更早的东西?