diff mbox

OMP builtins in offloading (was: [PATCH 1/4] Add mkoffload for Intel MIC)

Message ID 87fvblwa81.fsf@schwinge.name
State New
Headers show

Commit Message

Thomas Schwinge Jan. 8, 2015, 3:41 p.m. UTC
Hi!

On Fri, 26 Dec 2014 16:22:43 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> On 22 Dec 12:26, Jakub Jelinek wrote:
> > On Mon, Dec 22, 2014 at 12:20:58PM +0100, Thomas Schwinge wrote:
> > > What is the reason that you're adding -fopenmp here?  I assume it is that
> > > otherwise you'd get tree streaming errors because of different builtins
> > > configurations, like this?
> > > 
> > > If that is the "only" reason to add -fopenmp there, can we then instead
> > > do the following?
> > > 
> > >  gcc/builtins.def                     | 8 ++++++--
> > >  gcc/config/i386/intelmic-mkoffload.c | 1 -
> > >  2 files changed, 6 insertions(+), 3 deletions(-)
> > 
> > If Ilya confirms that is the sole reason, I'm fine with this change.
> > Please write ChangeLog entry for it.
> 
> Ok to me.

Committed to trunk in r219346:

commit 752cfdfdd758616a0fee3071d33e4add83f34a51
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Jan 8 15:41:13 2015 +0000

    Make sure that OMP builtins are available in offloading compilers.
    
    	gcc/
    	* builtins.def (DEF_GOMP_BUILTIN): Also consider flag_offload_abi
    	for registering builtins.
    	* config/i386/intelmic-mkoffload.c (prepare_target_image): Don't
    	add -fopenmp to the argv_obstack used when invoking
    	compile_for_target.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219346 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                        | 6 ++++++
 gcc/builtins.def                     | 5 ++++-
 gcc/config/i386/intelmic-mkoffload.c | 1 -
 3 files changed, 10 insertions(+), 2 deletions(-)



Grüße,
 Thomas

Comments

Jakub Jelinek Jan. 8, 2015, 3:49 p.m. UTC | #1
Hi!

On Thu, Jan 08, 2015 at 04:41:50PM +0100, Thomas Schwinge wrote:
> On Fri, 26 Dec 2014 16:22:43 +0300, Ilya Verbin <iverbin@gmail.com> wrote:

BTW, today when looking at the TARGET_OPTION_NODE streaming caused
regressions, I've discovered that it is very hard to debug issues in the
offloading compiler.  Would be nice if
-save-temps -v
printed enough information that it is actually possible to reproduce it,
e.g. while mkoffload command is printed, one can't cut and paste it easily,
because some env vars are required and those aren't printed in the -v dump.
Similarly, the lto1 offloading compiler invocation is not printed, and
wrapping offloading compiler's lto1 into a script that runs gdb on it
doesn't work, because stdout/stderr (and stdin) is redirected.

This is something that can be solved during stage4, but would be really nice
if it wasn't terribly hard to debug stuff.

	Jakub
Ilya Verbin Jan. 8, 2015, 4:32 p.m. UTC | #2
On 08 Jan 16:49, Jakub Jelinek wrote:
> BTW, today when looking at the TARGET_OPTION_NODE streaming caused
> regressions, I've discovered that it is very hard to debug issues in the
> offloading compiler.  Would be nice if
> -save-temps -v
> printed enough information that it is actually possible to reproduce it,
> e.g. while mkoffload command is printed, one can't cut and paste it easily,
> because some env vars are required and those aren't printed in the -v dump.

I agree, this should be improved.  Unfortunately, I didn't have time so far.

> Similarly, the lto1 offloading compiler invocation is not printed, and

It can be printed by -foffload="-save-temps -v", or should we pass through these
options from host to offload compiler by default?

> wrapping offloading compiler's lto1 into a script that runs gdb on it
> doesn't work, because stdout/stderr (and stdin) is redirected.
> 
> This is something that can be solved during stage4, but would be really nice
> if it wasn't terribly hard to debug stuff.

  -- Ilya
