[Omp] Help on the Barrier case

James Beyer beyerj at cray.com
Thu Mar 8 12:52:49 PST 2007


The barrier has to take cycles for all of the threads.  No thread can 
leave the barrier until all threads have entered the barrier and the 
only way all of the threads can know that they have all entered the 
barrier is for them all to see that the barrier counter has reached the 
proper limit.  How many cycles it takes to do this depends on the 
implementation and the hardware.  I don't know what your machine is, 
however, about 6000 cycles on a modern multi-gigahertz machine is rather 
quick turn around.  Think about how many cycles memory is away from the 
processor.

Have you tried a simple test case where only one of your threads sleeps 
for say 2 seconds while all the rest of the threads go immediately into 
the barrier?  The results might help you understand what is going on for 
your test case.

Another interesting data point would be to look at the code generated by 
the compiler to see what it takes to do a barrier.  Some compilers are 
going to do a call while others are going to inline the code so you can 
see exactly what a barrier looks like in the assembly, again I don't 
know what your compiler will do.

good luck.

james

Shengyan Hong wrote:
> Every member,
>        In the ft benchmark, I add a barrier in the ft.f . The code is as 
> follows.
> "
>        !$omp parallel do default(shared) private(i,j,k)
>        do k = 1, d3
>           do j = 1, d2
>              do i = 1, d1
>                 u1(i,j,k) = u0(i,j,k)*ex(t*indexmap(i,j,k))
>              end do
>           end do
>         TID = OMP_GET_THREAD_NUM()
>         PRINT *, 'thread = ', TID
>         print *, "March 6 night"
>         print *, "Before barrier"
>         CALL MAGIC_BRK_SIM_START()
>         !$OMP BARRIER
>         print *, "After barrier"
>         CALL MAGIC_BRK_SIM_START()
>         end do
>
>        return
>        end
> "
>        I run it on simics by using 8 processors with 8 threads. Now 8 
> threads enter the barrier and leave the barrier.
>        Now I have a problem. Every thread will have some time in the 
> barrier. The minimum idle time of the 8 threads is 6.493*10^3 cycles. I 
> think that there should at least one thread that has no idle 
> time in the barrier. So I am wondering whether my experiment is correct or 
> not.
>        Thank you.
>                                   Shengyan Hong
> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp
>   


More information about the Omp mailing list