This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ping Re: [gomp4] Dumping gimple for offload.


Ping.

On 03 Oct 20:05, Ilya Tocar wrote:
> 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 <tocarip.intel@gmail.com> wrote:
> > > > On 24 Sep 11:02, Richard Biener wrote:
> > > >> On Mon, Sep 23, 2013 at 3:29 PM, Ilya Tocar <tocarip.intel@gmail.com> 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 <cgraph_node> (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);
> -- 
> 1.7.11.7
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]