Jakub Jelinek Jan. 8, 2015, 4:39 p.m. UTC | #3
On Thu, Jan 08, 2015 at 07:32:13PM +0300, Ilya Verbin wrote:
> On 08 Jan 16:49, Jakub Jelinek wrote:
> > BTW, today when looking at the TARGET_OPTION_NODE streaming caused
> > regressions, I've discovered that it is very hard to debug issues in the
> > offloading compiler.  Would be nice if
> > -save-temps -v
> > printed enough information that it is actually possible to reproduce it,
> > e.g. while mkoffload command is printed, one can't cut and paste it easily,
> > because some env vars are required and those aren't printed in the -v dump.
> 
> I agree, this should be improved.  Unfortunately, I didn't have time so far.
> 
> > Similarly, the lto1 offloading compiler invocation is not printed, and
> 
> It can be printed by -foffload="-save-temps -v", or should we pass through these
> options from host to offload compiler by default?

Certainly not if they weren't passed by the user to the host compiler.
But if they have been passed, it might be useful, having to add -save-temps -v 
to too many spaces is annoying.
And it would be really nice to print the essential env vars mkoffload is
relying on, like:
var1=value1
var2=value2
...../mkoffload /tmp/@ccABCDEF

	Jakub
Richard Biener Jan. 9, 2015, 10:36 a.m. UTC | #4
On Thu, Jan 8, 2015 at 5:39 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Jan 08, 2015 at 07:32:13PM +0300, Ilya Verbin wrote:
>> On 08 Jan 16:49, Jakub Jelinek wrote:
>> > BTW, today when looking at the TARGET_OPTION_NODE streaming caused
>> > regressions, I've discovered that it is very hard to debug issues in the
>> > offloading compiler.  Would be nice if
>> > -save-temps -v
>> > printed enough information that it is actually possible to reproduce it,
>> > e.g. while mkoffload command is printed, one can't cut and paste it easily,
>> > because some env vars are required and those aren't printed in the -v dump.
>>
>> I agree, this should be improved.  Unfortunately, I didn't have time so far.
>>
>> > Similarly, the lto1 offloading compiler invocation is not printed, and
>>
>> It can be printed by -foffload="-save-temps -v", or should we pass through these
>> options from host to offload compiler by default?
>
> Certainly not if they weren't passed by the user to the host compiler.
> But if they have been passed, it might be useful, having to add -save-temps -v
> to too many spaces is annoying.
> And it would be really nice to print the essential env vars mkoffload is
> relying on, like:
> var1=value1
> var2=value2
> ...../mkoffload /tmp/@ccABCDEF

Maybe pass it through if you specify -Wl,-debug -v -save-temps
(that also makes sure to disable collect2s error output buffering
which is annoying with LTO)

Richard.

>         Jakub
Jakub Jelinek Jan. 9, 2015, 10:39 a.m. UTC | #5
On Fri, Jan 09, 2015 at 11:36:54AM +0100, Richard Biener wrote:
> Maybe pass it through if you specify -Wl,-debug -v -save-temps
> (that also makes sure to disable collect2s error output buffering
> which is annoying with LTO)

Works with me too (but should be documented somewhere).

	Jakub
Ilya Verbin Feb. 16, 2015, 6:58 p.m. UTC | #6
On Thu, Jan 08, 2015 at 16:49:40 +0100, Jakub Jelinek wrote:
> BTW, today when looking at the TARGET_OPTION_NODE streaming caused
> regressions, I've discovered that it is very hard to debug issues in the
> offloading compiler.  Would be nice if
> -save-temps -v
> printed enough information that it is actually possible to reproduce it,
> e.g. while mkoffload command is printed, one can't cut and paste it easily,
> because some env vars are required and those aren't printed in the -v dump.

Currently I see all required env vars for mkoffload in the -v dump:
COLLECT_GCC=...
COMPILER_PATH=...
.../mkoffload @...

It doesn't need anything more.

  -- Ilya
Thomas Schwinge Aug. 4, 2021, 9:46 a.m. UTC | #7
Hi!

On 2015-01-08T16:41:50+0100, I wrote:
> Committed to trunk in r219346:

(Git commit 45f46750a3513790573791c0eec6b600b42f2042.)

