llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.21k stars 11.14k forks source link

[Flang][OpenMP] Incorrect execution result of an assignment statement in task construct in taskgroup construct #91927

Open ohno-fj opened 2 months ago

ohno-fj commented 2 months ago
Version of flang-new : 19.0.0(1a498103ee5c4d101e70dc49db11938d8b87b518)/AArch64

The attached program (An assignment statement in task shared construct in taskgroup construct) has incorrect results.
When task shared construct is removed, the results are correct.

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

taskgroup_003_22.f90:

program main
  integer, dimension(10) :: a
  a = 0
  write(6,*) "1 : a = ", a
!$omp parallel private(i)
!$omp sections
!$omp section
!$omp taskgroup
  do i=1,10
!$omp task shared(a)
!$omp atomic write
     a(i) = 1
!$omp end task
  end do
!$omp end taskgroup
  write(6,*) "2 : a = ", a
!$omp end sections
!$omp end parallel
end program main
$ flang-new -fopenmp taskgroup_003_22.f90; ./a.out
 1 : a =  0 0 0 0 0 0 0 0 0 0
 2 : a =  0 0 0 0 0 0 0 0 0 0
$
$ gfortran -fopenmp taskgroup_003_22.f90; ./a.out
 1 : a =            0           0           0           0           0           0           0           0           0           0
 2 : a =            1           1           1           1           1           1           1           1           1           1
 $
$ ifort -qopenmp -diag-disable=10448 taskgroup_003_22.f90; ./a.out
 1 : a =            0           0           0           0           0
           0           0           0           0           0
 2 : a =            1           1           1           1           1
           1           1           1           1           1
$
llvmbot commented 2 months ago

@llvm/issue-subscribers-openmp

Author: None (ohno-fj)

``` Version of flang-new : 19.0.0(1a498103ee5c4d101e70dc49db11938d8b87b518)/AArch64 ``` The attached program (An assignment statement in `task shared` construct in `taskgroup` construct) has incorrect results. When `task shared` construct is removed, the results are correct. The following are the test program, Flang-new, Gfortran and ifort compilation/execution result. taskgroup_003_22.f90: ```fortran program main integer, dimension(10) :: a a = 0 write(6,*) "1 : a = ", a !$omp parallel private(i) !$omp sections !$omp section !$omp taskgroup do i=1,10 !$omp task shared(a) !$omp atomic write a(i) = 1 !$omp end task end do !$omp end taskgroup write(6,*) "2 : a = ", a !$omp end sections !$omp end parallel end program main ``` ``` $ flang-new -fopenmp taskgroup_003_22.f90; ./a.out 1 : a = 0 0 0 0 0 0 0 0 0 0 2 : a = 0 0 0 0 0 0 0 0 0 0 $ ``` ``` $ gfortran -fopenmp taskgroup_003_22.f90; ./a.out 1 : a = 0 0 0 0 0 0 0 0 0 0 2 : a = 1 1 1 1 1 1 1 1 1 1 $ ``` ``` $ ifort -qopenmp -diag-disable=10448 taskgroup_003_22.f90; ./a.out 1 : a = 0 0 0 0 0 0 0 0 0 0 2 : a = 1 1 1 1 1 1 1 1 1 1 $ ```