Internal switch that can turn off/on OpenMP

General OpenMP discussion

Internal switch that can turn off/on OpenMP

Postby noemig4 » Tue Nov 29, 2011 11:08 am

Hello all,

I have implemented OpenMP for some do loops in my code using the Parallel Do Directive. For small projects I am getting a simulation time greater than the one that I get for the serial code, the overhead is bigger than the time saved using OpenMP.

To avoid this, I would like the code to automatically turn off for small projects the OpenMP Do Directives and turn on them for bigger projects. Is there a way to implement an internal switch that can turn off the parallelization for small projects and on otherwise?

Thanks.
noemig4
 
Posts: 3
Joined: Wed Nov 09, 2011 8:48 am

Re: Internal switch that can turn off/on OpenMP

Postby MarkB » Fri Feb 17, 2012 10:28 am

You could try calling omp_set_num_threads(1); so that every parallel region will execute on one thread: this should remove most (though not all) of the overhead.
Using the if clause on your parallel regions will have a similar effect.
MarkB
 
Posts: 427
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 8 guests

cron