nested OMP and dynamic threads

General OpenMP discussion

nested OMP and dynamic threads

Postby genew » Sun Jul 07, 2013 12:45 pm

A very simple sample for my question:

DO I=1,2
IF(I.EQ.1)JE=1
IF(I.EQ.2)JE=7
DO J=1,JE
CALL BIGSUB(...)
END DO
END DO

If I have 8 threads/cores, I would like to OMP parallelize both loops
and somehow have a team of 1 thread do I=1 and a team of 7
threads do I=2 . So the 8 executions of BIGSUB will each be done by
a separate thread.

Is this possible ?
genew
 
Posts: 2
Joined: Sat Jul 06, 2013 11:26 pm

Re: nested OMP and dynamic threads

Postby MarkB » Mon Jul 08, 2013 3:03 am

Is this possible ?


Yes, you can do it like this:

Code: Select all
call omp_set_nested(.true.)
call omp_set_num_threads(2)
!$omp parallel do private(je)
DO I=1,2
   IF(I.EQ.1)JE=1
   IF(I.EQ.2)JE=7
   call omp_set_num_threads(JE)
!$omp parallel do
   DO J=1,JE
      CALL BIGSUB(...)
   END DO
END DO


Hope that helps,
Mark.
MarkB
 
Posts: 487
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: nested OMP and dynamic threads

Postby genew » Wed Jul 10, 2013 10:51 am

Mark

Thank you. I will try it. Can you point me to documentation or web page
that explains examples such as this ?

Thanks again

G
genew
 
Posts: 2
Joined: Sat Jul 06, 2013 11:26 pm

Re: nested OMP and dynamic threads

Postby MarkB » Mon Jul 15, 2013 2:30 am

genew wrote:Thank you. I will try it. Can you point me to documentation or web page
that explains examples such as this ?


You're welcome. I can't think of any good resources on this specific topic, I'm afraid, other than the specification itself.
MarkB
 
Posts: 487
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 5 guests