I have the following code:
void simulation (MD *md){
double sum;
#pragma omp parallel private (move)
{
for(move = 0; move < maxIterations; ++move)
{
cicleDoMove(md);
cicleForces(md);
cicleMkekin(md,sum);
}
}
}
Where:
void cicleMkekin(Md *md, double sum){
#pragma omp for reduction(+ : sum)
for (i = 0; i < md->mdsize; i++)
{
sum += mkekin(..);
}
}
I got the following error:
"reduction variable 'sum' is private in outer context"
The variable amount is general, not private, in fact, if I changed the simulation code to:
void simulation (MD *md){
double sum;
#pragma omp parallel private (move)
{
for(move = 0; move < maxIterations; ++move)
{
cicleDoMove(md);
cicleForces(md);
#pragma omp for reduction(+ : sum)
for (i = 0; i < md->mdsize; i++)
{
sum += mkekin(..);
}
}
}
}
It works great.
Anyway, can I use my first version of code without getting this error? or am i doing something wrong?
source
share