[Omp] Barrier constructs and regions

Marina Kraeva kraeva at iastate.edu
Tue Jun 21 07:27:00 PDT 2005


Sanjiv,

Why do you say that the program below is non-conforming (in the quoted 
message you say it is "con-forming", but later you said it's 
non-conforming)?

Both restrictions that you quoted are satisfied - the barrier is called 
by all threads, and there is no work-sharing regions, so the sequence of 
work-sharing regions and barrier regions is the same.

Look at the non-conforming example A.35.5 in the Specs 2.5. The barrier 
cannot be nested inside the critical region because only one thread AT A 
TIME can enter the critical region. But in the Michael's example all 
threads can call barrier at the same time.

Marina.

Shah, Sanjiv wrote:

> 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
> 
> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp_openmp.org
> 
> 




More information about the Omp mailing list