[Omp] Barrier constructs and regions
Michael Suess
mike_ml at suessnetz.de
Wed Jun 15 07:20:17 PDT 2005
Hi,
I have a small request for clarification. Please consider the following small
program:
#include <stdio.h>
#include <omp.h>
#define THREADS 4
int main()
{
omp_set_num_threads(THREADS);
# pragma omp parallel
{
if (omp_get_thread_num() == 0) {
#pragma omp barrier
} else {
#pragma omp barrier
}
}
return 0;
}
The question is: Is this a standard compliant program (the problem are the
barriers here). The Spec has to say:
"All of the threads of the team executing the binding parallel region must
execute the barrier region before any are allowed to continue execution
beyond the barrier."
And:
"The following restrictions apply to the barrier construct:
- Each barrier region must be encountered by all threads in a team or by none
at all
- The sequence of work-sharing regions and barrier regions encountered must be
the same for every thread in a team."
We have two barrier constructs. But do they create the same barrier region? If
yes, the program is compliant and should run just fine (it wont do very much,
but thats not the point :-) ). If not, the program is not compliant and
should hang (actually it's behaviour is undefined then and I would expect it
to hang). All compilers I have access to run the program just fine.
In the section about language terminology, it says in the comments about
region:
"During the execution of an OpenMP program, a construct may give
rise to many regions."
But can many constructs also give rise to the same region?
Thanks for your answers,
Michael Suess
More information about the Omp
mailing list