From patchwork Thu Dec 8 13:43:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 87265 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp850242qgi; Thu, 8 Dec 2016 05:43:51 -0800 (PST) X-Received: by 10.84.192.1 with SMTP id b1mr158751251pld.113.1481204631291; Thu, 08 Dec 2016 05:43:51 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v35si28933684plg.80.2016.12.08.05.43.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 05:43:51 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443786-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443786-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443786-patch=linaro.org@gcc.gnu.org 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:subject:message-id:in-reply-to:references:mime-version :content-type; q=dns; s=default; b=NenWxke7dzhp2VJkn5Y5p1JNv519n 5b2Kuirv5zBRZwEFW1YeLbUg1BPghiOWngUvl+qLSiuup0b0EHkA0A8dzdAw+CXZ PK2dYFVj1jdQ5zmrn9MC/CfPjm988jGvKXZj5y8UtQsK+9QTLdze4gibyZASlCvE HhGfTdEmiXQx5I= 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:subject:message-id:in-reply-to:references:mime-version :content-type; s=default; bh=f+quBfjq8OGSmLTGMSMHyHhtH4o=; b=xZz eRKztfCx63bTXNAgNR2JDrKvbOWo3smOj9ofcy0Koi9QLn/VnCoizcB8ZZWC3KDU AqEBs+PhxqlWc3/p42rR/JpQkHFJ4jSaaUsNTpOfCH20jhHhfttT9OiypwSBQ6p5 zuZuVrJqrRLwYFo4dL4S329cCWsUE2W5m4YDSNCQ= Received: (qmail 118217 invoked by alias); 8 Dec 2016 13:43:31 -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 118189 invoked by uid 89); 8 Dec 2016 13:43:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=gfc_symtree, vehregccgnuorg, vehre@gcc.gnu.org, HTo:U*damian X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Dec 2016 13:43:25 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MP0LT-1cKm8I0rkV-006KMn; Thu, 08 Dec 2016 14:43:17 +0100 Date: Thu, 8 Dec 2016 14:43:16 +0100 From: Andre Vehreschild To: GCC-Patches-ML , GCC-Fortran-ML , Damian Rouson Subject: Re: Ping [PATCH, Fortran, pr78505, v1] [F08] Coarray source allocation not synchronizing on oversubscribed cores Message-ID: <20161208144316.13d15764@vepi2> In-Reply-To: <20161202164629.7822c479@vepi2> References: <20161202164629.7822c479@vepi2> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:mMaP9hwrx3o=:gLZM9HpybyPBUQfUaZgieA jpwj9IktJ5cNyvwHI8WAfYFPhBAkFWYC7wkIMLgI8VCC9tghX9et73rMG76P8Uz288x9jQSHU SNXgW2o/o6VZYzU5rfNTS7N86zWkUPeqp5V/tviPIvwHodQjux7kSN8jxhu0B4LKX0ujWgomB HUSdI9a0rRtjcRnHCzLawwqrdjyquFoaaEGtL8hEwVUwYM5DmA8cqgVo1Tles92JFzqeT2GLI 1A0+xZp3VSxLLjjOXkI3yGWuEsB4oHRA6s7V4SEHAOyIy07BAoFzCiMcNFbytU9HlqlRn09wK vs/KigFWjWHoobjtX0sGpnAFGVyZMIdzChueBV2feKrLAo0sgLBezb3u6PntgTimT655rUCbv wOwbG6BHalP3AGMBGS8f7w2wX1x7cXviRXNdP6Ee/Va/uLM4246OuT8s+/5V1D+2JW2K2EvtP 28734Hrl0Ajxoy4VNIsIbg4iFSuPuyS6orVDlXK5kriDMBG2ellGMK2qXWil95AmzBfXl32wE nLypLcJzGhClDLjudlFSJ6IR3mQRzofiZqzuC9vQsLCsaYo3IC6I5yVwTMNUJhuF960jNwv+/ mEh1AGIuUdV4FQtw74NvOFTtFZ4uazO72osN/ShCYsdqYjOGgv12c110PfMnGpi+Fs8nzdgsB 78JddMCwpZZ/TjGu/hKQEvuu/EHkUDx8KSeD3yt49WoqeAadrMx3t8bwvwbI3DMOoSbERqjdG sUc/RhKnMRd/TlvOdplaaZERLfnA6j/Gra2ZBV4HnHj141jhcLLldCWg98U= Ping! On Fri, 2 Dec 2016 16:46:29 +0100 Andre Vehreschild wrote: > Hi all, > > attached patch adds a call to sync_all after an ALLOCATE allocating a coarray. > This is to adhere to standard wanting: > > ..., execution of the segment (11.6.2) following the statement is delayed > until all other active images in the current team have executed the same > statement the same number of times in this team. > > This, esp. the "statement", means that assigning the SOURCE= is to come before > the sync all, which means we have to do it explicitly after that assignment. > Or the other way around the sync all can be done in library caf_register(). > > Bootstraps and regtests ok on x86_64-linux/F23. Ok for trunk? > > Regards, > Andre -- Andre Vehreschild * Email: vehre ad gmx dot de gcc/fortran/ChangeLog: 2016-12-02 Andre Vehreschild PR fortran/78505 * trans-stmt.c (gfc_trans_allocate): Add sync all after the execution of the whole allocate-statement to adhere to the standard. gcc/testsuite/ChangeLog: 2016-12-02 Andre Vehreschild PR fortran/78505 * gfortran.dg/coarray_alloc_with_implicit_sync_1.f90: New test. diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 514db28..2219bcc 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5506,7 +5506,7 @@ gfc_trans_allocate (gfc_code * code) stmtblock_t block; stmtblock_t post; tree nelems; - bool upoly_expr, tmp_expr3_len_flag = false, al_len_needs_set; + bool upoly_expr, tmp_expr3_len_flag = false, al_len_needs_set, is_coarray ; gfc_symtree *newsym = NULL; if (!code->ext.alloc.list) @@ -5516,6 +5516,7 @@ gfc_trans_allocate (gfc_code * code) expr3 = expr3_vptr = expr3_len = expr3_esize = NULL_TREE; label_errmsg = label_finish = errmsg = errlen = NULL_TREE; e3_is = E3_UNSET; + is_coarray = false; gfc_init_block (&block); gfc_init_block (&post); @@ -5555,8 +5556,9 @@ gfc_trans_allocate (gfc_code * code) expression. */ if (code->expr3) { - bool vtab_needed = false, temp_var_needed = false, - is_coarray = gfc_is_coarray (code->expr3); + bool vtab_needed = false, temp_var_needed = false; + + is_coarray = gfc_is_coarray (code->expr3); /* Figure whether we need the vtab from expr3. */ for (al = code->ext.alloc.list; !vtab_needed && al != NULL; @@ -6093,6 +6095,9 @@ gfc_trans_allocate (gfc_code * code) tree caf_decl, token; gfc_se caf_se; + /* Set flag, to add synchronize after the allocate. */ + is_coarray = true; + gfc_init_se (&caf_se, NULL); caf_decl = gfc_get_tree_for_caf_expr (expr); @@ -6114,6 +6119,11 @@ gfc_trans_allocate (gfc_code * code) } else { + /* Allocating coarrays needs a sync after the allocate executed. + Set the flag to add the sync after all objects are allocated. */ + is_coarray = is_coarray || (gfc_caf_attr (expr).codimension + && flag_coarray == GFC_FCOARRAY_LIB); + if (expr->ts.type == BT_CHARACTER && al_len != NULL_TREE && expr3_len != NULL_TREE) { @@ -6357,6 +6367,15 @@ gfc_trans_allocate (gfc_code * code) gfc_add_modify (&block, se.expr, tmp); } + if (is_coarray && flag_coarray == GFC_FCOARRAY_LIB) + { + /* Add a sync all after the allocation has been executed. */ + tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_all, + 3, null_pointer_node, null_pointer_node, + integer_zero_node); + gfc_add_expr_to_block (&post, tmp); + } + gfc_add_block_to_block (&block, &se.post); gfc_add_block_to_block (&block, &post); diff --git a/gcc/testsuite/gfortran.dg/coarray_alloc_with_implicit_sync_1.f90 b/gcc/testsuite/gfortran.dg/coarray_alloc_with_implicit_sync_1.f90 new file mode 100644 index 0000000..1dbbcb7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_alloc_with_implicit_sync_1.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original -fcoarray=lib" } +! Check that allocating a coarray adds an implicit sync all. + + implicit none + integer, allocatable :: f(:)[:] + allocate( f(20)[*], source = 1 ) +end + +! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_all \\(" 1 "original" } }