public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Richard Biener <rguenther@suse.de>
Cc: Thomas Schwinge <thomas@codesourcery.com>,
	Jakub Jelinek	<jakub@redhat.com>,
	"gcc-patches@gnu.org" <gcc-patches@gnu.org>
Subject: Re: [PATCH] Handle BUILT_IN_GOACC_PARALLEL in ipa-pta
Date: Thu, 10 Dec 2015 13:15:00 -0000	[thread overview]
Message-ID: <56697AC5.7060902@mentor.com> (raw)
In-Reply-To: <566022D0.2030906@mentor.com>

[-- Attachment #1: Type: text/plain, Size: 2958 bytes --]

[ copy-pasting-with-quote from 
https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00420.html , for some 
reason I didn't get this email ]

> On Thu, 3 Dec 2015, Tom de Vries wrote:
>> The flag is set here in expand_omp_target:
>> ...
>> 12682         /* Prevent IPA from removing child_fn as unreachable,
>>                  since there are no
>> 12683            refs from the parent function to child_fn in offload
>>                  LTO mode.  */
>> 12684         if (ENABLE_OFFLOADING)
>> 12685           cgraph_node::get (child_fn)->mark_force_output ();
>> ...
>>
>
> How are there no refs from the "parent"?  Are there not refs from
> some kind of descriptor that maps fallback CPU and offloaded variants?

That descriptor is the offload table, which is emitted in 
omp_finish_file. The function iterates over vectors offload_vars and 
offload_funcs.

[ I would guess there's a one-on-one correspondance between 
symtab_node::offloadable and membership of either offload_vars or 
offload_funcs. ]

> I think the above needs sorting out in somw way, making the refs
> explicit rather than implicit via force_output.

I've tried an approach where I add a test for node->offloadable next to 
each test for node->force_output, except for the test in the nonlocal_p 
def in ipa_pta_execute. But I didn't (yet) manage to make that work.

>> I guess setting forced_by_abi instead would also mean child_fn is not removed
>> as unreachable, while still allowing optimizations:
>> ...
>>   /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol
>>      to be exported.  Unlike FORCE_OUTPUT this flag gets cleared to
>>      symbols promoted to static and it does not inhibit
>>      optimization.  */
>>   unsigned forced_by_abi : 1;
>> ...
>>
>> But I suspect that other optimizations (than ipa-pta) might break things.
>
> How so?

Probably it's more accurate to say that I do not understand the 
difference very well between force_output and force_by_abi, and what is 
the class of optimizations enabled by using forced_by_abi instead of 
force_output.'

>> Essentially we have two situations:
>> - in the host compiler, there is no need for the forced_output flag,
>>   and it inhibits optimization
>> - in the accelerator compiler, it (or some equivalent) is needed

Actually, things are slightly more complicated, I realize now. There's 
also the distinction between:
- symbols declared as offloadable in the source code, and
- symbols create by the compiler and marked offloadable

>> I wonder if setting the force_output flag only when streaming the bytecode for
>> offloading would work. That way, it wouldn't be set in the host compiler,
>> while being set in the accelerator compiler.
>
> Yeah, that was my original thinking btw.

FTR, I've tried that approach, as attached. It fixed the 
goacc/kernels-alias-ipa-pta*.c failures. And I ran target-libgomp (also 
using an accelerator configuration) without any regressions.

Thanks,
- Tom


[-- Attachment #2: 0002-Set-force_output-in-offload-stream-if-offloadable.patch --]
[-- Type: text/x-patch, Size: 1456 bytes --]

Set force_output in offload stream if offloadable

---
 gcc/lto-cgraph.c | 2 +-
 gcc/omp-low.c    | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 62e5454..c862b19 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -511,7 +511,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
   bp_pack_value (&bp, node->local.versionable, 1);
   bp_pack_value (&bp, node->local.can_change_signature, 1);
   bp_pack_value (&bp, node->local.redefined_extern_inline, 1);
-  bp_pack_value (&bp, node->force_output, 1);
+  bp_pack_value (&bp, node->force_output || node->offloadable, 1);
   bp_pack_value (&bp, node->forced_by_abi, 1);
   bp_pack_value (&bp, node->unique_name, 1);
   bp_pack_value (&bp, node->body_removed, 1);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 5643480..569cfd7 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -12770,10 +12770,12 @@ expand_omp_target (struct omp_region *region)
 	assign_assembler_name_if_neeeded (child_fn);
       cgraph_edge::rebuild_edges ();
 
+#if 0
       /* Prevent IPA from removing child_fn as unreachable, since there are no
 	 refs from the parent function to child_fn in offload LTO mode.  */
       if (ENABLE_OFFLOADING)
 	cgraph_node::get (child_fn)->mark_force_output ();
+#endif
 
       /* Some EH regions might become dead, see PR34608.  If
 	 pass_cleanup_cfg isn't the first pass to happen with the

  parent reply	other threads:[~2015-12-10 13:15 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30  9:00 [PATCH, PR46032] Handle BUILT_IN_GOMP_PARALLEL " Tom de Vries
2015-11-30  9:36 ` Richard Biener
2015-11-30 12:20   ` Tom de Vries
2015-11-30 13:32     ` Richard Biener
2015-11-30 13:35       ` Jakub Jelinek
2015-12-03 11:49         ` Tom de Vries
2015-11-30 16:44       ` Tom de Vries
2015-11-30 16:52         ` Jakub Jelinek
2015-11-30 18:00           ` Tom de Vries
2015-12-01 12:27             ` Christophe Lyon
2015-12-01 12:30               ` Jakub Jelinek
2015-12-01 14:49                 ` Tom de Vries
2015-12-01 14:27         ` [PATCH] Handle BUILT_IN_GOACC_PARALLEL " Tom de Vries
2015-12-01 14:38           ` Richard Biener
2015-12-01 14:44           ` Jakub Jelinek
2015-12-01 23:48             ` Tom de Vries
2015-12-02  9:31               ` Jakub Jelinek
2015-12-02 17:58           ` Thomas Schwinge
2015-12-02 23:32             ` Tom de Vries
2015-12-03  0:10               ` Tom de Vries
2015-12-03  0:27                 ` Tom de Vries
2015-12-03  8:59                   ` Richard Biener
2015-12-03 11:09                     ` Tom de Vries
2015-12-03 11:13                       ` Richard Biener
2015-12-03 11:13                       ` Jakub Jelinek
2015-12-10 13:15                       ` Tom de Vries [this message]
2015-12-16 16:02                         ` Tom de Vries
2016-01-05 14:56                           ` [PING][PATCH] Mark symbols in offload tables with force_output in read_offload_tables Tom de Vries
2016-01-25 13:27                             ` Ilya Verbin
2016-01-26 12:22                               ` Tom de Vries
2016-01-26 13:02                                 ` Ilya Verbin
2016-02-08 13:20                                   ` Tom de Vries
2016-02-08 15:02                                     ` Ilya Verbin
2016-02-15  7:38                                     ` [PING][PATCH] Don't mark offload symbols with force_output in ltrans Tom de Vries
2016-02-15  9:07                                       ` Richard Biener
2016-01-26 14:13                                 ` [PING][PATCH] Mark symbols in offload tables with force_output in read_offload_tables Richard Biener
2016-01-08  8:17                           ` [PATCH] Handle BUILT_IN_GOACC_PARALLEL in ipa-pta Richard Biener
2016-01-14  9:31                             ` Thomas Schwinge
2016-01-14  9:32                               ` Richard Biener
2015-12-09 10:01     ` [PATCH, PR68716] Fix GOMP/GOACC_parallel handling in find_func_clobbers Tom de Vries
2015-12-09 10:04       ` Jakub Jelinek
2015-12-09 10:09         ` Richard Biener
2015-12-09 10:11         ` Tom de Vries
2015-12-10  9:01       ` [committed, obvious] Remove invalid assert in find_func_aliases_for_builtin_call Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56697AC5.7060902@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gnu.org \
    --cc=jakub@redhat.com \
    --cc=rguenther@suse.de \
    --cc=thomas@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).