From patchwork Tue Oct 27 15:19:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 536707 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 78E161401E7 for ; Wed, 28 Oct 2015 02:20:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=mA/5Fm0R; 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:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=EAndOZOHwp1rSn+g zDx81EYH3UJ5TB5afzoM5LZvYFUr6PtCokbCb//z5B+Ft0kMIiHlpKPhqZb4vCtd o0gpP2l+r3jkafLxxGTgBBTrqMZLKlLvr6V6XMMkMg3Lhs9mfOtpST6zPi469/tC UZtO6YkySOfGI58qKcd8yGWrXHg= 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:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=iC/Ag+YUWVqDduW5UKoEuj FnGGw=; b=mA/5Fm0RX9QIi2WOjamvWyBFFM2eAOYdFw8B+GuNvYh1LaeIwMsAe4 jdrmOo6mr8bMOYpaJyrNmmSoCgK913pfPzeP/I6qWHjIifL6MYcrxHfd6nXCoFsL mWL8+ZVuc688IRCTBVbQWKrYk3/4nQDtzHWPPpSBQbd+zAmoZD28s= Received: (qmail 1774 invoked by alias); 27 Oct 2015 15:20:12 -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 1753 invoked by uid 89); 27 Oct 2015 15:20:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 3 recipients 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, 27 Oct 2015 15:20:10 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zr62f-0003Ci-Nn from Thomas_Schwinge@mentor.com ; Tue, 27 Oct 2015 08:20:06 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Tue, 27 Oct 2015 15:20:04 +0000 From: Thomas Schwinge To: , , Jakub Jelinek CC: Cesar Philippidis , James Norris , Subject: [PR fortran/63865] OpenACC cache directive: match Fortran support with C/C++ (was: [gomp4] OpenACC cache directive maintenance) In-Reply-To: <87389xegvp.fsf@kepler.schwinge.homeip.net> References: <52E158EF.9050009@samsung.com> <52E1595D.9000007@samsung.com> <52E1597E.8070809@samsung.com> <52E15999.6010505@samsung.com> <52E159BD.9040407@samsung.com> <874n4tqink.fsf@schwinge.name> <87d291ehls.fsf@kepler.schwinge.homeip.net> <87a945eh9d.fsf@kepler.schwinge.homeip.net> <87389xegvp.fsf@kepler.schwinge.homeip.net> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Tue, 27 Oct 2015 16:19:49 +0100 Message-ID: <87k2q85ofe.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Wed, 05 Nov 2014 17:44:58 +0100, I wrote: > On Wed, 05 Nov 2014 17:36:46 +0100, I wrote: > > In r217146, I applied the following to gomp-4_0-branch: > > > > [OpenACC cache directive maintenance in C/C++] > I also tried to make this work for Fortran, but didn't manage to (in > a reasonable amount of time, which has not been a lot that I allocated) > ;-) -- would you please have a look at this (but it's not urgent). > > [WIP patch] That never got resolved, so I've now done it myself, directly for trunk. OK to commit? commit 1e0a6332eb8b713afaeb43b554d4aae501a78bf9 Author: Thomas Schwinge Date: Tue Oct 27 12:20:12 2015 +0100 [PR fortran/63865] OpenACC cache directive: match Fortran support with C/C++ gcc/fortran/ PR fortran/63865 * openmp.c (resolve_oacc_cache): Remove function. (gfc_match_oacc_cache): Enable array sections. (resolve_omp_clauses, gfc_resolve_oacc_directive): Change accordingly. * trans-openmp.c (gfc_trans_omp_clauses): Likewise. gcc/testsuite/ PR fortran/63865 * gfortran.dg/goacc/coarray.f95: Expect the OpenACC cache directive to work. * gfortran.dg/goacc/loop-1.f95: Likewise. * gfortran.dg/goacc/cache-1.f95: Likewise, and extend testing. * gfortran.dg/goacc/cray.f95: Likewise. * gfortran.dg/goacc/parameter.f95: Likewise. --- gcc/fortran/openmp.c | 16 ++++------------ gcc/fortran/trans-openmp.c | 22 ++++++++++++++++------ gcc/testsuite/gfortran.dg/goacc/cache-1.f95 | 9 +++++++-- gcc/testsuite/gfortran.dg/goacc/coarray.f95 | 3 ++- gcc/testsuite/gfortran.dg/goacc/cray.f95 | 4 +--- gcc/testsuite/gfortran.dg/goacc/loop-1.f95 | 1 - gcc/testsuite/gfortran.dg/goacc/parameter.f95 | 3 +-- 7 files changed, 31 insertions(+), 27 deletions(-) Grüße Thomas diff --git gcc/fortran/openmp.c gcc/fortran/openmp.c index 3c12d8e..6c78c97 100644 --- gcc/fortran/openmp.c +++ gcc/fortran/openmp.c @@ -1387,7 +1387,8 @@ gfc_match_oacc_cache (void) { gfc_omp_clauses *c = gfc_get_omp_clauses (); match m = gfc_match_omp_variable_list (" (", - &c->lists[OMP_LIST_CACHE], true); + &c->lists[OMP_LIST_CACHE], true, + NULL, NULL, true); if (m != MATCH_YES) { gfc_free_omp_clauses(c); @@ -3107,6 +3108,7 @@ resolve_omp_clauses (gfc_code *code, locus *where, case OMP_LIST_MAP: case OMP_LIST_TO: case OMP_LIST_FROM: + case OMP_LIST_CACHE: for (; n != NULL; n = n->next) { if (n->expr) @@ -3380,7 +3382,6 @@ resolve_omp_clauses (gfc_code *code, locus *where, n->sym->name, name, where); /* FALLTHRU */ case OMP_LIST_DEVICE_RESIDENT: - case OMP_LIST_CACHE: check_symbol_not_pointer (n->sym, *where, name); check_array_not_assumed (n->sym, *where, name); break; @@ -4597,13 +4598,6 @@ resolve_oacc_loop (gfc_code *code) } -static void -resolve_oacc_cache (gfc_code *code ATTRIBUTE_UNUSED) -{ - sorry ("Sorry, !$ACC cache unimplemented yet"); -} - - void gfc_resolve_oacc_declare (gfc_namespace *ns) { @@ -4657,6 +4651,7 @@ gfc_resolve_oacc_directive (gfc_code *code, gfc_namespace *ns ATTRIBUTE_UNUSED) case EXEC_OACC_ENTER_DATA: case EXEC_OACC_EXIT_DATA: case EXEC_OACC_WAIT: + case EXEC_OACC_CACHE: resolve_omp_clauses (code, &code->loc, code->ext.omp_clauses, NULL, true); break; @@ -4665,9 +4660,6 @@ gfc_resolve_oacc_directive (gfc_code *code, gfc_namespace *ns ATTRIBUTE_UNUSED) case EXEC_OACC_LOOP: resolve_oacc_loop (code); break; - case EXEC_OACC_CACHE: - resolve_oacc_cache (code); - break; default: break; } diff --git gcc/fortran/trans-openmp.c gcc/fortran/trans-openmp.c index def8afb..3be9f51 100644 --- gcc/fortran/trans-openmp.c +++ gcc/fortran/trans-openmp.c @@ -1778,9 +1778,6 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, case OMP_LIST_DEVICE_RESIDENT: clause_code = OMP_CLAUSE_DEVICE_RESIDENT; goto add_clause; - case OMP_LIST_CACHE: - clause_code = OMP_CLAUSE__CACHE_; - goto add_clause; add_clause: omp_clauses @@ -2159,14 +2156,27 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, break; case OMP_LIST_TO: case OMP_LIST_FROM: + case OMP_LIST_CACHE: for (; n != NULL; n = n->next) { if (!n->sym->attr.referenced) continue; - tree node = build_omp_clause (input_location, - list == OMP_LIST_TO - ? OMP_CLAUSE_TO : OMP_CLAUSE_FROM); + switch (list) + { + case OMP_LIST_TO: + clause_code = OMP_CLAUSE_TO; + break; + case OMP_LIST_FROM: + clause_code = OMP_CLAUSE_FROM; + break; + case OMP_LIST_CACHE: + clause_code = OMP_CLAUSE__CACHE_; + break; + default: + gcc_unreachable (); + } + tree node = build_omp_clause (input_location, clause_code); if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL) { tree decl = gfc_get_symbol_decl (n->sym); diff --git gcc/testsuite/gfortran.dg/goacc/cache-1.f95 gcc/testsuite/gfortran.dg/goacc/cache-1.f95 index 746cf02..2aa9e05 100644 --- gcc/testsuite/gfortran.dg/goacc/cache-1.f95 +++ gcc/testsuite/gfortran.dg/goacc/cache-1.f95 @@ -3,10 +3,15 @@ program test implicit none - integer :: i, d(10) + integer :: i, d(10), e(5,13) do concurrent (i=1:5) !$acc cache (d) + !$acc cache (d(1:3)) + !$acc cache (d(i:i+2)) + + !$acc cache (e) + !$acc cache (e(1:3,2:4)) + !$acc cache (e(i:i+2,i+1:i+3)) enddo end -! { dg-prune-output "unimplemented" } diff --git gcc/testsuite/gfortran.dg/goacc/coarray.f95 gcc/testsuite/gfortran.dg/goacc/coarray.f95 index 4f1224e..130ffc3 100644 --- gcc/testsuite/gfortran.dg/goacc/coarray.f95 +++ gcc/testsuite/gfortran.dg/goacc/coarray.f95 @@ -9,6 +9,7 @@ contains implicit none integer :: i integer, codimension[*] :: a + ! { dg-excess-errors "sorry, unimplemented: directive not yet implemented" } !$acc declare device_resident (a) !$acc data copy (a) !$acc end data @@ -16,6 +17,7 @@ contains !$acc end data !$acc parallel private (a) !$acc end parallel + ! { dg-excess-errors "sorry, unimplemented: directive not yet implemented" } !$acc host_data use_device (a) !$acc end host_data !$acc parallel loop reduction(+:a) @@ -32,4 +34,3 @@ contains !$acc update self (a) end subroutine oacc1 end module test -! { dg-prune-output "ACC cache unimplemented" } diff --git gcc/testsuite/gfortran.dg/goacc/cray.f95 gcc/testsuite/gfortran.dg/goacc/cray.f95 index 52789fe..a35ab0d 100644 --- gcc/testsuite/gfortran.dg/goacc/cray.f95 +++ gcc/testsuite/gfortran.dg/goacc/cray.f95 @@ -24,8 +24,7 @@ contains !$acc end parallel loop !$acc parallel loop do i = 1,5 - ! Subarrays are not implemented yet - !$acc cache (pointee) ! TODO: This must fail, as in openacc-1_0-branch + !$acc cache (pointee) ! { dg-error "Cray pointee" } enddo !$acc end parallel loop !$acc update device (pointee) ! { dg-error "Cray pointee" } @@ -53,4 +52,3 @@ contains !$acc update self (ptr) end subroutine oacc1 end module test -! { dg-prune-output "ACC cache unimplemented" } diff --git gcc/testsuite/gfortran.dg/goacc/loop-1.f95 gcc/testsuite/gfortran.dg/goacc/loop-1.f95 index e1b2dfd..817039f 100644 --- gcc/testsuite/gfortran.dg/goacc/loop-1.f95 +++ gcc/testsuite/gfortran.dg/goacc/loop-1.f95 @@ -168,4 +168,3 @@ subroutine test1 end subroutine test1 end module test ! { dg-prune-output "Deleted" } -! { dg-prune-output "ACC cache unimplemented" } diff --git gcc/testsuite/gfortran.dg/goacc/parameter.f95 gcc/testsuite/gfortran.dg/goacc/parameter.f95 index 454924a..8427461 100644 --- gcc/testsuite/gfortran.dg/goacc/parameter.f95 +++ gcc/testsuite/gfortran.dg/goacc/parameter.f95 @@ -21,7 +21,7 @@ contains !$acc end parallel loop !$acc parallel loop do i = 1,5 - !$acc cache (a) ! TODO: This must fail, as in openacc-1_0-branch + !$acc cache (a) ! { dg-error "not a variable" } enddo !$acc end parallel loop !$acc update device (a) ! { dg-error "not a variable" } @@ -29,4 +29,3 @@ contains !$acc update self (a) ! { dg-error "not a variable" } end subroutine oacc1 end module test -! { dg-prune-output "ACC cache unimplemented" }