From patchwork Fri Sep 30 10:21:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 676951 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 3slnYj0JWVz9s3s for ; Fri, 30 Sep 2016 20:22:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Ej5Wbtig; 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:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=ilWHByINSeFOF5hd 5URL8pdv3OjGDZ7rv/izg5ZwsIjA4KUQrlz9/cMqEaGxLSOBGBq9f5MYe9I+FvfA j/OCToTR8A7nU4zh3ZA6vgMYQJNN17t4JAfdCXE9ADDIvatEeLEP47U7NWLsAfYb C/WBFbZwW3is9AJxdSCxBGtTOvY= 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:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=P6m7efDjGZZolUKm7jWmaN Yj1FU=; b=Ej5Wbtigg20bu2wNdLNABgEUzcaeajVaaP6bXpb2NtEndSil2X2M1z N7u4Qvfq8q/+k3kV/nA5zLvfJiYMYySQ955SLm5rHhoVrtTeg2PenslYTBCk/6dF qD/LnaiRcEtxBVbT2eYdWD8c8CPu+j+IM+ert1Gq4paqmdh/l8rn8= Received: (qmail 105289 invoked by alias); 30 Sep 2016 10:22:04 -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 105242 invoked by uid 89); 30 Sep 2016 10:22:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=D*gmx.de, 25657, UD:sym, UD:type X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Sep 2016 10:21:49 +0000 Received: from vepi2 ([84.63.206.51]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MFMIO-1bkMUd2Qiq-00ELeX; Fri, 30 Sep 2016 12:21:43 +0200 Date: Fri, 30 Sep 2016 12:21:42 +0200 From: Andre Vehreschild To: Paul Richard Thomas Cc: GCC-Patches-ML , GCC-Fortran-ML , Damian Rouson Subject: Re: [accaf, Fortran, patch, v1] Generate caf-reference chains only from the first coarray reference on, and more. Message-ID: <20160930122142.0d52394a@vepi2> In-Reply-To: References: <20160929140335.49237ec4@vepi2> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:Lqubi1gmBx4=:+7cHF0r3oeGYVEKyAJunOD Ft3pRqaKtNNaul0lT8OjPVhCBFCNq1KOBXrgR4jGWzKxqtl1g2/Ea5/oh8snlz0mSvGe1IdFT 93+UNxvCmjlS1FqRU5KCOOXeVNyURJZr4HfT/jgk6NtvBn+43pd+Zp0cXXh1jX4aHr/aywwmh IEChP6l/j5JFzX2ixRUhQHUfYorNnFmPyJmme567QTM+u1bIkyHN0uLFE004RpEM5v2wghFSR xcW3pxPKlTJOimgXsjnX1yR+3S/HXDx/Jhldp5bGGC5ydHAdB9r6MJ4a2aaXDdXdtp5Oc5OFt Loin+xr41NzFjbsAAnJI3Dvx/OZtpheHKRs+ak/bhyKupDsUiSuK/WhqQDLja3vChSlwlu2lI z/S0V3aeF7qC+GX9ECJBuUx6fgs6URJb9bJmtO5c+o3mcltAQcrdKDLGb/v+NGNoY+OU1Kod/ NnnySDx+SddvieP0ooBz2MwmkEPS4kjDBV1mrvJaA/OcF6pVTgwdaBn6PomBSETqdMlOM62vW ZUX8geRHZsaD+/OFukCCthraD3yBfBzlLLdb+50xhBOg78Bb2Th1u89GhCHWLlV+/E/uiIvLB FpqgemqtF703Qc2tDC9b07Q0X7J5EPdXqbWbOnjBvm0KWJ+MZNn8dosh5JT7dx9A/eiTb0QTY joJAD68GQNtQIwpLgLSQ2a9UGTx6VuHOBpcLVDSsKtU25jkHv7hFddA1tQtaxi/Kh1Iy324zR ByQ8zXYkw0q5XAJyRdaXFuZIvxcjaK06UGeukDlzC9uDY3pn1TC97bys2rI= Hi Paul, thanks for the fast review. Committed as r240650. Thanks again, Andre On Fri, 30 Sep 2016 11:16:48 +0200 Paul Richard Thomas wrote: > Dear Andre, > > Looks good to me - OK for trunk. > > Thanks > > Paul > > On 29 September 2016 at 14:03, Andre Vehreschild wrote: > > Hi all, > > > > attached patch fixes an addressing issue for coarrays *in* derived types. > > Before the patch the caf runtime reference chain was generated from the > > start of the symbol to the last reference *and* the reference chain upto > > the coarray in the derived type was used to call the caf_*_by_ref () > > functions. The patch fixes this by skipping the generation of unnecessary > > caf runtime references. > > > > The second part fixes finding the token for coarrayed arrays. The new > > semantic is, that each allocatable array has the coarray token in > > its .token member, which the allocate_array now makes use of. > > > > Bootstrapped and regtested ok on x86_64-linux/F23. Ok for trunk? > > > > Regards, > > Andre > > -- > > Andre Vehreschild * Email: vehre ad gmx dot de > > > Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 240649) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,12 @@ +2016-09-30 Andre Vehreschild + + * trans-array.c (gfc_array_allocate): Use the token from coarray's + .token member. + * trans-intrinsic.c (conv_expr_ref_to_caf_ref): Only generate + caf-reference chains from the first coarray references on. + * trans-types.c (gfc_get_derived_type): Switch on mandatory .token + member generation for allocatable arrays in coarrays in derived types. + 2016-09-29 James Greenhalgh * options.c (gfc_post_options): Remove special case for Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (Revision 240649) +++ gcc/fortran/trans-array.c (Arbeitskopie) @@ -5406,7 +5406,6 @@ gfc_expr **lower; gfc_expr **upper; gfc_ref *ref, *prev_ref = NULL, *coref; - gfc_se caf_se; bool allocatable, coarray, dimension, alloc_w_e3_arr_spec = false; ref = expr->ref; @@ -5531,7 +5530,6 @@ } } - gfc_init_se (&caf_se, NULL); gfc_start_block (&elseblock); /* Allocate memory to store the data. */ @@ -5543,9 +5541,7 @@ if (coarray && flag_coarray == GFC_FCOARRAY_LIB) { - tmp = gfc_get_tree_for_caf_expr (expr); - gfc_get_caf_token_offset (&caf_se, &token, NULL, tmp, NULL_TREE, expr); - gfc_add_block_to_block (&elseblock, &caf_se.pre); + token = gfc_conv_descriptor_token (se->expr); token = gfc_build_addr_expr (NULL_TREE, token); } @@ -5557,7 +5553,6 @@ else gfc_allocate_using_malloc (&elseblock, pointer, size, status); - gfc_add_block_to_block (&elseblock, &caf_se.post); if (dimension) { cond = gfc_unlikely (fold_build2_loc (input_location, NE_EXPR, Index: gcc/fortran/trans-intrinsic.c =================================================================== --- gcc/fortran/trans-intrinsic.c (Revision 240649) +++ gcc/fortran/trans-intrinsic.c (Arbeitskopie) @@ -1110,7 +1110,7 @@ static tree conv_expr_ref_to_caf_ref (stmtblock_t *block, gfc_expr *expr) { - gfc_ref *ref = expr->ref; + gfc_ref *ref = expr->ref, *last_comp_ref; tree caf_ref = NULL_TREE, prev_caf_ref = NULL_TREE, reference_type, tmp, tmp2, field, last_type, inner_struct, mode, mode_rhs, dim_array, dim, dim_type, start, end, stride, vector, nvec; @@ -1127,8 +1127,29 @@ /* Prevent uninit-warning. */ reference_type = NULL_TREE; - last_type = gfc_typenode_for_spec (&expr->symtree->n.sym->ts); - last_type_n = expr->symtree->n.sym->ts.type; + + /* Skip refs upto the first coarray-ref. */ + last_comp_ref = NULL; + while (ref && (ref->type != REF_ARRAY || ref->u.ar.codimen == 0)) + { + /* Remember the type of components skipped. */ + if (ref->type == REF_COMPONENT) + last_comp_ref = ref; + ref = ref->next; + } + /* When a component was skipped, get the type information of the last + component ref, else get the type from the symbol. */ + if (last_comp_ref) + { + last_type = gfc_typenode_for_spec (&last_comp_ref->u.c.component->ts); + last_type_n = last_comp_ref->u.c.component->ts.type; + } + else + { + last_type = gfc_typenode_for_spec (&expr->symtree->n.sym->ts); + last_type_n = expr->symtree->n.sym->ts.type; + } + while (ref) { if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0 Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c (Revision 240649) +++ gcc/fortran/trans-types.c (Arbeitskopie) @@ -2565,7 +2565,8 @@ if ((!c->attr.pointer && !c->attr.proc_pointer) || c->ts.u.derived->backend_decl == NULL) c->ts.u.derived->backend_decl = gfc_get_derived_type (c->ts.u.derived, - in_coarray); + in_coarray + || c->attr.codimension); if (c->ts.u.derived->attr.is_iso_c) { Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 240649) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2016-09-30 Andre Vehreschild + + * gfortran.dg/coarray_allocate_10.f08: New test. + * gfortran.dg/coindexed_1.f90: Above fixes allow execution. + 2016-09-30 Kyrylo Tkachov * gcc.target/aarch64/ifcvt_avoid_const_materialization_1.c: New test. Index: gcc/testsuite/gfortran.dg/coarray_allocate_10.f08 =================================================================== --- gcc/testsuite/gfortran.dg/coarray_allocate_10.f08 (nicht existent) +++ gcc/testsuite/gfortran.dg/coarray_allocate_10.f08 (Arbeitskopie) @@ -0,0 +1,39 @@ +! { dg-do run } +! { dg-options "-fcoarray=lib -lcaf_single" } + +program alloc_comp + implicit none + + type coords + integer,allocatable :: x(:) + end type + + type outerT + type(coords),allocatable :: coo[:] + end type + integer :: me,np,n,i + type(outerT) :: o + + ! with caf_single num_images is always == 1 + me = this_image(); np = num_images() + n = 100 + + allocate(o%coo[*]) + allocate(o%coo%x(n)) + + o%coo%x = me + + do i=1, n + o%coo%x(i) = o%coo%x(i) + i + end do + + sync all + + if(me == 1 .and. o%coo[np]%x(10) /= 11 ) call abort() + + ! Check the whole array is correct. + if (me == 1 .and. any( o%coo[np]%x /= [(i, i=2, 101)] ) ) call abort() + + deallocate(o%coo%x) + +end program Index: gcc/testsuite/gfortran.dg/coindexed_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/coindexed_1.f90 (Revision 240649) +++ gcc/testsuite/gfortran.dg/coindexed_1.f90 (Arbeitskopie) @@ -1,5 +1,5 @@ -! { dg-do compile } -! { dg-options "-fcoarray=lib" } +! { dg-do run } +! { dg-options "-fcoarray=lib -lcaf_single" } ! ! Contributed by Reinhold Bader ! @@ -14,7 +14,7 @@ integer :: ii !! --- ONE --- - allocate(real :: a(3)[*]) ! { dg-error "Sorry, coindexed access to an unlimited polymorphic object at" } + allocate(real :: a(3)[*]) IF (this_image() == num_images()) THEN SELECT TYPE (a) TYPE IS (real) @@ -43,7 +43,7 @@ !! --- TWO --- deallocate(a) - allocate(t :: a(3)[*]) ! { dg-error "Sorry, coindexed access to an unlimited polymorphic object at" } + allocate(t :: a(3)[*]) IF (this_image() == num_images()) THEN SELECT TYPE (a) TYPE IS (t)