[Omp] Barrier constructs and regions

Shah, Sanjiv sanjiv.shah at intel.com
Wed Jun 15 07:44:23 PDT 2005


This is a con-forming program that probably works with most
implementations, although it's possible some flag an error (like maybe
ours, I don't remember).  

The resons are as you quoted:

"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."

Sanjiv 


--
Sanjiv, 217-403-4244

-----Original Message-----
From: Omp-bounces at openmp.org [mailto:Omp-bounces at openmp.org] On Behalf
Of Michael Suess
Sent: Wednesday, June 15, 2005 9:20 AM
To: Omp at openmp.org
Subject: [Omp] Barrier constructs and regions

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

_______________________________________________
Omp mailing list
Omp at openmp.org
http://openmp.org/mailman/listinfo/omp_openmp.org




More information about the Omp mailing list