user functions and subroutines in OpenMP

General OpenMP discussion

user functions and subroutines in OpenMP

Postby smajz » Fri Sep 06, 2013 5:42 pm

Hi all,

I'm a user of the fortran 90 language and new to OpenMP.
I want to call user created functions and subroutines inside OpenMP parallel regions as follows

Code: Select all
!OMP PARALLEL
     CALL MYSUBROUTINE()
     MY FUN = MYFUNCTION(X)
!OMP END PARALLEL


where MYSUBROUTINE and MYFUNCTION are serial procedures. My questions are

1. Does the fortran compiler create a copy of MYSUBROUTINE and MYFUNCTION for
each processor being used?
2. Do I need to explicitly indicate in MYSUBROUTINE and MYFUNCTION definitions which variables need to be thread private?
I have read the LLNL OpenMP tutorial but the answer to these questions is not yet clear to me.

Thank you!

Miguel
smajz
 
Posts: 1
Joined: Tue Apr 27, 2010 1:18 pm

Re: user functions and subroutines in OpenMP

Postby ftinetti » Tue Sep 10, 2013 5:28 am

Hi Miguel,

1. Does the fortran compiler create a copy of MYSUBROUTINE and MYFUNCTION for
each processor being used?

What do you mean by "a copy"? Parallel regions are about creating and running threads. Your code imply having several threads, each one of them calling, in sequence, MYSUBROUTINE() and MYFUNCTION(X)...

2. Do I need to explicitly indicate in MYSUBROUTINE and MYFUNCTION definitions which variables need to be thread private?

Well... "automatic" variables (i.e. those allocated in the subroutine stack) are "automatically" private to each thread. You will have to declare as threadprivate those SAVE and COMMON variables which need to be so.

HTH,

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


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 3 guests

cron