Yes, Linux supports nested parallelism, and the community license
enables all the features on the Linux systems.
-
Make sure you set OMP_NESTED,
setenv OMP_NESTED TRUE
-
Make sure you set the active levels.
setenv OMP_MAX_ACTIVE_LEVELS 3
-
at each level, a parallel section will enable as many threads
as are set by OMP_NUM_THREADS
So if OMP_NUM_THREADS is set to 8, and OMP_MAX_ACTIVE_LEVELS is
set to 3, you will have problems, because
8**3 is greater than the thread limit of 256.
Here is a program with 3 levels of nesting.
Try OMP_NUM_THREADS set to 8, and then
OMP_MAX_ACTIVE_LEVELS to 3, and you will see problems.
pgfortran -Mfixed -mp -o hello_mp hello_mp.f
./hello_mp
% more hello_mp.f
program hello_mp
integer OMP_GET_THREAD_NUM, i,j
!$omp parallel
!$omp do
do i=1,8
j=OMP_GET_THREAD_NUM()
call hello_mp_sub(i,j)
end do
!$omp end parallel
end
subroutine hello_mp_sub(loopnum,threadnum)
integer OMP_GET_THREAD_NUM, loopnum,threadnum,i,j
!$omp parallel
!$omp do
do i=1,4
j=OMP_GET_THREAD_NUM()
call hello_mp_sub_sub(loopnum,threadnum,i,j)
end do
!$omp end parallel
end
subroutine hello_mp_sub_sub(lnum,tnum,l2num,t2num)
integer OMP_GET_THREAD_NUM, lnum,tnum,l2num,t2num,i,j
!$omp parallel
!$omp do
do i=1,2
j=OMP_GET_THREAD_NUM()
write(6,100)lnum,tnum,l2num,t2num,i,j
100 format(3x,“main lnum=”,i3,2x,“main tnum=”,i3,2x,
1 “2nd lnum=”,i3,2x,“2nd tnum=”,i3,2x,
1 “3nd lnum=”,i3,2x,“3nd tnum=”,i3,2x )
end do
!$omp end parallel
end