- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm finding that an OMP parallel construct called from a subroutine contained within a library does not fork. However, a call to OMP_GET_MAX_THREADS() returns 4. I.e. > 1. The same snippet of code, called from the main program works properly.
I've posted the routine here. It first prints the maximum number of threads available in a parallel section. Next, within the parallel section, each thread simply reports it's ID. This code allows you to verify that the main thread forked off into several slaves.
Given that I use the same compiler flags for both the library and the main driver program (both Intel Fortran 9.1 projects), what possible reason why OpenMP will not fork from within the library?
Here is the screen output.
From within the main driver program...
nThreadMax = 4
Thread 1 of 4 reporting
Thread 2 of 4 reporting
Thread 3 of 4 reporting
Thread 4 of 4 reporting
And then the output from the subroutine above called from within the library...
nThreadMax = 4
Thread 1 of 1 reporting
Clearly the call to OMP_GET_MAX_THREADS() returns 4 but the parallel section is only being handled by one thread.
I've posted the routine here. It first prints the maximum number of threads available in a parallel section. Next, within the parallel section, each thread simply reports it's ID. This code allows you to verify that the main thread forked off into several slaves.
Given that I use the same compiler flags for both the library and the main driver program (both Intel Fortran 9.1 projects), what possible reason why OpenMP will not fork from within the library?
Here is the screen output.
From within the main driver program...
nThreadMax = 4
Thread 1 of 4 reporting
Thread 2 of 4 reporting
Thread 3 of 4 reporting
Thread 4 of 4 reporting
And then the output from the subroutine above called from within the library...
nThreadMax = 4
Thread 1 of 1 reporting
Clearly the call to OMP_GET_MAX_THREADS() returns 4 but the parallel section is only being handled by one thread.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - jfwieden
I'm finding that an OMP parallel construct called from a subroutine contained within a library does not fork. However, a call to OMP_GET_MAX_THREADS() returns 4. I.e. > 1. The same snippet of code, called from the main program works properly.
I've posted the routine here. It first prints the maximum number of threads available in a parallel section. Next, within the parallel section, each thread simply reports it's ID. This code allows you to verify that the main thread forked off into several slaves.
Given that I use the same compiler flags for both the library and the main driver program (both Intel Fortran 9.1 projects), what possible reason why OpenMP will not fork from within the library?
Here is the screen output.
From within the main driver program...
nThreadMax = 4
Thread 1 of 4 reporting
Thread 2 of 4 reporting
Thread 3 of 4 reporting
Thread 4 of 4 reporting
And then the output from the subroutine above called from within the library...
nThreadMax = 4
Thread 1 of 1 reporting
Clearly the call to OMP_GET_MAX_THREADS() returns 4 but the parallel section is only being handled by one thread.
I've posted the routine here. It first prints the maximum number of threads available in a parallel section. Next, within the parallel section, each thread simply reports it's ID. This code allows you to verify that the main thread forked off into several slaves.
Given that I use the same compiler flags for both the library and the main driver program (both Intel Fortran 9.1 projects), what possible reason why OpenMP will not fork from within the library?
Here is the screen output.
From within the main driver program...
nThreadMax = 4
Thread 1 of 4 reporting
Thread 2 of 4 reporting
Thread 3 of 4 reporting
Thread 4 of 4 reporting
And then the output from the subroutine above called from within the library...
nThreadMax = 4
Thread 1 of 1 reporting
Clearly the call to OMP_GET_MAX_THREADS() returns 4 but the parallel section is only being handled by one thread.
Here is the source for that routine. Forgot at paste it in.
!==============================================================================
SUBROUTINE TestSetup()
!==============================================================================
! General setup routine for testing OMP within a library
!==============================================================================
!Declare imports
USE OMP_LIB
IMPLICIT NONE
!Local variables
INTEGER::nThread,nThreadMax
!==============================================================================
nThreadMax = OMP_GET_MAX_THREADS()
WRITE(6,'("nThreadMax = ",I2)') nThreadMax
!$OMP PARALLEL
nThread = OMP_GET_NUM_THREADS()
!$OMP CRITICAL
WRITE(6,'("Thread ",I2," of ",I2," reporting")') OMP_GET_THREAD_NUM()+1,nThread
!$OMP END CRITICAL
!$OMP END PARALLEL
END SUBROUTINE TestSetup
!==============================================================================

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page