From patchwork Sat Jan 24 18:21:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 432437 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 855B21402A7 for ; Sun, 25 Jan 2015 05:21:47 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=EGzlObSlOqKWIneGD5tKa7ZM9KognZiWRrW9ArgA7G3KAz TNKil45m/WFWinthCdWYvytQtVNpw4tpNIOUb33TMxV4a24XZRM/eFZJfh+fgSTb mSyUy6r8xg3lxGOU1QZeYPiAtLqND///BnEo9qNqk3/+gEKEwu4rSW05rqs1E= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=B1TpA/TBB3LV0W+XPLRyMoLQSpU=; b=wuR7GJCYxPsAFIb9+alC 6pdwsHEUXoJUL+pFywTtj1H5d44zWURbYRfmVsJ4PeGHZrP/TTu7yuQmcSmBbfCT OB5sp1/HF6ivRNXTaY7/4EcdEiZXicH85nLCL0zn0ZsCVxQPtSeO5Zooclb3In/c ja+PQC1ZwGojqxbyTlpclq0= Received: (qmail 18537 invoked by alias); 24 Jan 2015 18:21:39 -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 18517 invoked by uid 89); 24 Jan 2015 18:21:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx02.qsc.de Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 24 Jan 2015 18:21:35 +0000 Received: from tux.net-b.de (port-92-194-20-233.dynamic.qsc.de [92.194.20.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPSA id E559B24C5D; Sat, 24 Jan 2015 19:21:27 +0100 (CET) Message-ID: <54C3E2A7.1080608@net-b.de> Date: Sat, 24 Jan 2015 19:21:27 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: gcc-patches , gfortran , Jakub Jelinek , Cesar Philippidis Subject: [Patch, Fortran] PR63861 - fix OpenMP/ACC's gfc_has_alloc_comps gfortran's scalar coarray are special: The descriptorless variant is a normal variable with some language-specific additional information (corank, bounds). The descriptor variant has a descriptor but the _data component is just a pointer to the scalar variable. As the element type of a descriptorless coarray is the type itself, we need to break the while loop. Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias PS: I believes coarrays are fine in OpenMP and OpenACC constructs as long as the variable is not coindexed ("variable[remove_index]", gfc_is_coindexed()). Issues like synchronization is in my opinion purely in the responsibility of the user. 2015-01-24 Tobias Burnus PR fortran/63861 gcc/fortran/ * trans-openmp.c (gfc_has_alloc_comps): Fix handling for scalar coarrays. gcc/testsuite/ * gfortran.dg/goacc/coarray_2.f90: New. diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index cdd1885..4c7d82d 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -189,7 +189,8 @@ gfc_has_alloc_comps (tree type, tree decl) return false; } - while (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type)) + if (GFC_DESCRIPTOR_TYPE_P (type) + || (GFC_ARRAY_TYPE_P (type) && GFC_TYPE_ARRAY_RANK (type) == 0)) type = gfc_get_element_type (type); if (TREE_CODE (type) != RECORD_TYPE) diff --git a/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 b/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 new file mode 100644 index 0000000..7fbd928 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/coarray_2.f90 @@ -0,0 +1,112 @@ +! { dg-do compile } +! { dg-additional-options "-fcoarray=lib" } +! +! PR fortran/63861 + +module test +contains + subroutine oacc1(a) + implicit none + integer :: i + integer, codimension[*] :: a + !$acc declare device_resident (a) + !$acc data copy (a) + !$acc end data + !$acc data deviceptr (a) + !$acc end data + !$acc parallel private (a) + !$acc end parallel + !$acc host_data use_device (a) + !$acc end host_data + !$acc parallel loop reduction(+:a) + do i = 1,5 + enddo + !$acc end parallel loop + !$acc parallel loop + do i = 1,5 + enddo + !$acc end parallel loop + !$acc update device (a) + !$acc update host (a) + !$acc update self (a) + end subroutine oacc1 + + subroutine oacc2(a) + implicit none + integer :: i + integer, allocatable, codimension[*] :: a + !$acc declare device_resident (a) + !$acc data copy (a) + !$acc end data + !$acc data deviceptr (a) + !$acc end data + !$acc parallel private (a) + !$acc end parallel + !$acc host_data use_device (a) + !$acc end host_data + !$acc parallel loop reduction(+:a) + do i = 1,5 + enddo + !$acc end parallel loop + !$acc parallel loop + do i = 1,5 + enddo + !$acc end parallel loop + !$acc update device (a) + !$acc update host (a) + !$acc update self (a) + end subroutine oacc2 + + subroutine oacc3(a) + implicit none + integer :: i + integer, codimension[*] :: a(:) + !$acc declare device_resident (a) + !$acc data copy (a) + !$acc end data + !$acc data deviceptr (a) + !$acc end data + !$acc parallel private (a) + !$acc end parallel + !$acc host_data use_device (a) + !$acc end host_data + !$acc parallel loop reduction(+:a) + do i = 1,5 + enddo + !$acc end parallel loop + !$acc parallel loop + do i = 1,5 + enddo + !$acc end parallel loop + !$acc update device (a) + !$acc update host (a) + !$acc update self (a) + end subroutine oacc2 + + subroutine oacc2(a) + implicit none + integer :: i + integer, allocatable, codimension[*] :: a(:) + !$acc declare device_resident (a) + !$acc data copy (a) + !$acc end data + !$acc data deviceptr (a) + !$acc end data + !$acc parallel private (a) + !$acc end parallel + !$acc host_data use_device (a) + !$acc end host_data + !$acc parallel loop reduction(+:a) + do i = 1,5 + enddo + !$acc end parallel loop + !$acc parallel loop + do i = 1,5 + enddo + !$acc end parallel loop + !$acc update device (a) + !$acc update host (a) + !$acc update self (a) + end subroutine oacc2 +end module test +! { dg-excess-errors "sorry, unimplemented: directive not yet implemented" }