Reputation: 11
Im trying to implent my code with openmp but i am having some trouble. My code has several loops so i tried to parallelize each "for" blocks in order to make my code run faster. However im having problems parallelize certain for blocks. The issue is basically that the results I get when I parallelize tend to 0, while when the code runs without openmp they dont.
This is an example of a block im trying to parallelize (there are 3 of them):
#pragma omp parallel for private(j)
for(i=1;i<127;i++)
for(j=1;j<127;j++)
{
dpx=dp(p[i+1][j],p[i-1][j]);
dpy=dp(p[i][j+1],p[i][j-1]);
d2px=d2p(p[i+1][j],p[i][j],p[i-1][j]);
dpx=dp(p[i][j+1],p[i][j],p[i][j-1]);
f=F(d2px,d2py,dpx,dpy,p[i][j],i,j);
p1[i][j]=p[i][j] + f;
}
Does anyone has an idea why im getting results that tend to 0 for the p or the p1 value? I thought that perhaps the dpx,dpy... needed to be private as well but that didnt worked either.
Upvotes: 0
Views: 46
Reputation: 26345
You're setting dpx
twice without using it. Is that intended? Or did you want the second call to be d2py
? You never set d2py
, and then use it, which seems suspicious.
Upvotes: 1