From patchwork Wed Dec 21 16:19:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 707868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tkKd25prQz9t0G for ; Thu, 22 Dec 2016 03:20:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="baF06mXo"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=wU4szxgdO8aFrF5iJ6j/Hs6Il5kMHDwBjvHXXSKtSSY GjlnrCPOEVXH+wvS3MRf4e2mag3z8bHjgX81rViTArjhZ8gWcBXFjUZkJFJ+6us0 2pjueTXayP/ci5gNhwUoT6b7z5WwhN/B41uoYt0WNbfiwOPnEmjoT0za2bFdnnEg = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=QRXRw/qOLhz9fmdwtMNZk9RxMyw=; b=baF06mXoFdzhHsfpF bMHcR2AFQba5fxCcoBGvkQUbxYsWyzb3PhshY6IW35O/JF/S+K11T9psRs2Av2nL ATzPvT+0UwAvuKCNkjgegBfr1ztVnUbDien12ceupIOtePzP6ZOknBScsnjM7EUp 5WjVinexGEoRywuflPOUiXsZo4= Received: (qmail 109181 invoked by alias); 21 Dec 2016 16:19:59 -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 109156 invoked by uid 89); 21 Dec 2016 16:19:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=aas, 3811, raised, queued X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Dec 2016 16:19:57 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1C0BC04B93D; Wed, 21 Dec 2016 16:19:55 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBLGJr2s029273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 21 Dec 2016 11:19:55 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id uBLGJpkV029145; Wed, 21 Dec 2016 17:19:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id uBLGJoR3029144; Wed, 21 Dec 2016 17:19:50 +0100 Date: Wed, 21 Dec 2016 17:19:50 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [committed] Disallow explicit or implicit OpenMP mapping of assumed-size arrays (PR fortran/78866) Message-ID: <20161221161950.GY21933@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! At least in my reading of the standard OpenMP 4.[05] does not disallow explicit or implicit mapping of assumed-size arrays, but it is IMNSHO a defect in the standard, it is something that can't be really supported because the compiler does not know the size of the assumed size array. What works and is supported is explicit mapping of array section with the upper bound specificied, then you give it the size through the array section. ifort also rejects it. I've raised an OpenMP ticket for this. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for 6.4. 2016-12-21 Jakub Jelinek PR fortran/78866 * openmp.c (resolve_omp_clauses): Diagnose assumed size arrays in OpenMP map, to and from clauses. * trans-openmp.c: Include diagnostic-core.h, temporarily redefining GCC_DIAG_STYLE to __gcc_tdiag__. (gfc_omp_finish_clause): Diagnose implicitly mapped assumed size arrays. * gfortran.dg/gomp/map-1.f90: Add expected error. * gfortran.dg/gomp/pr78866-1.f90: New test. * gfortran.dg/gomp/pr78866-2.f90: New test. Jakub --- gcc/fortran/openmp.c.jj 2016-11-10 12:34:12.000000000 +0100 +++ gcc/fortran/openmp.c 2016-12-21 10:36:25.535619047 +0100 @@ -4382,6 +4382,11 @@ resolve_omp_clauses (gfc_code *code, gfc else resolve_oacc_data_clauses (n->sym, n->where, name); } + else if (list != OMP_CLAUSE_DEPEND + && n->sym->as + && n->sym->as->type == AS_ASSUMED_SIZE) + gfc_error ("Assumed size array %qs in %s clause at %L", + n->sym->name, name, &n->where); if (list == OMP_LIST_MAP && !openacc) switch (code->op) { --- gcc/fortran/trans-openmp.c.jj 2016-12-15 10:26:19.000000000 +0100 +++ gcc/fortran/trans-openmp.c 2016-12-21 13:11:34.131670305 +0100 @@ -38,6 +38,11 @@ along with GCC; see the file COPYING3. #include "gomp-constants.h" #include "omp-general.h" #include "omp-low.h" +#undef GCC_DIAG_STYLE +#define GCC_DIAG_STYLE __gcc_tdiag__ +#include "diagnostic-core.h" +#undef GCC_DIAG_STYLE +#define GCC_DIAG_STYLE __gcc_gfc__ int ompws_flags; @@ -1039,6 +1044,21 @@ gfc_omp_finish_clause (tree c, gimple_se return; tree decl = OMP_CLAUSE_DECL (c); + + /* Assumed-size arrays can't be mapped implicitly, they have to be + mapped explicitly using array sections. */ + if (TREE_CODE (decl) == PARM_DECL + && GFC_ARRAY_TYPE_P (TREE_TYPE (decl)) + && GFC_TYPE_ARRAY_AKIND (TREE_TYPE (decl)) == GFC_ARRAY_UNKNOWN + && GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (decl), + GFC_TYPE_ARRAY_RANK (TREE_TYPE (decl)) - 1) + == NULL) + { + error_at (OMP_CLAUSE_LOCATION (c), + "implicit mapping of assumed size array %qD", decl); + return; + } + tree c2 = NULL_TREE, c3 = NULL_TREE, c4 = NULL_TREE; if (POINTER_TYPE_P (TREE_TYPE (decl))) { --- gcc/testsuite/gfortran.dg/gomp/map-1.f90.jj 2015-01-15 23:39:06.000000000 +0100 +++ gcc/testsuite/gfortran.dg/gomp/map-1.f90 2016-12-21 13:29:03.333952262 +0100 @@ -70,7 +70,7 @@ subroutine test(aas) ! { dg-error "Rightmost upper bound of assumed size array section not specified" "" { target *-*-* } 68 } ! { dg-error "'aas' in MAP clause at \\\(1\\\) is not a proper array section" "" { target *-*-* } 68 } - !$omp target map(aas) ! { dg-error "The upper bound in the last dimension must appear" "" { xfail *-*-* } } + !$omp target map(aas) ! { dg-error "Assumed size array" } !$omp end target !$omp target map(aas(5:7)) --- gcc/testsuite/gfortran.dg/gomp/pr78866-1.f90.jj 2016-12-21 11:16:06.202498432 +0100 +++ gcc/testsuite/gfortran.dg/gomp/pr78866-1.f90 2016-12-21 11:12:14.000000000 +0100 @@ -0,0 +1,19 @@ +! PR fortran/78866 +! { dg-do compile } + +subroutine pr78866(x) + integer :: x(*) +!$omp target map(x) ! { dg-error "Assumed size array" } + x(1) = 1 +!$omp end target +!$omp target data map(tofrom: x) ! { dg-error "Assumed size array" } +!$omp target update to(x) ! { dg-error "Assumed size array" } +!$omp target update from(x) ! { dg-error "Assumed size array" } +!$omp end target data +!$omp target map(x(:23)) ! { dg-bogus "Assumed size array" } + x(1) = 1 +!$omp end target +!$omp target map(x(:)) ! { dg-error "upper bound of assumed size array section" } + x(1) = 1 ! { dg-error "not a proper array section" "" { target *-*-* } .-1 } +!$omp end target +end --- gcc/testsuite/gfortran.dg/gomp/pr78866-2.f90.jj 2016-12-21 13:23:21.100447198 +0100 +++ gcc/testsuite/gfortran.dg/gomp/pr78866-2.f90 2016-12-21 13:14:52.000000000 +0100 @@ -0,0 +1,9 @@ +! PR fortran/78866 +! { dg-do compile } + +subroutine pr78866(x) + integer :: x(*) +!$omp target ! { dg-error "implicit mapping of assumed size array" } + x(1) = 1 +!$omp end target +end