From patchwork Wed Mar 18 15:33:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1257598 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 48jDbp4jS8z9sPF for ; Thu, 19 Mar 2020 02:34:12 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B72338A2410; Wed, 18 Mar 2020 15:34:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id D6744389F4F4 for ; Wed, 18 Mar 2020 15:34:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D6744389F4F4 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: bDm4jMTNDre7YqkvIY+CIAX1ejE02QsT+07nEUuYjv4jYz5CILI/fLTmUFIQTIr17X4WDsZfN5 uZXWKL53Hp4Yy6PQICJZAzTCpqpsue1dRWo9+mUdbJPiyM63via5DqbtyH/cZQ9KjfMOMcG90N D129+KwhfwY1q11HJGXl+djEqeA7ypnPQFOOi8t1y/Mddlscu1ESCklP3PIFKvni9NlnPlFEBp rFN0MVkryBVfThWPeOYGFJ9Y3qJQ+zJgh9iGji81TAGtD+ETAR7un4JQYirjLsF9Kir8lBT3xW mFc= X-IronPort-AV: E=Sophos;i="5.70,568,1574150400"; d="diff'?scan'208";a="46886912" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 18 Mar 2020 07:33:41 -0800 IronPort-SDR: KPgY9+XQYfANPmXuoYbFj10aqGPJh117LuEqMNtXyyhdcnSpkGdXypA729UkScxUbPWOpF9WlF Cc8g9Av+VbN/tYim8mthJ1NwgqjHLAsaHacrist8E4TTrGjrtKiarYXfzabMY18z37elVog/aw DJdViSlgPzLhA+o00kfH49KXDiD2MSbJqBzZq/vae8xL6tdz0eJauGqwoZ/1Ki0w1xLS2KErJp H/7X+UHFNOm+u6nK4BbjAdHTjY87A6hFis/yAhwwPjEUvtDRogUNQpZjfHHg/EE9bten0IrceZ MX8= To: gcc-patches From: Tobias Burnus Subject: [Patch, committed] Fix libgomp.oacc-fortran/atomic_capture-1.f90 Message-ID: Date: Wed, 18 Mar 2020 16:33:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-24.2 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The test case does the following: igot = 1 !$acc parallel loop copy (igot, itmp) do i = 1, N !$acc atomic capture iarr(i) = igot igot = max (igot, i) !$acc end atomic end do !$acc end parallel loop And then checks that "all(iarr < N)". That works fine as long as no other code accesses "igot" after the i=N thread has set it. Otherwise, all later accesses to igot will be N – and thus some iarr(i) will be N, causing FAILs. Or in other words: The current code either works if i=N is run last (e.g. serial code) or when all concurrent accesses access "igot" early enough such that none (or at least not i=N) has modified it. While serial ("host") and Nvidia work (PASS), AMDGCN runs did fail before this patch. The OG9 commit by Julian already fixed this but it was never put on the GCC trunk = 10.0, cf. 868d3ad10f2dfd532a494bfe1513200eb361a6de on devel/omp/gcc-9. While Julian's patch modified much more (also a C test case), I have committed a minimal version which only fixes the issue mentioned above for MIN and for MAX. Committed as r10-7252-g26cbcfe5fce57b090b0f2336aad27d84b725f760 Cheers, Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter commit 26cbcfe5fce57b090b0f2336aad27d84b725f760 Author: Tobias Burnus Date: Wed Mar 18 16:28:08 2020 +0100 Fix libgomp.oacc-fortran/atomic_capture-1.f90 2020-03-18 Julian Brown Tobias Burnus * testsuite/libgomp.oacc-fortran/atomic_capture-1.f90: Really make it work concurrently. diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 3dbe94bc982..9a1065fef4e 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,9 @@ +2020-03-18 Julian Brown + Tobias Burnus + + * testsuite/libgomp.oacc-fortran/atomic_capture-1.f90: Really make + it work concurrently. + 2020-03-18 Tobias Burnus * testsuite/libgomp.oacc-c++/firstprivate-mappings-1.C: Add diff --git a/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 index 5a4a1e03f64..536b3f0030c 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 +++ b/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 @@ -275,8 +275,9 @@ program main if (ltmp .neqv. .not. lexp) STOP 33 if (lgot .neqv. lexp) STOP 34 - igot = 1 + igot = 0 iexp = N + iarr = -42 !$acc parallel loop copy (igot, itmp) do i = 1, N @@ -287,13 +288,24 @@ program main end do !$acc end parallel loop + if (igot /= N) stop 107 + itmp = 0 + do i = 1, N + if (iarr(i) == 0) then + itmp = i + exit + end if + end do + ! At most one iarr element can be 0. do i = 1, N - if (.not. (1 <= iarr(i) .and. iarr(i) < iexp)) STOP 35 + if ((iarr(i) == 0 .and. i /= itmp) & + .or. iarr(i) < 0 .or. iarr(i) >= N) STOP 35 end do if (igot /= iexp) STOP 36 - igot = N + igot = N + 1 iexp = 1 + iarr = -42 !$acc parallel loop copy (igot, itmp) do i = 1, N @@ -304,8 +316,18 @@ program main end do !$acc end parallel loop + if (igot /= 1) stop 108 + itmp = N + 1 + ! At most one iarr element can be N+1. + do i = 1, N + if (iarr(i) == N + 1) then + itmp = i + exit + end if + end do do i = 1, N - if (.not. (iarr(i) == 1 .or. iarr(i) == N)) STOP 37 + if ((iarr(i) == N + 1 .and. i /= itmp) & + .or. iarr(i) <= 0 .or. iarr(i) > N + 1) STOP 37 end do if (igot /= iexp) STOP 38