OpenMP help

General OpenMP discussion

OpenMP help

Postby eladtan » Sat Feb 25, 2012 1:53 pm

Hello all,

I want to use openmp to speed up my program (in c++). I have a method (lets call it method A) which consists of a big loop that has to be done serially. This loop call method B which among other thing has a loop in it that can be parellized. However, simply using a parallel for on the loop only makes things worse since the loop in method B isn't that time consuming (per one iteration of method A, but taking into account all of the iteration of method A this loop takes most of the time) so I spend much more time on creating and synchronizing threads then I do calculating. Is there a way to tell the compiler to always have several threads "on" but only to use one of them and the minute that thread enters the loop in method B use all of the other threads. I thought about using the single clause, but once I use that on the loop in method A I can't do anything on the loop in method B. Any ideas??

Thank you for your help,
Elad
eladtan
 
Posts: 3
Joined: Sat Feb 25, 2012 1:46 pm

Re: OpenMP help

Postby shivaram » Sun Feb 26, 2012 7:41 am

Hi,

Is it possible to inline the body of function B inside function A?. In that case you may be able to use omp_single clause for function A body and the loop of function B can be executed in parallel.

Regards,
Shivaram
shivaram
 
Posts: 5
Joined: Wed Feb 22, 2012 5:10 am

Re: OpenMP help

Postby eladtan » Sun Feb 26, 2012 2:07 pm

Function B is a very big function that branched off into other functions as well. Part of function B consists of a loop that can be parellized (this loop is the most time consuming). I don't think I can inline it, is there someway to tell the compiler not to close off threads?
eladtan
 
Posts: 3
Joined: Sat Feb 25, 2012 1:46 pm

Re: OpenMP help

Postby shivaram » Tue Feb 28, 2012 4:27 am

There is no language or openmp support to do this. However, many of the openmp implementations create the openmp threads as part of the initialization step. At the end of a parallel region the thread is not removed, but stored in a thread pool for later reuse. This is to reduce the overhead in creation and deletion of threads for each of the parallel regions, whenever they are entered. May be your openmp library is already doing this. Which compiler is used in your development?
shivaram
 
Posts: 5
Joined: Wed Feb 22, 2012 5:10 am

Re: OpenMP help

Postby MarkB » Tue Feb 28, 2012 5:35 am

Do you have some idea of how long each call to the parallelisable loop takes? If it is less than a few microseconds, no OpenMP implementation is likely to give you any useful speedup: the overheads of starting and stopping a parallel region are typically of this order, even if the implementation keeps the threads alive.
MarkB
 
Posts: 434
Joined: Thu Jan 08, 2009 10:12 am

Re: OpenMP help

Postby eladtan » Tue Feb 28, 2012 12:05 pm

I guess that's the problem then. I want to parrelize a loop which basically does each iteration about 10 floating point operations and the loop runs for about 500 iterations so I guess that it will take it only a few microseconds. Unfortionatly, that loops take up most of the time of my code since I repeat this loop a few million times.
And I forgot to say, I'm using Intel composer 2011 compiler.
eladtan
 
Posts: 3
Joined: Sat Feb 25, 2012 1:46 pm


Return to Using OpenMP

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests