number of threads

General OpenMP discussion

number of threads

Postby mth » Wed Apr 25, 2012 11:36 am

Hi,

I extended a mpi program by openmp. Only a few computationally expensive functions are
parallelized by openmp, which are called many times, the rest is "serial". In the beginning I
set the maximum number of threads by omp_set_num_threads(N). I test the number of
threads at the beginning of each pragma region by omp_get_max_threads(). Now over time
this value decreases. Is this possible? I thought this number is fixed.

Thanks,
mth
mth
 
Posts: 2
Joined: Mon Apr 23, 2012 12:23 pm

Re: number of threads

Postby UYNIX » Thu Apr 26, 2012 12:27 pm

Hi Mth,
I am extremely new to OpenMP, but I happened to cross this piece of information
http://openmp.org/mp-documents/omp-hands-on-SC08.pdf
On page 44, it explicit states that the system may give you lesser processors. You may look at it yourself.

Good luck,
Cindy
UYNIX
 
Posts: 8
Joined: Thu Apr 26, 2012 11:58 am

Re: number of threads

Postby mth » Fri Apr 27, 2012 3:16 am

Thanks for the answer. Well, this explains a lot. However, is there a way of enforcing
the maximum number? I find it strange using a 6 core processor where the system
drops the number of threads to 4 (or less)...
mth
 
Posts: 2
Joined: Mon Apr 23, 2012 12:23 pm

Re: number of threads

Postby ftinetti » Fri Apr 27, 2012 6:06 am

Hi,

I test the number of
threads at the beginning of each pragma region by omp_get_max_threads()

Take into account that (copied from Spec. v. 3.1)
The omp_get_max_threads routine returns an upper bound on the number of
threads that could be used to form a new team if a parallel region without a
num_threads clause were encountered after execution returns from this routine.


However, is there a way of enforcing
the maximum number? I find it strange using a 6 core processor where the system
drops the number of threads to 4 (or less)...

Do you mean 4 running threads or the value returned by omp_get_max_threads() is 4 or ...? BTW, what is your system (computer, processor/s, # of cores, RAM, compiler, etc.)?

Fernando.
ftinetti
 
Posts: 581
Joined: Wed Feb 10, 2010 2:44 pm

Re: number of threads

Postby MarkB » Fri Apr 27, 2012 9:16 am

I expect dynamic adjustment of threads is enabled by default in your OpenMP implementation, which allows the runtime to deliver fewer threads than requested by omp_set_num_threads(). To disable this dynamic adjustment, call

omp_set_dynamic(0);

at the start of your program.
However, the fact that the runtime is choosing to do dynamic adjustment might indicate that you are somehow oversubscribing the hardware (i.e. you are running more threads than cores).
MarkB
 
Posts: 432
Joined: Thu Jan 08, 2009 10:12 am

Re: number of threads

Postby pprovazky » Sat May 26, 2012 2:06 am

Hi Cindy,
I went on the pages which you provided
http://openmp.org/mp-documents/omp-hands-on-SC08.pdf
but, I do not think it explicitly state that the system can give you lesser processors...

Pprovazky
pprovazky
 
Posts: 1
Joined: Mon May 21, 2012 8:11 am


Return to Using OpenMP

Who is online

Users browsing this forum: Majestic-12 [Bot] and 8 guests