From patchwork Wed Oct 11 14:03:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 824438 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-463946-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kvxnuhe6"; 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 3yBwh82Xq1z9s8J for ; Thu, 12 Oct 2017 01:04:08 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=xzPOnz3qXtEmZ3nw2reRfDSGxI2KpewXmtbQ9TMXnegNzfA5C+ BsGwub5zhxm+xJVqk8O8i0riT0mBHZEY8YkrFEgUK7/h1FVICS+tdir+LKM1KJij BZsbaecWSM+x+e6Zg+2+A4fdu3DGkkhHdIvurL7V/5voW0rDkfkG5CgPs= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=RiJTVXGmKYnr19zZBVwpPC+i1u4=; b=kvxnuhe6zHmivaJLyRjT 7H1u1V+6E3FbRqOuJHbXXJn8abGJfnAZZ1rPzGwf37vKYTsuwFEEroZKpQhAd2vC +b0MZUc68e0rbaMLiEm5423o2xSq46gPbqA348hB1WR7yY4h2txDwwgoLeMWGE/q 3lOetUjlo6eHKrleLH+NDaw= Received: (qmail 12358 invoked by alias); 11 Oct 2017 14:04:00 -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 12337 invoked by uid 89); 11 Oct 2017 14:04:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 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=ary, i1 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; Wed, 11 Oct 2017 14:03:58 +0000 Received: from svr-orw-mbx-02.mgc.mentorg.com ([147.34.90.202]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1e2Hc5-0000iN-Cj from Cesar_Philippidis@mentor.com ; Wed, 11 Oct 2017 07:03:57 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 11 Oct 2017 07:03:55 -0700 To: Fortran List , "gcc-patches@gcc.gnu.org" From: Cesar Philippidis Subject: [og7] Enable fortran derived types in acc enter/exit data Message-ID: <1a54d19d-65de-d61c-568b-bf15fcd8c707@codesourcery.com> Date: Wed, 11 Oct 2017 07:03:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) To svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) This patch enables fortran derived type members to be used in acc enter/exit data constructs. Now, both acc enter/exit data and acc update support individual derived type members. Eventually, I'd like all of the acc data clauses to support individual derived type members. But that may not happen in the near term. Cesar 2017-10-11 Cesar Philippidis gcc/fortran/ * openmp.c (match_acc): Add new argument derived_types. Propagate it to gfc_match_omp_clauses. (gfc_match_oacc_enter_data): Update call to match_acc. (gfc_match_oacc_exit_data): Likewise. gcc/testsuite/ * gfortran.dg/goacc/derived-types.f90: Adjust test case. libgomp/ * testsuite/libgomp.oacc-fortran/derived-type-2.f90: New test. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index a59b7d27e9c..5562f4e02f7 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -2141,10 +2141,12 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, omp_mask mask, static match -match_acc (gfc_exec_op op, const omp_mask mask, const omp_mask dtype_mask) +match_acc (gfc_exec_op op, const omp_mask mask, const omp_mask dtype_mask, + bool derived_types=false) { gfc_omp_clauses *c; - if (gfc_match_omp_clauses (&c, mask, dtype_mask, false, false, true) + if (gfc_match_omp_clauses (&c, mask, dtype_mask, false, false, true, + derived_types) != MATCH_YES) return MATCH_ERROR; new_st.op = op; @@ -2329,7 +2331,7 @@ match gfc_match_oacc_enter_data (void) { return match_acc (EXEC_OACC_ENTER_DATA, OACC_ENTER_DATA_CLAUSES, - OMP_MASK2_LAST); + OMP_MASK2_LAST, true); } @@ -2337,7 +2339,7 @@ match gfc_match_oacc_exit_data (void) { return match_acc (EXEC_OACC_EXIT_DATA, OACC_EXIT_DATA_CLAUSES, - OMP_MASK2_LAST); + OMP_MASK2_LAST, true); } diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-types.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-types.f90 index 44a38149560..11d055a79f2 100644 --- a/gcc/testsuite/gfortran.dg/goacc/derived-types.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/derived-types.f90 @@ -28,11 +28,14 @@ program derived_acc !$acc update self(var%a) !$acc enter data copyin(var) - !$acc enter data copyin(var%a) ! { dg-error "Syntax error in OpenMP" } + !$acc enter data copyin(var%a) !$acc exit data copyout(var) - !$acc exit data copyout(var%a) ! { dg-error "Syntax error in OpenMP" } + !$acc exit data copyout(var%a) + !$acc data copy(var%a) ! { dg-error "Syntax error in OpenMP" } + !$acc end data ! { dg-error "Unexpected ..ACC END DATA" } + !$acc data copy(var) !$acc end data diff --git a/libgomp/testsuite/libgomp.oacc-fortran/derived-type-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/derived-type-2.f90 new file mode 100644 index 00000000000..3ed21953261 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/derived-type-2.f90 @@ -0,0 +1,67 @@ +! Test derived types in data clauses. + +! { dg-do run } + +module newtype + type dtype + integer :: a, b, c + integer, allocatable :: ary(:) + end type dtype +end module newtype + +program main + use newtype + implicit none + integer, parameter :: n = 100 + integer i + type (dtype), dimension(n) :: d1 + type (dtype) :: d2 + external process + + allocate (d2%ary(n)) + + !$acc enter data create (d2%ary) + + do i = 1, n + d2%ary(i) = 1 + end do + + !$acc update device (d2%ary) + + call process (n, d2%ary) + + !$acc exit data copyout (d2%ary) + + do i = 1, n + if (d2%ary(i) /= i + 1) call abort + end do + + !$acc data copy(d1(1:n)) + !$acc parallel loop + do i = 1, n + d1(i)%a = i + d1(i)%b = i-1 + d1(i)%c = i+1 + end do + !$acc end data + + do i = 1, n + if (d1(i)%a /= i) call abort + if (d1(i)%b /= i-1) call abort + if (d1(i)%c /= i+1) call abort + end do + + deallocate (d2%ary) +end program main + +subroutine process (a, b) + use newtype + implicit none + integer :: a, i + integer :: b(a) + + !$acc parallel loop present (b(1:a)) + do i = 1, a + b(i) = b(i) + i + end do +end subroutine process