openmp nested parallelism

Hi, I tried to use openmp nested parallelism feature in my PGI accelerator complier 12.5, but failed.
I set Environment variables OMP_NESTED and OMP_MAX_ACTIVE_LEVELS
,but still failed.

My code is as attached :



program hello
use omp_lib
implicit none
integer :: i

!print *,"omp nested",omp_get_nested()
call omp_set_nested(.true.)
print *,"omp nested",omp_get_nested()
!$omp parallel num_threads(2) default(private)
i = omp_get_thread_num()
if (i.eq.0) then
print *,"hello"
print *,"thread num is ",omp_get_thread_num()
print *,"level is ",omp_get_level()
end if

if (i.eq.1) then
!$omp parallel num_threads(2) 
print *,"world"
print *,"thread num is ",omp_get_thread_num()
print *,"level is ",omp_get_level()
!$omp end parallel
end if
if(i.eq.1) then
print *,"thread num is ",omp_get_thread_num()
print *,"level is ",omp_get_level()
end if
!$omp end parallel
end program hello

My running result is as below

[ldl@ln0%lab PGI_125]$ a.out
omp nested F
hello
thread num is 0
level is 1
world
thread num is 0
level is 2
thread num is 1
level is 1

You can see that the output “World” is lever 2,which wasn’t Parallelized.and I have set set_nested to true,but I get fales.

But if I use ifort to compile the coda as :
$ ifort hello.f90 -openmp

the running result is as below:

[ldl@ln0%lab PGI_125]$ a.out
omp nested T
hello
thread num is 0
level is 1
world
thread num is 0
level is 2
world
thread num is 1
level is 2
thread num is 1
level is 1

you will see that set_nested was true and the level 2 was Parallelized.

Can you give me advices?

Currently we only support nested OpenMP parallelism by setting the environment variables:

OMP_NESTED=TRUE
OMP_MAX_ACTIVE_LEVELS=<n>

While we do allow the runtime calls, they are basically nops at this point.

One other requirement is that we only support orphaned nested parallelism. In the example that you show, the nested parallel region is in the lexical scope of the outer parallel region, and thus we do not honor the nested parallel region.