From patchwork Tue Sep 8 20:19:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1360056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmGjP4tzbz9sRK for ; Wed, 9 Sep 2020 06:20:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E3684385702B; Tue, 8 Sep 2020 20:20:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 84A733952535 for ; Tue, 8 Sep 2020 20:20:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 84A733952535 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: 5A3XoQJdYg4arb0y1ii0c6eiELtwgKOKfMYJ8JDZLOF2sIQE91s9pQ3DpFtyzCW+9FjjwUviDU meu/hVJxdNwJlrlEfrq7/hNscZUbuC+/SFfRiAp2FPSwhYtLTpVjxSF5X3zvIAhjnFulXYTe+X QUNPQYmd5Gx7z+ki1ZQYKmEqjDX4glAFchMJXRcRHnneNg2j3A+I2s51Mej6HBlzMXpnl1YZIx +ot11cwRZZ+29RBFUBs1LCKZ8xb5wvl35Y9El5/2QVKP4dmSaNsR1WhQIXbvIpL6p5URsmYlTT AwI= X-IronPort-AV: E=Sophos;i="5.76,406,1592899200"; d="scan'208";a="54886866" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 08 Sep 2020 12:20:02 -0800 IronPort-SDR: XiPARyFEHn8X971v44ofh8Ug9uRTRtftSnabgsuSnZV0exAn5ZJkdvxwbMHBInxbGVV+wWPlDU CxkGnfMfCNVSAepWbiQbgQ3+bh8Q/uAYgu8vxI6l1r5gdVY2qU42yopGaIYLpGc7VHCxvIGqxF sUroHmkqAasmTpN2QjjAZtwBTIqGfECVPIfWVZacdqxJMO47/kKYzpe8q0E68lzIoFJTucJQ0B IOWUiyOcQ3OzqReFWdqmiPZWSXDo4mhu84ggdame0F7bvqJextAROTpBFDEVv0bsu91Y9pxWMi LjU= From: Julian Brown To: Subject: [PATCH] openacc: Fix race condition in Fortran loop collapse tests Date: Tue, 8 Sep 2020 13:19:44 -0700 Message-ID: <20200908201947.43277-1-julian@codesourcery.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ams@codesourcery.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The gangs participating in a gang-partitioned loop are not all guaranteed to complete before some given gang continues to execute beyond that loop. This means that two existing test cases contain a race condition, because a loop that may be gang-partitioned is followed immediately by another loop. The fix is to place the loops in separate parallel regions. Tested with offloading to AMD GCN. I will apply shortly (testsuite change only). Julian 2020-09-08 Julian Brown libgomp/ * testsuite/libgomp.oacc-fortran/collapse-1.f90: Fix race condition. * testsuite/libgomp.oacc-fortran/collapse-2.f90: Likewise. --- libgomp/testsuite/libgomp.oacc-fortran/collapse-1.f90 | 3 +++ libgomp/testsuite/libgomp.oacc-fortran/collapse-2.f90 | 3 +++ 2 files changed, 6 insertions(+) diff --git a/libgomp/testsuite/libgomp.oacc-fortran/collapse-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/collapse-1.f90 index 918c5d0d5b1..4857752f1b0 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/collapse-1.f90 +++ b/libgomp/testsuite/libgomp.oacc-fortran/collapse-1.f90 @@ -14,6 +14,9 @@ program collapse1 end do end do end do + !$acc end parallel + + !$acc parallel !$acc loop collapse(2) reduction(.or.:l) do i = 1, 3 do j = 4, 6 diff --git a/libgomp/testsuite/libgomp.oacc-fortran/collapse-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/collapse-2.f90 index 98b6987750e..0a543909127 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/collapse-2.f90 +++ b/libgomp/testsuite/libgomp.oacc-fortran/collapse-2.f90 @@ -13,6 +13,9 @@ program collapse2 do 164 k = 5, 7 a(i, j, k) = i + j + k 164 end do + !$acc end parallel + + !$acc parallel !$acc loop collapse(2) reduction(.or.:l) firstdo: do i = 1, 3 do j = 4, 6