Join Overhead

General OpenMP discussion

Join Overhead

Postby bluekds » Wed Jul 30, 2008 11:30 pm

This is my code..

Code: Select all
   checker->onTimer(TIME_TOTAL) ;
   #pragma omp parallel default(shared) num_threads(4)
   {
      #pragma omp sections
      {
         #pragma omp section
         {
            checker->onTimer(TIME_0) ;
            threadPlay(0) ;
            checker->offTimer(TIME_0) ;
         }

         #pragma omp section
         {
            checker->onTimer(TIME_1) ;
            threadPlay(1) ;
            checker->offTimer(TIME_1) ;
         }
         #endif

         #pragma omp section
         {
            checker->onTimer(TIME_2) ;
            threadPlay(2) ;
            checker->offTimer(TIME_2) ;
         }
         #endif

         #pragma omp section
         {
            checker->onTimer(TIME_3) ;
            threadPlay(3) ;
            checker->offTimer(TIME_3) ;
         }
         #endif
      }
   }   // end parallel region
   checker->offTimer(TIME_TOTAL) ;


This code is done 480 times.
And I got the result like bellow..

TIME_0 : 115.036 sec
TIME_1 : 115.896 sec
TIME_2 : 114.573 sec
TIME_3 : 115.001 sec

TIME_TOTAL : 131.191


Each thread processes tasks that allocated to their own queue. Each task are totally independent.
And when one finished it's work, get more task from other thread.
So each thread sets a lock for their own queue when it accesses the queue.

The timer of each thread covers all the work including processing task ,seting lock and geting more job.

So I think the TIME_TOTAL should similar with largest time ( 115.896 sec )
But the total time shows big difference.

Can the overhead of join large like it ?

What makes the join overhead ?




Thank you.
Duksu Kim
SGLab, KAIST
bluekds
 
Posts: 8
Joined: Mon Jul 14, 2008 6:18 am

Re: Join Overhead

Postby ejd » Thu Jul 31, 2008 5:52 am

It is not the join by itself that has the overhead. You have timed the total and each section. However, you don't know when each section was started. So it can look something like (hopefully this turns out looking okay):
Code: Select all
 
                        |----------- section 1 -----------|
|----------- section 2 -----------|-------- wait ---------|
       |----------- section 3 -----------|---- wait ------|
              |----------- section 4 -----------|- wait --|

In this example, each section has the same execution time, but they start at different points. This is caused by the startup overhead and system scheduling of the threads. I haven't really shown the join overhead at the end, but this is also part of your section overhead total.

You haven't said what implementation you are using, so I can't comment too much on the barrier at the end of the region. Most implementations use posix threads or pthreads and the barrier is a thread join plus some other overhead. The overhead is caused by things like seeing if a reduction is being used and either "parking" or destroying the threads. It also depends on how the barrier is implemented - a spin wait or a sleep - depending on how an implementation thinks the system is being used. Hopefully this helps.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: Join Overhead

Postby bluekds » Sun Aug 24, 2008 8:41 pm

Thanks, ejd.
You are right!

I found the reason!
My program work for 480 frames.

The sumation time of whole frame was similar with each other.
But for each frame, there were some difference between threads.

I fixed it :)
Duksu Kim
SGLab, KAIST
bluekds
 
Posts: 8
Joined: Mon Jul 14, 2008 6:18 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 7 guests