http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49792

           Summary: OpenMP workshare: Wrong result with array assignment
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: pk...@dcs.gla.ac.uk


Based on the thread at http://gcc.gnu.org/ml/fortran/2011-07/msg00194.html

OpenMP 3.1 has in "2.5.4 workshare Construct" (normative text):

"An implementation of the workshare construct must insert any synchronization
that is required to maintain standard Fortran semantics. For example, the
effects of one statement within the structured block must appear to occur
before the execution of succeeding statements, and the evaluation of the right
hand side of an assignment must appear to complete prior to the effects of
assigning to the left hand side."


That seems to fail for:

!$omp parallel workshare
    a(:) = a(n:1:-1)
!$omp end parallel workshare

which cannot be run in parallel as the element access on the RHS cannot be done
in arbitrary order.

Possible solution: Make use of gfortran's dependency.c machinery but only look
for GFC_DEP_EQUAL and GFC_DEP_NODEP - and ignore, e.g., GFC_DEP_BACKWARD or
GFC_DEP_FORWARD, which indicate that the loop order is important.

Reply via email to