From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68017 invoked by alias); 3 Dec 2015 17:52:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 67995 invoked by uid 89); 3 Dec 2015 17:52:00 -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, 2 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; Thu, 03 Dec 2015 17:51:58 +0000 Received: from svr-orw-fem-06.mgc.mentorg.com ([147.34.97.120]) by relay1.mentorg.com with esmtp id 1a4Y2t-0000Tj-6O from Cesar_Philippidis@mentor.com ; Thu, 03 Dec 2015 09:51:55 -0800 Received: from [127.0.0.1] (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.3.224.2; Thu, 3 Dec 2015 09:51:54 -0800 From: Cesar Philippidis Subject: [gomp4] backport fortran array reduction changes To: "gcc-patches@gcc.gnu.org" , Fortran List , Thomas Schwinge Message-ID: <5660813A.8080203@mentor.com> Date: Thu, 03 Dec 2015 17:52:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080402090509050808040909" X-SW-Source: 2015-12/txt/msg00470.txt.bz2 --------------080402090509050808040909 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-length: 403 This patch backports the recent array reduction changes in trunk to gomp-4_0-branch. It's mostly straightforward, except I couldn't include changes to reduction-2.f95 because the gimplifier is reordering the loop clauses slightly different in trunk and gomp4. I'm not sure why. Thomas, that's something to keep in mind next time you do a trunk merge. I've applied this patch to gomp-4_0-branch. Cesar --------------080402090509050808040909 Content-Type: text/x-patch; name="gomp4-gfc_array-reductions.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gomp4-gfc_array-reductions.diff" Content-length: 8118 2015-12-03 Cesar Philippidis gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Allow subarrays for acc reductions. (resolve_omp_clauses): Error on any acc reductions on arrays. gcc/testsuite/ * gfortran.dg/goacc/array-reduction.f90: New test. * gfortran.dg/goacc/assumed.f95: Update expected diagnostics. * gfortran.dg/goacc/coarray.f95: Likewise. * gfortran.dg/goacc/coarray_2.f90: Likewise. * gfortran.dg/goacc/reduction.f95: Likewise. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 0e87f54..e7f61f2 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -997,7 +997,8 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask, if (gfc_match_omp_variable_list (" :", &c->lists[OMP_LIST_REDUCTION], - false, NULL, &head) == MATCH_YES) + false, NULL, &head, openacc) + == MATCH_YES) { gfc_omp_namelist *n; if (rop == OMP_REDUCTION_NONE) @@ -3429,6 +3430,11 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, n->sym->name, &n->where); else n->sym->mark = 1; + + /* OpenACC does not support reductions on arrays. */ + if (n->sym->as) + gfc_error ("Array %qs is not permitted in reduction at %L", + n->sym->name, &n->where); } } diff --git a/gcc/testsuite/gfortran.dg/goacc/array-reduction.f90 b/gcc/testsuite/gfortran.dg/goacc/array-reduction.f90 new file mode 100644 index 0000000..d71c400 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/array-reduction.f90 @@ -0,0 +1,74 @@ +program test + implicit none + integer a(10), i + + a(:) = 0 + + ! Array reductions. + + !$acc parallel reduction (+:a) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a = a + 1 + end do + !$acc end parallel + + !$acc parallel + !$acc loop reduction (+:a) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a = a + 1 + end do + !$acc end parallel + + !$acc kernels + !$acc loop reduction (+:a) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a = a + 1 + end do + !$acc end kernels + + ! Subarray reductions. + + !$acc parallel reduction (+:a(1:5)) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a = a + 1 + end do + !$acc end parallel + + !$acc parallel + !$acc loop reduction (+:a(1:5)) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a = a + 1 + end do + !$acc end parallel + + !$acc kernels + !$acc loop reduction (+:a(1:5)) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a = a + 1 + end do + !$acc end kernels + + ! Reductions on array elements. + + !$acc parallel reduction (+:a(1)) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a(1) = a(1) + 1 + end do + !$acc end parallel + + !$acc parallel + !$acc loop reduction (+:a(1)) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a(1) = a(1) + 1 + end do + !$acc end parallel + + !$acc kernels + !$acc loop reduction (+:a(1)) ! { dg-error "Array 'a' is not permitted in reduction" } + do i = 1, 10 + a(1) = a(1) + 1 + end do + !$acc end kernels + + print *, a +end program test diff --git a/gcc/testsuite/gfortran.dg/goacc/assumed.f95 b/gcc/testsuite/gfortran.dg/goacc/assumed.f95 index 3287241..4efe5a2 100644 --- a/gcc/testsuite/gfortran.dg/goacc/assumed.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/assumed.f95 @@ -45,3 +45,6 @@ contains !$acc update self (a) ! { dg-error "Assumed rank" } end subroutine assumed_rank end module test + +! { dg-error "Array 'a' is not permitted in reduction" "" { target "*-*-*" } 18 } +! { dg-error "Array 'a' is not permitted in reduction" "" { target "*-*-*" } 39 } diff --git a/gcc/testsuite/gfortran.dg/goacc/coarray.f95 b/gcc/testsuite/gfortran.dg/goacc/coarray.f95 index d2f10d5..932e1f7 100644 --- a/gcc/testsuite/gfortran.dg/goacc/coarray.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/coarray.f95 @@ -2,8 +2,6 @@ ! { dg-additional-options "-fcoarray=single" } ! ! PR fortran/63861 -! { dg-xfail-if "" { *-*-* } } -! { dg-excess-errors "TODO" } module test contains @@ -20,7 +18,7 @@ contains !$acc end parallel !$acc host_data use_device (a) !$acc end host_data - !$acc parallel loop reduction(+:a) + !$acc parallel loop reduction(+:a) ! { dg-error "Array 'a' is not permitted in reduction" } do i = 1,5 enddo !$acc end parallel loop diff --git a/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 b/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 index 87e04d5..05167a1 100644 --- a/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 @@ -2,8 +2,6 @@ ! { dg-additional-options "-fcoarray=lib" } ! ! PR fortran/63861 -! { dg-xfail-if "" { *-*-* } } -! { dg-excess-errors "TODO" } module test contains @@ -20,7 +18,7 @@ contains !$acc end parallel !$acc host_data use_device (a) !$acc end host_data - !$acc parallel loop reduction(+:a) + !$acc parallel loop reduction(+:a) ! { dg-error "Array 'a' is not permitted in reduction" } do i = 1,5 enddo !$acc end parallel loop @@ -72,7 +70,7 @@ contains !$acc end parallel !$acc host_data use_device (a) !$acc end host_data - !$acc parallel loop reduction(+:a) + !$acc parallel loop reduction(+:a) ! { dg-error "Array 'a' is not permitted in reduction" } do i = 1,5 enddo !$acc end parallel loop @@ -94,7 +92,7 @@ contains !$acc end data !$acc parallel private (a) !$acc end parallel - !$acc parallel loop reduction(+:a) + !$acc parallel loop reduction(+:a) ! { dg-error "Array 'a' is not permitted in reduction" } do i = 1,5 enddo !$acc end parallel loop diff --git a/gcc/testsuite/gfortran.dg/goacc/reduction.f95 b/gcc/testsuite/gfortran.dg/goacc/reduction.f95 index 833230a..a13574b 100644 --- a/gcc/testsuite/gfortran.dg/goacc/reduction.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/reduction.f95 @@ -136,3 +136,26 @@ common /blk/ i1 !$acc end parallel end subroutine + +! { dg-error "Array 'ia2' is not permitted in reduction" "" { target "*-*-*" } 27 } +! { dg-error "Array 'ra1' is not permitted in reduction" "" { target "*-*-*" } 29 } +! { dg-error "Array 'ca1' is not permitted in reduction" "" { target "*-*-*" } 31 } +! { dg-error "Array 'da1' is not permitted in reduction" "" { target "*-*-*" } 33 } +! { dg-error "Array 'la1' is not permitted in reduction" "" { target "*-*-*" } 35 } +! { dg-error "Array 'aa1' is not permitted in reduction" "" { target "*-*-*" } 65 } +! { dg-error "Array 'ia1' is not permitted in reduction" "" { target "*-*-*" } 67 } +! { dg-error "Array 'la1' is not permitted in reduction" "" { target "*-*-*" } 71 } +! { dg-error "Array 'ta1' is not permitted in reduction" "" { target "*-*-*" } 77 } +! { dg-error "Array 'ia2' is not permitted in reduction" "" { target "*-*-*" } 81 } +! { dg-error "Array 'ra1' is not permitted in reduction" "" { target "*-*-*" } 85 } +! { dg-error "Array 'da1' is not permitted in reduction" "" { target "*-*-*" } 89 } +! { dg-error "Array 'ca1' is not permitted in reduction" "" { target "*-*-*" } 93 } +! { dg-error "Array 'ta1' is not permitted in reduction" "" { target "*-*-*" } 99 } +! { dg-error "Array 'ca1' is not permitted in reduction" "" { target "*-*-*" } 103 } +! { dg-error "Array 'la1' is not permitted in reduction" "" { target "*-*-*" } 107 } +! { dg-error "Array 'ta1' is not permitted in reduction" "" { target "*-*-*" } 113 } +! { dg-error "Array 'ra1' is not permitted in reduction" "" { target "*-*-*" } 117 } +! { dg-error "Array 'da1' is not permitted in reduction" "" { target "*-*-*" } 121 } +! { dg-error "Array 'ca1' is not permitted in reduction" "" { target "*-*-*" } 125 } +! { dg-error "Array 'la1' is not permitted in reduction" "" { target "*-*-*" } 129 } +! { dg-error "Array 'ta1' is not permitted in reduction" "" { target "*-*-*" } 135 } --------------080402090509050808040909--