From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19171 invoked by alias); 20 Jul 2011 09:50:18 -0000 Received: (qmail 19162 invoked by uid 22791); 20 Jul 2011 09:50:17 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Jul 2011 09:50:03 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49792] New: OpenMP workshare: Wrong result with array assignment X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 20 Jul 2011 09:50:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg01642.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: pkeir@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.