How does OpenMP handle data declared inside a parallel partition? Prior to C99, I would use the private () clause to specify local stream data, e.g.
int i, x;
#pragma omp parallel for private(x)
for (i=0; i<n; i++) {
x=i;
}
Now that C99 allows you to mix data and code, I prefer to declare variables just before using them. Does a loop ad guarantee that it is threadable? For example, the following is valid:
#pragma omp parallel for
for (int i=0; i<n; i++) {
int x=i;
}
I tried to add private (x) just in case, but my compiler objects (perhaps because x has not been declared yet).
source
share