From patchwork Thu Oct 3 16:05:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Tocar X-Patchwork-Id: 280386 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1C4932C0090 for ; Fri, 4 Oct 2013 02:11:33 +1000 (EST) 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:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=O1rG7TYD/XcXO4zs2 VzS/5TswkZ8oWqwiKg2q3hzdjZRMl8l/IqpZ509KFgK35hWbASUogzlrQh1rg4w7 DMYLdnzTyUkp69xB9ApGzSmBumOEJJYGI000mSMX0qfoL+fmIvR7cW+g3eKH5P7z DMAIsTyzvDSkGVVk7otUjdUsFY= 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:references:mime-version :content-type:in-reply-to; s=default; bh=eThfgbUU4U5YLz1ojw8YKsN cXYk=; b=T+Qa1a6pL0G+7D0FPyAZy5QBZ7Wtu27x2blnNwtolNfmvjlgeoiyWdm aKVhnjUE8yGF8zL0zIDfMLYrrgIE8NEiQ4YlGaVYcBpEKSdFs3slEDwnOD8uQU6c u2rlH3FzOnGkBrlyd+Z9QXInHnzE7bkSx9fLK00rz4gqWw/Yr3hU= Received: (qmail 17446 invoked by alias); 3 Oct 2013 16:11:25 -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 17437 invoked by uid 89); 3 Oct 2013 16:11:25 -0000 Received: from mail-pd0-f175.google.com (HELO mail-pd0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 03 Oct 2013 16:11:25 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_00, FREEMAIL_FROM, KAM_STOCKGEN autolearn=no version=3.3.2 X-HELO: mail-pd0-f175.google.com Received: by mail-pd0-f175.google.com with SMTP id q10so2690477pdj.34 for ; Thu, 03 Oct 2013 09:11:22 -0700 (PDT) X-Received: by 10.66.146.42 with SMTP id sz10mr10578725pab.100.1380816329286; Thu, 03 Oct 2013 09:05:29 -0700 (PDT) Received: from msticlxl7.ims.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by mx.google.com with ESMTPSA id os4sm9090199pbb.25.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 09:05:28 -0700 (PDT) Date: Thu, 3 Oct 2013 20:05:07 +0400 From: Ilya Tocar To: Richard Biener Cc: Jakub Jelinek , "Michael V. Zolotukhin" , Kirill Yukhin , gcc , Richard Henderson , Jan Hubicka Subject: Ping Re: [gomp4] Dumping gimple for offload. Message-ID: <20131003160507.GA116670@msticlxl7.ims.intel.com> References: <20130923132951.GA80051@msticlxl7.ims.intel.com> <20130925132924.GA122388@msticlxl7.ims.intel.com> <20130926172127.GA41768@msticlxl7.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130926172127.GA41768@msticlxl7.ims.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 26 Sep 21:21, Ilya Tocar wrote: > On 25 Sep 15:48, Richard Biener wrote: > > On Wed, Sep 25, 2013 at 3:29 PM, Ilya Tocar wrote: > > > On 24 Sep 11:02, Richard Biener wrote: > > >> On Mon, Sep 23, 2013 at 3:29 PM, Ilya Tocar wrote: > > >> thus consider assigning the section > > >> name in a different place. > > >> > > >> Richard. > > > > > > What do you mean by different place? > > > I can add global dumping_omp_target variable to choose correct name, > > > depending on it's value (patch below). Is it better? > > > > More like passing down a different abstraction, like for > > > > > @@ -907,9 +907,15 @@ output_symtab (void) > > > { > > > symtab_node node = lto_symtab_encoder_deref (encoder, i); > > > if (cgraph_node *cnode = dyn_cast (node)) > > > - lto_output_node (ob, cnode, encoder); > > > + { > > > + if (!dumping_omp_target || lookup_attribute ("omp declare target", > > > + DECL_ATTRIBUTES (node->symbol.decl))) > > > + lto_output_node (ob, cnode, encoder); > > > + } > > > else > > > - lto_output_varpool_node (ob, varpool (node), encoder); > > > + if (!dumping_omp_target || lookup_attribute ("omp declare target", > > > + DECL_ATTRIBUTES (node->symbol.decl))) > > > + lto_output_varpool_node (ob, varpool (node), encoder); > > > > > > } > > > > have the symtab encoder already not contain the varpool nodes you > > don't need. > > > > And instead of looking up attributes, mark the symtab node with a flag. > > Good idea! > I've tried creating 2 encoders, and adding only nodes with > "omp declare target" attribute in omp case. There is still some is_omp > passing to control lto_set_symtab_encoder_in_partition behaivor, > because i think it's better than global var. > What do you think? > Updated version of the patch. I've checked that it doesn't break lto on SPEC 2006. Streaming for omp is enabled by -fopnemp flag. Works with and without enabled lto. Ok for gomp4 branch? --- gcc/cgraphunit.c | 15 +++++++++++++-- gcc/ipa-inline-analysis.c | 2 +- gcc/lto-cgraph.c | 15 ++++++++++----- gcc/lto-streamer.c | 5 +++-- gcc/lto-streamer.h | 10 ++++++++-- gcc/lto/lto-partition.c | 4 ++-- gcc/passes.c | 12 ++++++------ gcc/tree-pass.h | 2 +- 8 files changed, 44 insertions(+), 21 deletions(-) diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 1644ca9..d595475 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2016,7 +2016,18 @@ ipa_passes (void) passes->all_lto_gen_passes); if (!in_lto_p) - ipa_write_summaries (); + { + if (flag_openmp) + { + section_name_prefix = OMP_SECTION_NAME_PREFIX; + ipa_write_summaries (true); + } + if (flag_lto) + { + section_name_prefix = LTO_SECTION_NAME_PREFIX; + ipa_write_summaries (false); + } + } if (flag_generate_lto) targetm.asm_out.lto_end (); @@ -2107,7 +2118,7 @@ compile (void) cgraph_state = CGRAPH_STATE_IPA; /* If LTO is enabled, initialize the streamer hooks needed by GIMPLE. */ - if (flag_lto) + if (flag_lto || flag_openmp) lto_streamer_hooks_init (); /* Don't run the IPA passes if there was any error or sorry messages. */ diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index ba6221e..4420213 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -3721,7 +3721,7 @@ inline_generate_summary (void) /* When not optimizing, do not bother to analyze. Inlining is still done because edge redirection needs to happen there. */ - if (!optimize && !flag_lto && !flag_wpa) + if (!optimize && !flag_lto && !flag_wpa && !flag_openmp) return; function_insertion_hook_holder = diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 952588d..4a7d179 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -236,8 +236,13 @@ lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder, void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder, - symtab_node node) + symtab_node node, bool is_omp) { + /* Ignore non omp target nodes for omp case. */ + if (is_omp && !lookup_attribute ("omp declare target", + DECL_ATTRIBUTES (node->symbol.decl))) + return; + int index = lto_symtab_encoder_encode (encoder, (symtab_node)node); encoder->nodes[index].in_partition = true; } @@ -760,7 +765,7 @@ add_references (lto_symtab_encoder_t encoder, ignored by the partitioning logic earlier. */ lto_symtab_encoder_t -compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) +compute_ltrans_boundary (lto_symtab_encoder_t in_encoder, bool is_omp) { struct cgraph_node *node; struct cgraph_edge *edge; @@ -779,7 +784,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) { node = lsei_cgraph_node (lsei); add_node_to (encoder, node, true); - lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node); + lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node, is_omp); add_references (encoder, &node->symbol.ref_list); /* For proper debug info, we need to ship the origins, too. */ if (DECL_ABSTRACT_ORIGIN (node->symbol.decl)) @@ -794,7 +799,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) { struct varpool_node *vnode = lsei_varpool_node (lsei); - lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode); + lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode, is_omp); lto_set_symtab_encoder_encode_initializer (encoder, vnode); add_references (encoder, &vnode->symbol.ref_list); /* For proper debug info, we need to ship the origins, too. */ @@ -802,7 +807,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) { struct varpool_node *origin_node = varpool_get_node (DECL_ABSTRACT_ORIGIN (node->symbol.decl)); - lto_set_symtab_encoder_in_partition (encoder, (symtab_node)origin_node); + lto_set_symtab_encoder_in_partition (encoder, (symtab_node)origin_node, is_omp); } } /* Pickle in also the initializer of all referenced readonly variables diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index cdc75de..34f93a0 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -44,6 +44,7 @@ struct lto_stats_d lto_stats; static bitmap_obstack lto_obstack; static bool lto_obstack_initialized; +const char *section_name_prefix = LTO_SECTION_NAME_PREFIX; /* Return a string representing LTO tag TAG. */ @@ -173,7 +174,7 @@ lto_get_section_name (int section_type, const char *name, struct lto_file_decl_d sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, f->id); else sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false)); - return concat (LTO_SECTION_NAME_PREFIX, sep, add, post, NULL); + return concat (section_name_prefix, sep, add, post, NULL); } @@ -311,7 +312,7 @@ lto_streamer_init (void) bool gate_lto_out (void) { - return ((flag_generate_lto || in_lto_p) + return ((flag_generate_lto || in_lto_p || flag_openmp) /* Don't bother doing anything if the program has errors. */ && !seen_error ()); } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 13a9593..7cd7514 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -141,6 +141,11 @@ along with GCC; see the file COPYING3. If not see name for the functions and static_initializers. For other types of sections a '.' and the section type are appended. */ #define LTO_SECTION_NAME_PREFIX ".gnu.lto_" +#define OMP_SECTION_NAME_PREFIX ".gnu.target_lto_" + +/* Can be either OMP_SECTION_NAME_PREFIX when we stream pragma omp target + stuff, or LTO_SECTION_NAME_PREFIX for lto case. */ +extern const char *section_name_prefix; #define LTO_major_version 2 #define LTO_minor_version 2 @@ -882,7 +887,7 @@ bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t, bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t, symtab_node); void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t, - symtab_node); + symtab_node, bool is_omp); bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t, struct varpool_node *); @@ -896,7 +901,8 @@ bool referenced_from_this_partition_p (struct ipa_ref_list *, lto_symtab_encoder_t); bool reachable_from_this_partition_p (struct cgraph_node *, lto_symtab_encoder_t); -lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder); +lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder, + bool is_omp); /* In lto-symtab.c. */ diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index e05f805..83b3eba 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -189,7 +189,7 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node node) gcc_assert (c != SYMBOL_EXTERNAL && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node))); - lto_set_symtab_encoder_in_partition (part->encoder, (symtab_node) node); + lto_set_symtab_encoder_in_partition (part->encoder, (symtab_node) node, false); if (symbol_partitioned_p (node)) { @@ -922,7 +922,7 @@ lto_promote_cross_file_statics (void) { ltrans_partition part = ltrans_partitions[i]; - part->encoder = compute_ltrans_boundary (part->encoder); + part->encoder = compute_ltrans_boundary (part->encoder, false); } /* Look at boundaries and promote symbols as needed. */ diff --git a/gcc/passes.c b/gcc/passes.c index f3f85fd..8a788ed 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2321,7 +2321,7 @@ ipa_write_summaries_1 (lto_symtab_encoder_t encoder) /* Write out summaries for all the nodes in the callgraph. */ void -ipa_write_summaries (void) +ipa_write_summaries (bool is_omp) { lto_symtab_encoder_t encoder; int i, order_pos; @@ -2329,7 +2329,7 @@ ipa_write_summaries (void) struct cgraph_node *node; struct cgraph_node **order; - if (!flag_generate_lto || seen_error ()) + if (!(flag_generate_lto || flag_openmp) || seen_error () ) return; encoder = lto_symtab_encoder_new (false); @@ -2359,16 +2359,16 @@ ipa_write_summaries (void) pop_cfun (); } if (node->symbol.definition) - lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node); + lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node, is_omp); } FOR_EACH_DEFINED_FUNCTION (node) if (node->symbol.alias) - lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node); + lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node, is_omp); FOR_EACH_DEFINED_VARIABLE (vnode) - lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode); + lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode, is_omp); - ipa_write_summaries_1 (compute_ltrans_boundary (encoder)); + ipa_write_summaries_1 (compute_ltrans_boundary (encoder, is_omp)); free (order); } diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index ea1a62f..40e1882 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -598,7 +598,7 @@ extern void pass_fini_dump_file (struct opt_pass *); extern const char *get_current_pass_name (void); extern void print_current_pass (FILE *); extern void debug_pass (void); -extern void ipa_write_summaries (void); +extern void ipa_write_summaries (bool is_omp); extern void ipa_write_optimization_summaries (struct lto_symtab_encoder_d *); extern void ipa_read_summaries (void); extern void ipa_read_optimization_summaries (void);