Is there an implicit omp barrier after omp critical section
For example, Can I modify this following code version-1 into version-2.
VERSION-1
int min = 100;
#pragma omp parallel
{
int localmin = min;
#pragma omp for schedule(static)
for(int i = 0; i < 1000; i++)
localmin = std::min(localmin, arr[i]);
#pragma omp critical
{
min = std::min(localmin, min)
}
}
VERSION-2
int min = 100;
#pragma omp parallel
{
int localmin = min;
#pragma omp for schedule(static) nowait
for(int i = 0; i < 1000; i++)
localmin = std::min(localmin, arr[i]);
#pragma omp critical
{
min = std::min(localmin, min)
}
} // will I get the right "min" after this (because I have included nowait)
Will I get the same result for both version-1 and version-2?
Is there an implicit barrier after omp critical region?
EDIT: Sorry if the example is very poor.. Also, I would like to know whether there would be any performance difference between version-1 and version-2