[Bug fortran/101079] New: [OPENMP] The value of list-item in linear clause in loop construct is not calculated on each iteration

xiao.liu@compiler-dev.com gcc-bugzilla@gcc.gnu.org
Tue Jun 15 13:10:18 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101079

            Bug ID: 101079
           Summary: [OPENMP] The value of list-item in linear clause in
                    loop construct is not calculated on each iteration
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xiao.liu@compiler-dev.com
  Target Milestone: ---

The testcase is,

program p
  use omp_lib
  integer :: i, j
  j = 0
  !$omp parallel num_threads(2)
  !$omp do linear(j:1) schedule(static, 4)
  do i= 1, 10
    print *, i, j, omp_get_thread_num()
  end do
  !$omp end parallel
  print *, "final j: ", j
end program

The result is,
           1           0           0
           2           0           0
           3           0           0
           4           0           0
           9           8           0
          10           8           0
           5           4           1
           6           4           1
           7           4           1
           8           4           1
 final j:            8

It looks like that the calculation for list-item 'j' is invoked after task
dispatching not on each iteration. 

See OpenMP 4.5 specification, 2.15.3.7

"When a linear clause is specified on a construct, the value of the new list
item on each iteration of the associated loop(s) corresponds to the value of
the original list item before entering the construct plus the logical number of
the iteration times linear-step. The value corresponding to the sequentially
last iteration of the associated loop(s) is assigned to the original list
item."

The expected result seems to be that 'j' always equals (i-1), and final j
equals 9.


More information about the Gcc-bugs mailing list