From patchwork Tue Aug 28 19:19:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 963089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-484618-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="MlXhnzbL"; 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 420JVR3WGlz9s3x for ; Wed, 29 Aug 2018 05:19:59 +1000 (AEST) 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:mime-version:content-type; q=dns; s= default; b=Ge9uOWkoX67ZA/9VmfkHj74+EZ75pwyquF+cpHI8Avc88FU/G811B hG1+vDJhqO8t4tFLSXso+xsbtFqM7rhub+cu6U+bHi02NZnj4If/SOs+Jv5HGV4J 6MwQoMULnNK/H4fSnpkkADNcYJc69wdKJs3mMJRkbkKU0p+2NKGFf8= 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:mime-version:content-type; s= default; bh=vhZgb2kaMUQL41wM/BaareokCg0=; b=MlXhnzbLCSYAqsUReOu+ nRk/dEjDVK8W3dvd70+zKipFr2IoWdQoxy8c5KOrzhqJrywsD/oXVjlIGIEadG9X qyXPXTf1ZDH3POpRzSMuogwDRG2fIcpi+bXTCec6aAo7jJMsPl+cTbECOYL2ZiY7 Bi+aSMCFJTduT3AWJ9RSBsM= Received: (qmail 91578 invoked by alias); 28 Aug 2018 19:19:50 -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 91346 invoked by uid 89); 28 Aug 2018 19:19:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Aug 2018 19:19:46 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fujWj-0000kT-Bo from Julian_Brown@mentor.com ; Tue, 28 Aug 2018 12:19:45 -0700 Received: from squid.athome (137.202.0.90) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Tue, 28 Aug 2018 20:19:40 +0100 Date: Tue, 28 Aug 2018 15:19:34 -0400 From: Julian Brown To: , , Jakub Jelinek Subject: [PATCH, OpenACC] (2/2) Fix implicit mapping for array slices on lexically-enclosing data constructs (PR70828) Message-ID: <20180828151934.1d60ea68@squid.athome> MIME-Version: 1.0 X-IsSubscribed: yes This follow-up patch enables the "inheritance" of mappings for OpenACC data constructs to work also for Fortran assumed-size arrays. Otherwise, such arrays are (arguably, prematurely) bailed out on in the Fortran front-end. Tested alongside the previous patch with offloading to nvptx. OK to apply? Thanks, Julian 2018-08-28 Julian Brown gcc/fortran/ * trans-openmp.c (gfc_omp_finish_clause): Don't raise error for assumed-size array if present in a lexically-enclosing data construct. libgomp/ * testsuite/libgomp.oacc-fortran/pr70828-4.f90: New test. From 9214ffc6bb2ac7cf023f4e62ca324b1a47123ffc Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Tue, 28 Aug 2018 09:01:15 -0700 Subject: [PATCH 2/2] Assumed-size array fix 2018-08-28 Julian Brown gcc/fortran/ * trans-openmp.c (gfc_omp_finish_clause): Don't raise error for assumed-size array if present in a lexically-enclosing data construct. libgomp/ * testsuite/libgomp.oacc-fortran/pr70828-4.f90: New test. --- gcc/fortran/trans-openmp.c | 10 ++++--- .../testsuite/libgomp.oacc-fortran/pr70828-4.f90 | 31 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/pr70828-4.f90 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index f038f4c..86be407 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -1045,9 +1045,13 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p) 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 + /* Assumed-size arrays can't be mapped implicitly, they have to be mapped + explicitly using array sections. An exception is if the array is + mapped explicitly in an enclosing data construct for OpenACC, in which + case we see GOMP_MAP_FORCE_PRESENT here and do not need to raise an + error. */ + if (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_PRESENT + && 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), diff --git a/libgomp/testsuite/libgomp.oacc-fortran/pr70828-4.f90 b/libgomp/testsuite/libgomp.oacc-fortran/pr70828-4.f90 new file mode 100644 index 0000000..01da999 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/pr70828-4.f90 @@ -0,0 +1,31 @@ +! Subarrays declared on data construct: assumed-size array. + +subroutine s1(n, arr) + integer :: n + integer :: arr(*) + + !$acc data copy(arr(5:n-10)) + !$acc parallel loop + do i = 10, n - 10 + arr(i) = i + end do + !$acc end parallel loop + !$acc end data +end subroutine s1 + +program test + integer, parameter :: n = 100 + integer i, data(n) + + data(:) = 0 + + call s1(n, data) + + do i = 1, n + if ((i < 10 .or. i > n-10)) then + if ((data(i) .ne. 0)) call abort + else if (data(i) .ne. i) then + call abort + end if + end do +end program test -- 1.8.1.1