From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50981 invoked by alias); 7 Aug 2018 22:04:09 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 50958 invoked by uid 89); 7 Aug 2018 22:04:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.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=resolver, H*r:0700 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, 07 Aug 2018 22:04:07 +0000 Received: from svr-orw-mbx-01.mgc.mentorg.com ([147.34.90.201]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fnA5F-0005KG-Mz from Cesar_Philippidis@mentor.com ; Tue, 07 Aug 2018 15:04:05 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Tue, 7 Aug 2018 15:04:03 -0700 From: Cesar Philippidis Subject: [PATCH][OpenACC] Don't error on implicitly private induction variables in gfortran To: Fortran List , "gcc-patches@gcc.gnu.org" Message-ID: <0ff2fb49-36d3-6a12-b2be-d4f22ff8386d@codesourcery.com> Date: Tue, 07 Aug 2018 22:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BC44E7731AD36A4B4D042BEB" X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00030.txt.bz2 --------------BC44E7731AD36A4B4D042BEB Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-length: 382 At present, the fortran FE reports an error if the user adds an explicit private clause to an induction variable used by an acc loop. This patch teaches the fortran acc block resolver how to cope with "duplicate" private clauses, so that it doesn't error anymore. Is this patch OK for trunk? I bootstrapped and regression tested it for x86_64 with nvptx offloading. Thanks, Cesar --------------BC44E7731AD36A4B4D042BEB Content-Type: text/x-patch; name="0001-OpenACC-Don-t-error-on-implicitly-private-induction-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-OpenACC-Don-t-error-on-implicitly-private-induction-.pa"; filename*1="tch" Content-length: 1925 >From 576b2a7d5574400f067ec309929b38b324d8c6f6 Mon Sep 17 00:00:00 2001 From: Cesar Philippidis Date: Fri, 27 Jan 2017 14:58:16 +0000 Subject: [PATCH] [OpenACC] Don't error on implicitly private induction variables in gfortran 2018-XX-YY Cesar Philippidis gcc/fortran/ * openmp.c (gfc_resolve_oacc_blocks): Populate list of private variables. gcc/testsuite/ * gfortran.dg/goacc/implicitly-private.f90: New test. --- gcc/fortran/openmp.c | 5 +++++ gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index b346b51..798c5fa 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5951,6 +5951,7 @@ void gfc_resolve_oacc_blocks (gfc_code *code, gfc_namespace *ns) { fortran_omp_context ctx; + gfc_omp_namelist *n; resolve_oacc_loop_blocks (code); @@ -5961,6 +5962,10 @@ gfc_resolve_oacc_blocks (gfc_code *code, gfc_namespace *ns) ctx.is_openmp = false; omp_current_ctx = &ctx; + if (code->ext.omp_clauses) + for (n = code->ext.omp_clauses->lists[OMP_LIST_PRIVATE]; n; n = n->next) + ctx.private_iterators->add (n->sym); + gfc_resolve_blocks (code->block, ns); omp_current_ctx = ctx.previous; diff --git a/gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 b/gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 new file mode 100644 index 0000000..a687d8a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 @@ -0,0 +1,12 @@ +! Ensure that implicitly private variables do not clash with those +! that are explicitly private. + +program main + implicit none + + integer i + + !$acc parallel loop private(i) + do i = 1, 100 + end do +end program main -- 2.7.4 --------------BC44E7731AD36A4B4D042BEB--