Skip to content

[Flang][OpenMP] Incorrect execution result of a variable in critical construct in parallel construct with default(firstprivate) clause #75767

@ohno-fj

Description

@ohno-fj
Version of flang-new : 18.0.0(76bbbcb41bcf4a1d7a26bb11b78cf97b60ea7d4b) 

The execution result of a variable in critical construct in parallel construct with default(firstprivate) clause is incorrect.
The execution result is correct if:

  • remove critical construct, or
  • change default(firstprivate) to firstprivate(j)

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

snf_ng_01_1.f90:

program main INTEGER :: j j=2 !$OMP PARALLEL default(firstprivate) !$OMP critical j=200 !$OMP END critical !$OMP END PARALLEL if (j.ne.2) print *,'err var j=',j print *,'pass' end program main
$ export OMP_NUM_THREADS=2; flang-new -fopenmp snf_ng_01_1.f90; ./a.out err var j= 200 pass $ 
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snf_ng_01_1.f90; ./a.out pass $ 
$ export OMP_NUM_THREADS=2; ifort -qopenmp snf_ng_01_1.f90; ./a.out pass $ 

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions