Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flang][OpenMP] Incorrect execution result when multiple associate and parallel private constructs are nested #114890

Open
ohno-fj opened this issue Nov 4, 2024 · 0 comments

Comments

@ohno-fj
Copy link

ohno-fj commented Nov 4, 2024

Version of flang-new : 20.0.0(5621929f7f4878c318deecb592cd03f5ecbb83ba)/AArch64

When multiple associate and parallel private constructs are nested, the value of association is incorrect.
The above program is FT_openmp_private_09_21.f90
When associate construct is not nested, the result is correct.
The above program is FT_openmp_private_09_22.f90

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

FT_openmp_private_09_21.f90:

program main
  integer :: b(3)=5
  integer :: d=10
  real    :: f=15
  associate(c=>d, a=>b(2:3))
!$omp parallel private(b,d,f)
    associate(e=>f)
!$omp parallel private(f)
      b=7
      d=8
      f=9
      if(e  .ne. 15) print*,"104",e
!$omp end parallel
    end associate
    if(a(1) .ne.  5) print*,"101"
    if(a(2) .ne.  5) print*,"102"
    if(c    .ne. 10) print*,"103",c
!$omp end parallel
    print*, "pass"
  end associate
end program main
$ export OMP_NUM_THREADS=2; flang-new -fopenmp FT_openmp_private_09_21.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 104 1.54E-43
 104 6.3116734E-19
 pass
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp FT_openmp_private_09_21.f90; ./a.out
 104   2.25024438
 104   0.00000000
 pass
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp FT_openmp_private_09_21.f90; ./a.out
 pass
$

FT_openmp_private_09_22.f90:

program main
  integer :: b(3)=5
  integer :: d=10
  real    :: f=15
  associate(c=>d, a=>b(2:3),e=>f)
!$omp parallel private(b,d,f)
!    associate(e=>f)
!$omp parallel private(f)
      b=7
      d=8
      f=9
      if(e  .ne. 15) print*,"104",e
!$omp end parallel
!    end associate
    if(a(1) .ne.  5) print*,"101"
    if(a(2) .ne.  5) print*,"102"
    if(c    .ne. 10) print*,"103",c
!$omp end parallel
    print*, "pass"
  end associate
end program main
$ export OMP_NUM_THREADS=2; flang-new -fopenmp FT_openmp_private_09_22.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 pass
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp FT_openmp_private_09_22.f90; ./a.out
 pass
$
$ export OMP_NUM_THREADS=2; ifx -qopenmp FT_openmp_private_09_22.f90; ./a.out
 pass
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant