Skip to content

[Flang][OpenMP]Incorrect execution result when reduction-identifier(+) is used in REDUCTION clause during the reduction(-) operation #64245

Closed
@ohno-fj

Description

@ohno-fj
Version of flang-new : 17.0.0(359f170f5f712ee714193b46bad45a45656b2c59)

Using the reduction-identifier(+) in the REDUCTION clause during a reduction(-) operation results in incorrect execution.

The result is correct when the test program is modified as follows:

  • Before the change
         ia = ia-i
  • After the change
         ia = ia+(-i)

z012.f90:

      program main
      integer*4 ia
      integer*4 :: loop=10
      ia = 0
!$omp parallel do reduction(+:ia)
      do i=1, loop
         ia = ia-i
      end do
!$omp end parallel do
      write(*,*) "     ia=",ia,"  It must be -55"
      end
$ export OMP_NUM_THREADS=2; flang-new -fopenmp z012.f90; ./a.out
      ia= 55   It must be -55
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp z012.f90; ./a.out
      ia=         -55   It must be -55
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp z012.f90; ./a.out
      ia=         -55   It must be -55
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions