使用 OpenMP 时,此代码速度较慢。如果没有 OpenMP,我会得到大约 10 秒。使用 OpenMP,我得到大约 40 秒。怎么了?非常感谢各位朋友!
for (i=2;i<(nnoib-2);++i){
#pragma omp parallel for
for (j=2; j<(nnojb-2); ++j) {
C[i][j]= absi[i]*absj[j]*
(2.0f*B[i][j] + absi[i]*absj[j]*
(VEL[i][j]*VEL[i][j]*fat*
(16.0f*(B[i][j-1]+B[i][j+1]+B[i-1][j]+B[i+1][j])
-1.0f*(B[i][j-2]+B[i][j+2]+B[i-2][j]+B[i+2][j])
-60.0f*B[i][j]
)-A[i][j]));
c2 = (abs(C[i][j]) > Amax[i][j]);
if (c2) {
Amax[i][j] = abs(C[i][j]);
Ttra[i][j] = t;
}
}
}