>     Make sure that OMP builtins are available in offloading compilers.

> --- gcc/builtins.def
> +++ gcc/builtins.def
> @@ -148,11 +148,14 @@ along with GCC; see the file COPYING3.  If not see
>
>  /* Builtin used by the implementation of GNU OpenMP.  None of these are
>     actually implemented in the compiler; they're all in libgomp.  */
> +/* These builtins also need to be enabled in offloading compilers invoked from
> +   mkoffload; for that purpose, we're checking the -foffload-abi flag here.  */
>  #undef DEF_GOMP_BUILTIN
>  #define DEF_GOMP_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
>    DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,    \
>                 false, true, true, ATTRS, false, \
> -            (flag_openmp || flag_tree_parallelize_loops))
> +            (flag_openmp || flag_tree_parallelize_loops \
> +             || flag_offload_abi != OFFLOAD_ABI_UNSET))

(Similar for 'DEF_GOACC_BUILTIN', later.)

Since Tom's PR64707 commit r220037 (Git commit
1506ae0e1e865fb7a42fc37a47f1799b71f21c53) "Make fopenmp an LTO option" as
well as PR64672 commit r220038 (Git commit
a0c88d0629a33161add8d5bc083f1e59f3f756f7) "Make fopenacc an LTO option",
we're now actually passing '-fopenacc'/'-fopenmp' to the 'mkoffload's,
which will pass these on to the offload compilers, so we may clean up
this change.

OK to push "Don't consider '-foffload-abi' in 'DEF_GOACC_BUILTIN',
'DEF_GOMP_BUILTIN'", see attached?


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
diff mbox

Patch

diff --git gcc/ChangeLog gcc/ChangeLog
index 01b6cc6..5bc6591 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,5 +1,11 @@ 
 2015-01-08  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* builtins.def (DEF_GOMP_BUILTIN): Also consider flag_offload_abi
+	for registering builtins.
+	* config/i386/intelmic-mkoffload.c (prepare_target_image): Don't
+	add -fopenmp to the argv_obstack used when invoking
+	compile_for_target.
+
 	* config/i386/intelmic-mkoffload.c (compile_for_target): Always
 	add "-m32" or "-m64" to argv_obstack.
 	(generate_host_descr_file): Likewise, when invoking host_compiler.
diff --git gcc/builtins.def gcc/builtins.def
index 28b1646..5a7ed10 100644
--- gcc/builtins.def
+++ gcc/builtins.def
@@ -148,11 +148,14 @@  along with GCC; see the file COPYING3.  If not see
 
 /* Builtin used by the implementation of GNU OpenMP.  None of these are
    actually implemented in the compiler; they're all in libgomp.  */
+/* These builtins also need to be enabled in offloading compilers invoked from
+   mkoffload; for that purpose, we're checking the -foffload-abi flag here.  */
 #undef DEF_GOMP_BUILTIN
 #define DEF_GOMP_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,    \
                false, true, true, ATTRS, false, \
-	       (flag_openmp || flag_tree_parallelize_loops))
+	       (flag_openmp || flag_tree_parallelize_loops \
+		|| flag_offload_abi != OFFLOAD_ABI_UNSET))
 
 /* Builtin used by implementation of Cilk Plus.  Most of these are decomposed
    by the compiler but a few are implemented in libcilkrts.  */ 
diff --git gcc/config/i386/intelmic-mkoffload.c gcc/config/i386/intelmic-mkoffload.c
index 23bc955..050f2e6 100644
--- gcc/config/i386/intelmic-mkoffload.c
+++ gcc/config/i386/intelmic-mkoffload.c
@@ -390,7 +390,6 @@  prepare_target_image (const char *target_compiler, int argc, char **argv)
   obstack_init (&argv_obstack);
   obstack_ptr_grow (&argv_obstack, target_compiler);
   obstack_ptr_grow (&argv_obstack, "-xlto");
-  obstack_ptr_grow (&argv_obstack, "-fopenmp");
   obstack_ptr_grow (&argv_obstack, "-shared");
   obstack_ptr_grow (&argv_obstack, "-fPIC");
   obstack_ptr_grow (&argv_obstack, opt1);