Skip to content

[Flang][OpenMP] Variable in parallel sections construct with default(private) clause is not treated as private #141438

Open
@ohno-fj

Description

@ohno-fj
Version of flang : 21.0.0(fb86b3d96b73f4e628288b180ef4e038da8b7bc1)/AArch64

sngf_reduction71_222.f90:

program main
  integer a
  a=10
!$omp parallel sections default(private)
  a=15
!$omp end parallel sections
  print *,'a = ', a
end program main

Variable (a) in parallel sections construct with default (private) clause is not treated as private.
After parallel sections construct ends, the value of variable (a) is expected to be 10.

I found variable (a) is treated as private in the following cases:

  • default (private) clause is changed to private (a) clause
    See sngf_reduction71_232.f90 below.
  • parallel sections construct is changed to parallel construct
    See sngf_reduction71_223.f90 below.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

$ export OMP_NUM_THREADS=2; flang -fopenmp sngf_reduction71_222.f90; ./a.out
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 a =  15
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp sngf_reduction71_222.f90; ./a.out
 a =           10
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp sngf_reduction71_222.f90; ./a.out
 a =           10
$

sngf_reduction71_232.f90:

program main
  integer a
  a=10
!$omp parallel sections private(a)
  a=15
!$omp end parallel sections
  print *,'a = ', a
end program main
$ export OMP_NUM_THREADS=2; flang -fopenmp sngf_reduction71_232.f90; ./a.out
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 a =  10
$

sngf_reduction71_223.f90:

program main
  integer a
  a=10
!$omp parallel default(private)
  a=15
!$omp end parallel
  print *,'a = ', a
end program main
$ export OMP_NUM_THREADS=2; flang -fopenmp sngf_reduction71_223.f90; ./a.out
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 a =  10
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions