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

            Bug ID: 104864
           Summary: fortran openmp taskloop firstprivate and lastprivate
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: han...@compiler-dev.com
  Target Milestone: ---

program main
  use omp_lib
  Implicit None
  Logical :: init
  Integer accum1,accum2,answer,i
  Integer :: x(50)
  Do i=1,Size(x,1)
    x(i) = i
  End Do
  Call omp_set_schedule(1,10)
  !$OMP PARALLEL NUM_THREADS(15) DEFAULT(none) SHARED(accum1,answer,x)
PRIVATE(init,accum2)
    accum1 = -555
    !$OMP BARRIER
    accum2 = 0
    init = .True.
    !$OMP taskloop LASTPRIVATE(accum1) FIRSTPRIVATE(accum1)
      Do i=1,Size(x,1)
        If (init) Then
          If (accum1/=-555) Stop 'FAIL firstpriv'
          accum1 = 0
          init = .False.
        End If
        accum1 = accum1 + x(i)
        accum2 = accum2 + x(i)
        If (accum1/=accum2) Stop 'FAIL accum incon'
        If (i==Size(x,1)) answer = accum1
      End Do
    !$OMP END taskloop
    If (accum1/=answer) Stop 'FAIL accum1 lastprivate'
  !$OMP END PARALLEL
  Print *,'ok'
End Program



gfortran-10 a.f90 -fopenmp 

run a.out many times, most of the time run ok, but some time run result like
this:

./a.out 
STOP STOP STOP FAIL firstpriv
FAIL firstpriv
FAIL firstpriv

I think  one thread the firstpriv assignment statement really execute after
some  
 threads execute some do loop and return the lastprivate value to the original
list item accum1.

can taskloop construct should add a  BARRIER after task_dup initial value of
accum1 from the original list?

Reply via email to