From patchwork Fri Dec 20 11:23:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1214013 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-516360-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.b="yNhPODHZ"; 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 47fRGN0H3wz9sPc for ; Fri, 20 Dec 2019 22:24:10 +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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=K86B3nK9aalpI94n1 4W8JUZPWP7HXeX/RoEmT7irzGlaC1EbyaOwcWjpTS132vefOuQE1Rx02MvPOFtej qL8NtCrwVchy6iYWlpBFkL4hEzL1lEuxmMomyncOHrcETn9umG5cQfzG34rtLzGd sVsrIuM7mhokAObS1rJ3InBe9A= 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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=0KZiIQShGFsG27iz85aajnR HV/k=; b=yNhPODHZRi4tOnjNsux8QbsfFfBmiaPYBQ1paTzGrvuNDjxp9r2nJTZ 34VkINjn1vkpyD11zHJlK7QC9mkfWgiq2rUqO4y/XtYv0464oL4odiSnEjfz7U/4 oqKOT/8j2muZN/kSkRiIeWRQG7GMDmBfJ2c9IaknaQMnwKaTVoj0= Received: (qmail 83040 invoked by alias); 20 Dec 2019 11:23:58 -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 83019 invoked by uid 89); 20 Dec 2019 11:23:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=Rev, openmp.c, UD:openmp.c, openmpc X-HELO: esa4.mentor.iphmx.com Received: from esa4.mentor.iphmx.com (HELO esa4.mentor.iphmx.com) (68.232.137.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Dec 2019 11:23:56 +0000 IronPort-SDR: CuQmeKzbaol3X8f4hMS7IgffRBQJY1QSKws+JEyjo8if2OQ0+iZU0LfzTddcSTwv1c/u37cBsy znxfbFtCWKWj7hXVfwqII9k+CntSeXTagkTaCggoZOCcGcpXGTVrmm6DJRaLu6W2w2DZVYHTrf cqzTecemvK09ShH2MKVSOMXoPVEhkqR57O1g/DfduNoQL0qvZOmn7fS4Yh6QEfPItWRKoDtv+q 1yrYQTeidN/ol5dUM/H2HU6mrAXyX6lCd+DyPqE2+azYGiAmfyGZ7wSoRz7Zp9xrw1NhVLBH9O z9s= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 20 Dec 2019 03:23:55 -0800 IronPort-SDR: NH3vhQMzrlmh9HcFKelNLLHmPBkPwTM3kiwUPGRqiBt4uuCxfob0qoQSQ8GGlvcryPm0p8y7xw mQs6HtS9qZ5q0M/QOBGAEmDwhtxYhtjrVZXzUi2KiPKVD7MjpIDQyziEg7cJsQJC7lEPT7zVOn oETeKI7nAqtqJNKyiQCYgdw8GCMQfp3bDSGoUI6fXTjf0L3o612KQPvr7jTG+/friczTM69Kxh F2reMTTWcQEIqc1eScJOy0/mhly4R+A9oBJJrt2ZUAasviNmpvldv4kJB3tyyBwgL+EfmtdADS Dgk= Subject: [committed] Improve is-coindexed check for OpenACC/OpenMP (was: [PATCH 10/13] OpenACC 2.6 deep copy: Fortran front-end parts) To: Tobias Burnus , Julian Brown , CC: Thomas Schwinge , Jakub Jelinek , , References: <16a3f985-3602-9a61-769d-46abcf958f72@codesourcery.com> From: Tobias Burnus Message-ID: Date: Fri, 20 Dec 2019 12:23:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <16a3f985-3602-9a61-769d-46abcf958f72@codesourcery.com> X-IsSubscribed: yes Julian has committed that patch as Rev. 279628. Follow up regarding coarrays: I had proposed to use 'gfc_is_coindexed' instead of only checking the rightmost array reference. However, it turned out that this check comes too late. (As did the check before Julian's patch.) Namely, when checking in resolve_omp_clauses the gfc_resolve_expr seems to have called – and this changes the expression.  Example: "A[2]" will be converted into a function call "_F.caf_get[[A]]" with -fcoarray=lib — or to "A" with -fcoarray=single. Hence, I moved the coindexed check directly after parsing and added a test case for it. Coarrays by itself should be fine as they act as normal local variables – just that they are allocated by _gfortran_caf_register instead of malloc, stack or static allocation. Committed as Rev. 279637. Cheers, Tobias Index: gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/goacc/coindexed-1.f90 (revision 279637) @@ -0,0 +1,37 @@ +! { dg-do compile } +! { dg-additional-options "-fcoarray=single" } +! +subroutine check_coindexed() +implicit none +type t + integer :: i +end type t +type t2 + integer, allocatable :: i[:] + type(t), allocatable :: x[:] +end type t2 +type(t), allocatable :: A(:)[:], B(:)[:] +type(t) :: D(1)[*], E[*] +type(t2) :: C +save :: D, E + +! Coarrays are fine if they are local/not coindexed: + +!$acc enter data copyin(D(1)%i) +!$acc enter data copyin(A(1)) +!$acc enter data copyin(B(1)%i) +!$acc enter data copyin(C%i) +!$acc enter data copyin(C%x%i) +!$acc enter data copyin(C%i) +!$acc enter data copyin(C%x%i) + +! Does not like the '[' after the identifier: +!$acc enter data copyin(E[2]) ! { dg-error "Syntax error in OpenMP variable list" } + +!$acc enter data copyin(D(1)[2]%i) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(A(1)[4]) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(B(1)[4]%i) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(C%i[2]) ! { dg-error "List item shall not be coindexed" } +!$acc enter data copyin(C%x[4]%i) ! { dg-error "List item shall not be coindexed" } + +end Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 279636) +++ gcc/testsuite/ChangeLog (revision 279637) @@ -1,5 +1,9 @@ 2019-12-20 Tobias Burnus + * gfortran.dg/goacc/coindexed-1.f90: New. + +2019-12-20 Tobias Burnus + * gfortran.dg/goacc/data-clauses.f95: Remove now obsolete dg-error. Index: gcc/fortran/openmp.c =================================================================== --- gcc/fortran/openmp.c (revision 279636) +++ gcc/fortran/openmp.c (revision 279637) @@ -274,6 +274,11 @@ default: break; } + if (gfc_is_coindexed (expr)) + { + gfc_error ("List item shall not be coindexed at %C"); + goto cleanup; + } } gfc_set_sym_referenced (sym); p = gfc_get_omp_namelist (); @@ -4544,9 +4549,6 @@ gfc_error ("%qs in %s clause at %L is not a proper " "array section", n->sym->name, name, &n->where); - else if (gfc_is_coindexed (n->expr)) - gfc_error ("Entry shall not be coindexed in %s " - "clause at %L", name, &n->where); else { int i; Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (revision 279636) +++ gcc/fortran/ChangeLog (revision 279637) @@ -1,3 +1,8 @@ +2019-12-20 Tobias Burnus + + * openmp.c (resolve_omp_clauses): Move is-coindexed check from here ... + (gfc_match_omp_variable_list): ... to here. + 2019-12-19 Julian Brown * openmp.c (resolve_oacc_data_clauses): Don't disallow allocatable