From patchwork Thu Feb 20 17:21:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1241579 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519863-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=m4irp1X1; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48NhGK6z93z9sR4 for ; Fri, 21 Feb 2020 04:21:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=pI7li75ShXzb0E0ZQKRElnmXFrWDkBb8d5KjDTnzwHQgLqnmPJ Ur8cp7IwRkEz1Fo2HX0s/XzhHdy8xXNfKI/c/aZ+evUY2/KKxobBlllIGvTSB5/m Hg+x5JHcSW9Ine+Ia9W7q8fVE3CE/riVdA2Tk7qWM+nUKBgSwOI62lEvY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=KXtffRQFDIHtD/TBIagFiKz3GFM=; b=m4irp1X1w5SgY3vaVE8/ sqYWBPTFgk94nNlPU3wnVyY3Q/7A0XuLdpJ6QbavmEprD33kIb3RCEvldzPccJNr N1eWcJoXkWZjygXohyEXus9CjfbAsGG66vs3iGS+CYjkYGy6+T/mGdkhrGpaFx4W TnifM/ytwIg24ViX7FldrIQ= Received: (qmail 59933 invoked by alias); 20 Feb 2020 17:21:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 58614 invoked by uid 89); 20 Feb 2020 17:21:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=Tobias, Burnus, 93825, !$acc X-HELO: esa3.mentor.iphmx.com Received: from esa3.mentor.iphmx.com (HELO esa3.mentor.iphmx.com) (68.232.137.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Feb 2020 17:21:34 +0000 IronPort-SDR: fEh5LVq3fX+BJa+UufLiiVd00ZuLyqrU+ykrPMq7LrVICmSpnTYe9U7mNDI0ifG1Y73EO1GKzk HI4ki42V/IKc3YxFzDxVjgSheGLT4exwP/eTlgcSPLAZqtcCVCKwSlDUd/ox5E26tTg1umhJzq wW7V5+tVIW5N+/F23Mu6sj2k43hKGoWwo4UJpd1vlIngn2ETR6qNuN6JfyZXfhoVULnlQgxwjI mhP9NaQp8paJT18UE1xR2wM2vEmGflTPjl8ClctIBN625y9QOcoizmqd5tprv0c/davmJNzhHW 0+0= Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 20 Feb 2020 09:21:33 -0800 IronPort-SDR: meWYOWv/qdBNMB/TtzJtkDBI6AYL9xE4gCqcauZXogtyIsnn83h3vzofI/A9I8Q/98lqYEgVbv 3I21plJL6B+SHjm1mFbFUN5nRW1i2fJutIv0gYtt27YkKNwf4wMaD4n3xlecI47IEiFTRL2sln 9+T1JOe1V7akbAoDr/A1LKf/CFyoAAckgot190attDWrAnaSWM3OcQkFuUOEEt+GhZR4ojEAMr iDZ6c1S0OpUru1UhE2EALcGhV/SLT8JXCLKO+/K6mPddwQwSiBV2YDF49fJeJVIlCUPeOoKp6P 30Q= To: gcc-patches , fortran From: Tobias Burnus Subject: [patch, committed] OpenACC's tile clause fix for implicit typing (PR93825) Message-ID: <39096dbd-a2a4-6fe2-3c43-e97ca72a9cf8@codesourcery.com> Date: Thu, 20 Feb 2020 18:21:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 X-IsSubscribed: yes I committed it as simple and obvious patch, but of course I am happy for comment :-) OpenACC loop directives can have both 'collapse' and 'tile' clauses. They are resolved as follows: * gfc_resolve_oacc_blocks is called, which in turn calls resolve_oacc_loop_blocks followed by gfc_resolve_blocks, * Then gfc_resolve_oacc_directive is called, which calls resolve_oacc_loop It turned out that one needs to handle first the checks in resolve_oacc_loop_blocks for the clauses itself – if one moved this call after the gfc_resolve_blocks in the callee gfc_resolve_oacc_blocks it won't work. On the other hand, if one directly calls resolve_oacc_nested_loops within resolve_oacc_loop_blocks, the loop data (code->ext.iterator) is not yet resolved. – That's visible in the included test case as the variables are still BT_UNKNOWN instead of implicitly being typed to integer. Hence, the solution is to keep the clause checks in resolve_oacc_loop_blocks but move the checking of the loop data (via resolve_oacc_nested_loops) to resolve_oacc_loop — next to the handling for collapsed, which also makes sense code-organization wise. NOTE: In line with the tree-conversion code, which does ignore "collapse", this check ignores "collapse" in terms of checking. That only matters if "n" in collapse(n) is greater than the "n" in "tile" as otherwise all the check are already done for "tile". Installed as Rev. r10-6761-g2c52b2884ba10b1c5050fe066bae651680c8ebae Cheers, Tobias commit 2c52b2884ba10b1c5050fe066bae651680c8ebae Author: Tobias Burnus Date: Thu Feb 20 18:11:32 2020 +0100 OpenACC's tile clause fix for implicit typing (PR93825) 2020-02-20 Tobias Burnus PR fortran/93825 * openmp.c (resolve_oacc_loop_blocks): Move call to resolve_oacc_nested_loops from here ... (resolve_oacc_loop): ... to here. PR fortran/93825 * gfortran.dg/goacc/tile-3.f90: New. --- gcc/fortran/ChangeLog | 25 ++++++++++++++++--------- gcc/fortran/openmp.c | 15 ++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/goacc/tile-3.f90 | 13 +++++++++++++ 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7547dccd79a..6795b82b74c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2020-02-20 Tobias Burnus + + PR fortran/93825 + * openmp.c (resolve_oacc_loop_blocks): Move call to + resolve_oacc_nested_loops from here ... + (resolve_oacc_loop): ... to here. + 2020-02-18 Mark Eggleston PR fortran/93714 @@ -29,15 +36,15 @@ 2020-02-10 Andrew Benson - PR fortran/83113 - * array.c: Do not attempt to set the array spec for a submodule - function symbol (as it has already been set in the corresponding - module procedure interface). - * symbol.c: Do not reject duplicate POINTER, ALLOCATABLE, or - DIMENSION attributes in declarations of a submodule function. - * gfortran.h: Add a macro that tests for a module procedure in a - submodule. - * gfortran.dg/pr83113.f90: New test. + PR fortran/83113 + * array.c: Do not attempt to set the array spec for a submodule + function symbol (as it has already been set in the corresponding + module procedure interface). + * symbol.c: Do not reject duplicate POINTER, ALLOCATABLE, or + DIMENSION attributes in declarations of a submodule function. + * gfortran.h: Add a macro that tests for a module procedure in a + submodule. + * gfortran.dg/pr83113.f90: New test. 2020-02-03 Julian Brown Tobias Burnus diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index b885e86c658..35f6b2f4938 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -6192,10 +6192,8 @@ resolve_oacc_loop_blocks (gfc_code *code) if (code->ext.omp_clauses->tile_list) { gfc_expr_list *el; - int num = 0; for (el = code->ext.omp_clauses->tile_list; el; el = el->next) { - num++; if (el->expr == NULL) { /* NULL expressions are used to represent '*' arguments. @@ -6213,7 +6211,6 @@ resolve_oacc_loop_blocks (gfc_code *code) &code->loc); } } - resolve_oacc_nested_loops (code, code->block->next, num, "tiled"); } } @@ -6266,6 +6263,18 @@ resolve_oacc_loop (gfc_code *code) do_code = code->block->next; collapse = code->ext.omp_clauses->collapse; + /* Both collapsed and tiled loops are lowered the same way, but are not + compatible. In gfc_trans_omp_do, the tile is prioritized. */ + if (code->ext.omp_clauses->tile_list) + { + int num = 0; + gfc_expr_list *el; + for (el = code->ext.omp_clauses->tile_list; el; el = el->next) + ++num; + resolve_oacc_nested_loops (code, code->block->next, num, "tiled"); + return; + } + if (collapse <= 0) collapse = 1; resolve_oacc_nested_loops (code, do_code, collapse, "collapsed"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a54505ed73e..89acd3f518f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-20 Tobias Burnus + + PR fortran/93825 + * gfortran.dg/goacc/tile-3.f90: New. + 2020-02-19 Marek Polacek PR c++/93169 - wrong-code with a non-constexpr constructor. diff --git a/gcc/testsuite/gfortran.dg/goacc/tile-3.f90 b/gcc/testsuite/gfortran.dg/goacc/tile-3.f90 new file mode 100644 index 00000000000..00b4f1df2d8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/tile-3.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! +! PR fortran/93825 +! +! Check that implicit typing works + +program p + !$acc parallel loop tile(2,2) + do i = 1, 8 + do j = 1, 8 + end do + end do +end