Previous: Loop Unraveling Up: Structured Parallel Loops: parfor Next: Examples
{
int i;
parfor (i=0; i<N; i++) //ERROR
{ ... }
}
parfor (int i=0; i<N; i++) {
int x, y = i*2;
x = f();
g(x,y);
}
{
int i,j;
for (i=0; i<N; i++)
for (j=0; j<N; j++)
{ ... }
}
The following parallelization of this code is incorrect:
{
int j;
parfor (int i=0; i<N; i++)
for (j=0; j<N; j++) //Error: j is a shared mutable
{ ... }
}
This code is incorrect because the mutable variable j is shared between the concurrently executing iterations of the parallel loop. All sequential loops nested within a parallel loop should declare their loop control variables.
The current implementation restrictions are the same as those
for parallel blocks (see Section ).