Skip to content

[Flang][OpenMP] Incorrect execution result of a do-variable defined as shared in parallel construct #78938

Closed
@ohno-fj

Description

@ohno-fj
Version of flang-new : 18.0.0(0fe86f9c518fb1296bba8d66ce495f9dfff2c435)

A do-variable defined as shared in parallel construct has an incorrect value after executing parallel construct.
A do-variable is executing by private, not shared.

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

snggz567_22.f90:

subroutine s1
  ip=100
  ip2=-100
!$omp parallel shared(ip) private(ip2)
  DO ip = 0, 1
  END DO
  DO ip2 = 0, 1
  END DO
!$omp end parallel
  print *,'ip  shared  :',ip
  print *,'ip2 private :',ip2
end subroutine s1

program main
  call s1
end program main
$ export OMP_NUM_THREADS=2; flang-new -fopenmp snggz567_22.f90; ./a.out
 ip  shared  : 100
 ip2 private : -100
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snggz567_22.f90; ./a.out
 ip  shared  :           2
 ip2 private :        -100
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp snggz567_22.f90; ./a.out
 ip  shared  :           2
 ip2 private :        -100
$

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions