This should be an easy one for anyone that's used OpenMP before!
How do I share a variable in a parallel loop.
I.e.:
The problem is that sausage and indigo need to be independent for each thread. Now I guess I could use the thread number and the total number of threads to somehow create an array for each indigo and sausage but I'm sure there's something built into openmp where you can just say "give each thread their own version of indigo and sausage".
Any ideas?
How do I share a variable in a parallel loop.
I.e.:
Code:
#pragma omp parallel for
for(i=0;i<n1;i++)
{
for(j=0;j<n2;j++)
{
indigo=array1[i]*array2[j];
sausage=sqrt(indigo);
array3[i][j]=sausage;
}
}
The problem is that sausage and indigo need to be independent for each thread. Now I guess I could use the thread number and the total number of threads to somehow create an array for each indigo and sausage but I'm sure there's something built into openmp where you can just say "give each thread their own version of indigo and sausage".
Any ideas?