Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-25 Thread Ilya Verbin
On Fri, Feb 20, 2015 at 15:50:53 +0100, Jakub Jelinek wrote:
> On Fri, Feb 20, 2015 at 03:41:40PM +0100, Thomas Schwinge wrote:
> > Well, but users (like Jakub, for example) ;-) may decide to build the
> > offloading compilers without specifying --enable-languages, and that'll
> > then default to include Java, and you'll end up with:
> 
> Yeah.  We can perhaps tweak what languages we include by default for
> the --enable-as-accelerator-for= configurations, but if the user decides
> to explicitly add some language, we should still support that.

Here is the patch.
Build and install seems to be working both for accel and regular modes, with
--enable-languages=c,c++,fortran,go,java,jit,lto,objc,obj-c++
OK for trunk?


gcc/ada/
* gcc-interface/Make-lang.in (ada.install-common): Do not install for
the offloading compiler.
gcc/go/
* Make-lang.in (go.install-common): Do not install for the offloading
compiler.
gcc/java/
* Make-lang.in (java.install-common): Do not install for the offloading
compiler.
gcc/jit/
* Make-lang.in (jit.install-common): Do not install for the offloading
compiler.


diff --git a/gcc/ada/gcc-interface/Make-lang.in 
b/gcc/ada/gcc-interface/Make-lang.in
index 4696203..81fd80a 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -754,25 +754,27 @@ doc/gnat-style.pdf: ada/gnat-style.texi 
$(gcc_docdir)/include/fdl.texi
 # vxaddr2line is only used for cross VxWorks ports (it calls the underlying
 # cross addr2line).
 ada.install-common:
-   $(MKDIR) $(DESTDIR)$(bindir)
-   -if [ -f gnat1$(exeext) ] ; \
-   then \
- for tool in $(ADA_TOOLS) ; do \
-   install_name=`echo $$tool|sed 
'$(program_transform_name)'`$(exeext); \
-   $(RM) $(DESTDIR)$(bindir)/$$install_name; \
-   if [ -f $$tool-cross$(exeext) ] ; \
+   -if test "$(enable_as_accelerator)" != "yes" ; then \
+ $(MKDIR) $(DESTDIR)$(bindir); \
+ if [ -f gnat1$(exeext) ] ; \
+ then \
+   for tool in $(ADA_TOOLS) ; do \
+ install_name=`echo $$tool|sed 
'$(program_transform_name)'`$(exeext); \
+ $(RM) $(DESTDIR)$(bindir)/$$install_name; \
+ if [ -f $$tool-cross$(exeext) ] ; \
+ then \
+   $(INSTALL_PROGRAM) $$tool-cross$(exeext) 
$(DESTDIR)$(bindir)/$$install_name; \
+ else \
+   $(INSTALL_PROGRAM) $$tool$(exeext) 
$(DESTDIR)$(bindir)/$$install_name; \
+ fi ; \
+   done; \
+   $(RM) $(DESTDIR)$(bindir)/gnatdll$(exeext); \
+   $(INSTALL_PROGRAM) gnatdll$(exeext) 
$(DESTDIR)$(bindir)/gnatdll$(exeext); \
+   if [ -f vxaddr2line$(exeext) ] ; \
then \
- $(INSTALL_PROGRAM) $$tool-cross$(exeext) 
$(DESTDIR)$(bindir)/$$install_name; \
-   else \
- $(INSTALL_PROGRAM) $$tool$(exeext) 
$(DESTDIR)$(bindir)/$$install_name; \
+ $(RM) $(DESTDIR)$(bindir)/vxaddr2line$(exeext); \
+ $(INSTALL_PROGRAM) vxaddr2line$(exeext) 
$(DESTDIR)$(bindir)/vxaddr2line$(exeext); \
fi ; \
- done; \
- $(RM) $(DESTDIR)$(bindir)/gnatdll$(exeext); \
- $(INSTALL_PROGRAM) gnatdll$(exeext) 
$(DESTDIR)$(bindir)/gnatdll$(exeext); \
- if [ -f vxaddr2line$(exeext) ] ; \
- then \
-   $(RM) $(DESTDIR)$(bindir)/vxaddr2line$(exeext); \
-   $(INSTALL_PROGRAM) vxaddr2line$(exeext) 
$(DESTDIR)$(bindir)/vxaddr2line$(exeext); \
  fi ; \
fi
 
diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in
index 6c5968a..891b610 100644
--- a/gcc/go/Make-lang.in
+++ b/gcc/go/Make-lang.in
@@ -136,15 +136,17 @@ check_go_parallelize = 10
 # Install hooks.
 
 go.install-common: installdirs
-   -rm -f $(DESTDIR)$(bindir)/$(GCCGO_INSTALL_NAME)$(exeext)
-   $(INSTALL_PROGRAM) gccgo$(exeext) 
$(DESTDIR)$(bindir)/$(GCCGO_INSTALL_NAME)$(exeext)
-   -if test -f go1$(exeext); then \
- if test -f gccgo-cross$(exeext); then \
-   :; \
- else \
-   rm -f $(DESTDIR)$(bindir)/$(GCCGO_TARGET_INSTALL_NAME)$(exeext); \
-   ( cd $(DESTDIR)$(bindir) && \
- $(LN) $(GCCGO_INSTALL_NAME)$(exeext) 
$(GCCGO_TARGET_INSTALL_NAME)$(exeext) ); \
+   -if test "$(enable_as_accelerator)" != "yes" ; then \
+ rm -f $(DESTDIR)$(bindir)/$(GCCGO_INSTALL_NAME)$(exeext); \
+ $(INSTALL_PROGRAM) gccgo$(exeext) 
$(DESTDIR)$(bindir)/$(GCCGO_INSTALL_NAME)$(exeext); \
+ if test -f go1$(exeext); then \
+   if test -f gccgo-cross$(exeext); then \
+ :; \
+   else \
+ rm -f $(DESTDIR)$(bindir)/$(GCCGO_TARGET_INSTALL_NAME)$(exeext); \
+ ( cd $(DESTDIR)$(bindir) && \
+   $(LN) $(GCCGO_INSTALL_NAME)$(exeext) 
$(GCCGO_TARGET_INSTALL_NAME)$(exeext) ); \
+   fi; \
  fi; \
fi
 
diff --git a/gcc/java/Make-lang.in b/gcc/java/Make

Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-21 Thread Iain Sandoe
Hi Thomas,

On 20 Feb 2015, at 19:46, Thomas Schwinge wrote:

> On Fri, 20 Feb 2015 11:35:18 -0800, Mike Stump  wrote:
>> On Feb 20, 2015, at 6:36 AM, Ilya Verbin  wrote:
>>> I assumed that nobody would build an offloading compiler with 
>>> --enable-languages
>>> other than c,c++,fortran[,lto].
>> 
>> :-)  You should try objc and obj-c++…  With some luck, they might just work 
>> out of the box.
> 
> At least objc does build indeed (gets enabled by default if
> --enable-languages is not explicitly specified).  Now we just need
> someone to write additional OpenACC/OpenMP test cases...  Are you or Iain
> interested (in doing that)?  ;-D

Well, the mantra is "Objective-C,C++ are supersets of the underlying languages".

So, for a first cut, it should be possible to run all the existing C and C++ 
testcases with -x objective-c,c++ respectively.   If that doesn't work as 
expected - we should examine why (and identify any restrictions that apply).  
Do you want to try that (at least once manually) to see if there are any 
show-stoppers? (I don't have an accelerated setup here).

That should be adequate, for now at least, since there are currently no 
Objective-C family-specific OpenAcc or OpenMP clauses (AFAIU).

FWIW, I, for one, have implemented real-time signal processing and data 
collection systems in Objective-C (a useful thin wrapper to get access to GUI 
features, without slowing the actual work down).  So, it seems reasonable that 
acceleration capabilities will be interesting to (at least some) Objective-C 
users.

As for the future (i.e. should the Objective C family support extra 
capabilities in this area), IMO, unless we see some killer capability that is a 
"must have" (for stage #1 of course), then let's leave the lead on language 
features to the "defining implementation" (i.e. clang).  TBH, we are somewhat 
behind on Objective-C in any event, catching up to modern capabilities is a 
higher priority for me.

cheers
Iain



Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-20 Thread Thomas Schwinge
Hi!

On Fri, 20 Feb 2015 11:35:18 -0800, Mike Stump  wrote:
> On Feb 20, 2015, at 6:36 AM, Ilya Verbin  wrote:
> > I assumed that nobody would build an offloading compiler with 
> > --enable-languages
> > other than c,c++,fortran[,lto].
> 
> :-)  You should try objc and obj-c++…  With some luck, they might just work 
> out of the box.

At least objc does build indeed (gets enabled by default if
--enable-languages is not explicitly specified).  Now we just need
someone to write additional OpenACC/OpenMP test cases...  Are you or Iain
interested (in doing that)?  ;-D


Grüße,
 Thomas


pgpfyNCv43Grl.pgp
Description: PGP signature


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-20 Thread Mike Stump
On Feb 20, 2015, at 6:36 AM, Ilya Verbin  wrote:
> I assumed that nobody would build an offloading compiler with 
> --enable-languages
> other than c,c++,fortran[,lto].

:-)  You should try objc and obj-c++…  With some luck, they might just work out 
of the box.


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-20 Thread Jakub Jelinek
On Fri, Feb 20, 2015 at 03:41:40PM +0100, Thomas Schwinge wrote:
> Well, but users (like Jakub, for example) ;-) may decide to build the
> offloading compilers without specifying --enable-languages, and that'll
> then default to include Java, and you'll end up with:

Yeah.  We can perhaps tweak what languages we include by default for
the --enable-as-accelerator-for= configurations, but if the user decides
to explicitly add some language, we should still support that.

Jakub


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-20 Thread Thomas Schwinge
Hi!

On Fri, 20 Feb 2015 17:36:12 +0300, Ilya Verbin  wrote:
> On Thu, Feb 19, 2015 at 12:37:10 +0100, Thomas Schwinge wrote:
> > On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> > > gcc/
> > >   * Makefile.in
> > 
> > >   (install-cpp, install-common, install_driver, install-gcc-ar): Do not
> > >   install for the offload compiler.
> > 
> > > gcc/cp/
> > >   * Make-lang.in (c++.install-common): Do not install for the offload
> > >   compiler.
> > > gcc/fortran/
> > >   * Make-lang.in (fortran.install-common): Do not install for the offload
> > >   compiler.
> > 
> > Hmm, shouldn't that be done for all gcc/*/Make-lang.in?  If I understand
> > correctly, if the language is enabled,
> > gcc/java/Make-lang.in:java.install-common would currently still install
> > *-gcj, and similar for gcc/go/Make-lang.in:go.install-common,
> > gcc/ada/gcc-interface/Make-lang.in:ada.install-common,
> > gcc/jit/Make-lang.in:jit.install-common.
> 
> I assumed that nobody would build an offloading compiler with 
> --enable-languages
> other than c,c++,fortran[,lto].

Well, but users (like Jakub, for example) ;-) may decide to build the
offloading compilers without specifying --enable-languages, and that'll
then default to include Java, and you'll end up with:

$ ls -l install/offload-x86_64-intelmicemul-linux-gnu/bin/
total 12152
-rwxr-xr-x 1 tschwing eeg3107 Feb 19 13:37 aot-compile
-rwxr-xr-x 1 tschwing eeg9419 Feb 19 13:37 gappletviewer
-rwxr-xr-x 1 tschwing eeg9429 Feb 19 13:37 gc-analyze
-rwxr-xr-x 1 tschwing eeg  105588 Feb 19 13:37 gcj-dbtool
-rwxr-xr-x 1 tschwing eeg9415 Feb 19 13:37 gcjh
-rwxr-xr-x 1 tschwing eeg7453 Feb 19 13:37 gij
-rwxr-xr-x 1 tschwing eeg9385 Feb 19 13:37 gjar
-rwxr-xr-x 1 tschwing eeg9415 Feb 19 13:37 gjarsigner
-rwxr-xr-x 1 tschwing eeg9387 Feb 19 13:37 gjavah
-rwxr-xr-x 1 tschwing eeg9467 Feb 19 13:37 gjdoc
-rwxr-xr-x 1 tschwing eeg9397 Feb 19 13:37 gkeytool
-rwxr-xr-x 1 tschwing eeg9436 Feb 19 13:37 gnative2ascii
-rwxr-xr-x 1 tschwing eeg9386 Feb 19 13:37 gorbd
-rwxr-xr-x 1 tschwing eeg9386 Feb 19 13:37 grmic
-rwxr-xr-x 1 tschwing eeg9386 Feb 19 13:37 grmid
-rwxr-xr-x 1 tschwing eeg9418 Feb 19 13:37 grmiregistry
-rwxr-xr-x 1 tschwing eeg9420 Feb 19 13:37 gserialver
-rwxr-xr-x 1 tschwing eeg9415 Feb 19 13:37 gtnameserv
-rwxr-xr-x 1 tschwing eeg9340 Feb 19 13:37 jv-convert
-rwxr-xr-x 1 tschwing eeg 859 Feb 19 13:37 rebuild-gcj-db
-rwxr-xr-x 2 tschwing eeg 3277373 Feb 19 13:37 
x86_64-intelmicemul-linux-gnu-x86_64-unknown-linux-gnu-accel-x86_64-intelmicemul-linux-gnu-gcj
-rwxr-xr-x 1 tschwing eeg 3231429 Feb 19 13:37 
x86_64-unknown-linux-gnu-accel-x86_64-intelmicemul-linux-gnu-gcc
-rwxr-xr-x 2 tschwing eeg 3277373 Feb 19 13:37 
x86_64-unknown-linux-gnu-accel-x86_64-intelmicemul-linux-gnu-gcj
-rwxr-xr-x 1 tschwing eeg 2327849 Feb 19 13:37 
x86_64-unknown-linux-gnu-accel-x86_64-intelmicemul-linux-gnu-jcf-dump

... and more files with clashing file names in other directories.


Grüße,
 Thomas


pgpe0te3arv6f.pgp
Description: PGP signature


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-20 Thread Ilya Verbin
On Thu, Feb 19, 2015 at 12:37:10 +0100, Thomas Schwinge wrote:
> On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> > gcc/
> > * Makefile.in
> 
> > (install-cpp, install-common, install_driver, install-gcc-ar): Do not
> > install for the offload compiler.
> 
> > gcc/cp/
> > * Make-lang.in (c++.install-common): Do not install for the offload
> > compiler.
> > gcc/fortran/
> > * Make-lang.in (fortran.install-common): Do not install for the offload
> > compiler.
> 
> Hmm, shouldn't that be done for all gcc/*/Make-lang.in?  If I understand
> correctly, if the language is enabled,
> gcc/java/Make-lang.in:java.install-common would currently still install
> *-gcj, and similar for gcc/go/Make-lang.in:go.install-common,
> gcc/ada/gcc-interface/Make-lang.in:ada.install-common,
> gcc/jit/Make-lang.in:jit.install-common.

I assumed that nobody would build an offloading compiler with --enable-languages
other than c,c++,fortran[,lto].

  -- Ilya


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2015-02-19 Thread Thomas Schwinge
Hi!

On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> The patch has been updated:

> if a compiler is configured as accelerator,
> it installs *-accel-*-g++, and other drivers.  But only *-accel-*-gcc is 
> needed.
> Therefore I suppressed their installation in corresponding Makefiles.

> gcc/
>   * Makefile.in

>   (install-cpp, install-common, install_driver, install-gcc-ar): Do not
>   install for the offload compiler.

> gcc/cp/
>   * Make-lang.in (c++.install-common): Do not install for the offload
>   compiler.
> gcc/fortran/
>   * Make-lang.in (fortran.install-common): Do not install for the offload
>   compiler.

Hmm, shouldn't that be done for all gcc/*/Make-lang.in?  If I understand
correctly, if the language is enabled,
gcc/java/Make-lang.in:java.install-common would currently still install
*-gcj, and similar for gcc/go/Make-lang.in:go.install-common,
gcc/ada/gcc-interface/Make-lang.in:ada.install-common,
gcc/jit/Make-lang.in:jit.install-common.


Grüße,
 Thomas


pgpatGV53y4JH.pgp
Description: PGP signature


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-12-15 Thread Kirill Yukhin
Hi,
On 12 Dec 09:17, Jakub Jelinek wrote:
> On Fri, Dec 12, 2014 at 09:14:28AM +0100, Thomas Schwinge wrote:
> > On Tue, 30 Sep 2014 13:16:37 +0200, I wrote:
> > > On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> > > > --- a/configure.ac
> > > > +++ b/configure.ac
> > > > @@ -286,6 +286,24 @@ case ${with_newlib} in
> > > >yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` 
> > > > ;;
> > > >  esac
> > > >  
> > > > +AC_ARG_ENABLE(as-accelerator-for,
> > > > +[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
> > > > +   [build as offload target compiler.
> > > > +   Specify offload host triple by ARG])],
> > > > +ENABLE_AS_ACCELERATOR_FOR=$enableval,
> > > > +ENABLE_AS_ACCELERATOR_FOR=no)
> > > 
> > > I don't see $ENABLE_AS_ACCELERATOR_FOR being used anywhere, so this can
> > > probably be removed?
> > 
> > On Wed, 1 Oct 2014 20:05:45 +0400, Ilya Verbin  wrote:
> > > It will be used in one of the upcoming patches.
> > 
> > OK, but why do you need the all-uppercase variant?  The lowercase
> > enable_as_accelerator_for already is (automatically) populated by
> > Autoconf, and used in other places?  Here is a untested cleanup patch;
> > could you please test this?
> > 
> > * configure.ac (--enable-as-accelerator-for): Don't set
> > ENABLE_AS_ACCELERATOR_FOR.  Update all users.
> > * configure: Regenerate.
> 
> Ok if it works.
The patch doesn't regress MIC offloading.

--
Thanks, K

> 
>   Jakub


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-12-12 Thread Jakub Jelinek
On Fri, Dec 12, 2014 at 09:14:28AM +0100, Thomas Schwinge wrote:
> On Tue, 30 Sep 2014 13:16:37 +0200, I wrote:
> > On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> > > --- a/configure.ac
> > > +++ b/configure.ac
> > > @@ -286,6 +286,24 @@ case ${with_newlib} in
> > >yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
> > >  esac
> > >  
> > > +AC_ARG_ENABLE(as-accelerator-for,
> > > +[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
> > > + [build as offload target compiler.
> > > + Specify offload host triple by ARG])],
> > > +ENABLE_AS_ACCELERATOR_FOR=$enableval,
> > > +ENABLE_AS_ACCELERATOR_FOR=no)
> > 
> > I don't see $ENABLE_AS_ACCELERATOR_FOR being used anywhere, so this can
> > probably be removed?
> 
> On Wed, 1 Oct 2014 20:05:45 +0400, Ilya Verbin  wrote:
> > It will be used in one of the upcoming patches.
> 
> OK, but why do you need the all-uppercase variant?  The lowercase
> enable_as_accelerator_for already is (automatically) populated by
> Autoconf, and used in other places?  Here is a untested cleanup patch;
> could you please test this?
> 
>   * configure.ac (--enable-as-accelerator-for): Don't set
>   ENABLE_AS_ACCELERATOR_FOR.  Update all users.
>   * configure: Regenerate.

Ok if it works.

Jakub


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-12-12 Thread Thomas Schwinge
Hi!

On Tue, 30 Sep 2014 13:16:37 +0200, I wrote:
> On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -286,6 +286,24 @@ case ${with_newlib} in
> >yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
> >  esac
> >  
> > +AC_ARG_ENABLE(as-accelerator-for,
> > +[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
> > +   [build as offload target compiler.
> > +   Specify offload host triple by ARG])],
> > +ENABLE_AS_ACCELERATOR_FOR=$enableval,
> > +ENABLE_AS_ACCELERATOR_FOR=no)
> 
> I don't see $ENABLE_AS_ACCELERATOR_FOR being used anywhere, so this can
> probably be removed?

On Wed, 1 Oct 2014 20:05:45 +0400, Ilya Verbin  wrote:
> It will be used in one of the upcoming patches.

OK, but why do you need the all-uppercase variant?  The lowercase
enable_as_accelerator_for already is (automatically) populated by
Autoconf, and used in other places?  Here is a untested cleanup patch;
could you please test this?

* configure.ac (--enable-as-accelerator-for): Don't set
ENABLE_AS_ACCELERATOR_FOR.  Update all users.
* configure: Regenerate.

diff --git configure configure
index 297f38e..1804198 100755
--- configure
+++ configure
@@ -2893,9 +2893,7 @@ esac
 
 # Check whether --enable-as-accelerator-for was given.
 if test "${enable_as_accelerator_for+set}" = set; then :
-  enableval=$enable_as_accelerator_for; ENABLE_AS_ACCELERATOR_FOR=$enableval
-else
-  ENABLE_AS_ACCELERATOR_FOR=no
+  enableval=$enable_as_accelerator_for;
 fi
 
 
@@ -3094,7 +3092,7 @@ if test "${enable_liboffloadmic+set}" = set; then :
 as_fn_error "--enable-liboffloadmic=no/host/target" "$LINENO" 5 ;;
 esac
 else
-  if test "${ENABLE_AS_ACCELERATOR_FOR}" != "no"; then
+  if test x"$enable_as_accelerator_for" != x; then
   case "${target}" in
 *-intelmic-* | *-intelmicemul-*)
   enable_liboffloadmic=target
diff --git configure.ac configure.ac
index fd1bdf0..91c9a72 100644
--- configure.ac
+++ configure.ac
@@ -289,9 +289,7 @@ esac
 AC_ARG_ENABLE(as-accelerator-for,
 [AS_HELP_STRING([--enable-as-accelerator-for=ARG],
[build as offload target compiler.
-   Specify offload host triple by ARG])],
-ENABLE_AS_ACCELERATOR_FOR=$enableval,
-ENABLE_AS_ACCELERATOR_FOR=no)
+   Specify offload host triple by ARG])])
 
 AC_ARG_ENABLE(offload-targets,
 [AS_HELP_STRING([--enable-offload-targets=LIST],
@@ -470,7 +468,7 @@ AC_HELP_STRING([[--enable-liboffloadmic[=ARG]]],
   *)
 AC_MSG_ERROR([--enable-liboffloadmic=no/host/target]) ;;
 esac],
-[if test "${ENABLE_AS_ACCELERATOR_FOR}" != "no"; then
+[if test x"$enable_as_accelerator_for" != x; then
   case "${target}" in
 *-intelmic-* | *-intelmicemul-*)
   enable_liboffloadmic=target


Grüße,
 Thomas


signature.asc
Description: PGP signature


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-10-01 Thread Ilya Verbin
On 26 Sep 22:02, Joseph S. Myers wrote:
> Any patch adding new configure options needs to add documentation of the 
> semantics of those options in install.texi.  I see no such documentation 
> in this patch.

Done.

On 30 Sep 13:16, Thomas Schwinge wrote:
> Doesn't that comment belong to real_target_noncanonical just above?  By
> default, accel_dir_suffix is empty.  Probably also move accel_dir_suffix
> above to where real_target_noncanonical is being set?

Right, done.

> I don't see $ENABLE_AS_ACCELERATOR_FOR being used anywhere, so this can
> probably be removed?

It will be used in one of the upcoming patches.

> Also, given that we're addding --enable-as-accelerator-for and
> --enable-offload-targets to the top-level configure, do we need really to
> repeat (and thus, in the future maintain) those also in the subdirectory
> configure files where the respective enable_* flags are evaulated?  If my
> understanding of Autoconf is correct, then the enable_* variables will be
> available in the subdirectory configure files, even without repeating the
> AC_ARG_ENABLE instantiations.
> 
> How is this handled for other --enable-[...] flags that are needed in
> several configure files?
> 
> Thus, here you should be able to remove the AC_ARG_ENABLE for
> --enable-as-accelerator-for, and just do something like (untested):
> 
> if test x"$enable_as_accelerator" != x; then
>   AC_DEFINE([...])
>   [...]
> fi
> 
> I'm not sure whether the AC_SUBST for enable_as_accelerator needs to be
> repeated.  (I think it needs to be repeated.)
> 
> Likewise, and also in the other */configure.ac files.

I didn't know that this is possible.  Thanks, done.
AC_SUBST needs to be repeated.

> Can't we move these two AC_SUBST invocation up to where the variables are
> being defined?

Done.

> ..., also use OFFLOAD_*_TABLE_*, but on the other hand use _omp_*_table.
> For consistency, shouldn't these also be named _offload_*_table?  Then
> the »OpenMP« could be removed from the description in line 1 (just
> »needed for the offloading tables«, and the file also be renamed to
> offloadstuff.c or similar.  I certainly do acknowledge the role that
> OpenMP has played in the development of this, but yet, this
> infrastructure is not tied to OpenMP.
> 
> Also, the name __OPENMP_TARGET__ here is more opaque than it needs to be:
> what about using __OFFLOADING_TABLE__ or similar.  As I have argued
> before in a similar context (and Jakub has generally agreed): »the
> "target" tag is confusing in that "target" typically has a different
> meaning in the compiler context -- while this one here is used for
> implementing OpenMP's target construct, what it technically does should
> be described by .gnu.offload_[...] or somthing similar.  [...] Again, all
> this doesn't matter to anyone who's already versed with the code, but it
> does matter to people who are new, and still have to learn all these fine
> details.  (Of which there are many, many more.  Yes, I know, life's
> tough, and I'm used to that, but still.)  ;-)«.
> 
> If you agree, then these files would be renamed to
> crtoffload[ing]{begin,end}$(objext).

Sounds reasonable, renamed.

On 30 Sep 12:10, Jakub Jelinek wrote:
> If you add the documentation Joseph requested, looks good to me
> (once the rest is reviewed too).

If no other objections, I will consider this patch as a pre-approved.

Thanks,
  -- Ilya


* configure: Regenerate.
* configure.ac (--enable-as-accelerator-for)
(--enable-offload-targets): New configure options.
gcc/
* Makefile.in (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator): New variables substituted by configure.
(libsubdir, libexecsubdir, unlibsubdir): Tweak for the possibility of
being configured as an offload compiler.
(DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
ACCEL_DIR_SUFFIX.
(install-cpp, install-common, install_driver, install-gcc-ar): Do not
install for the offload compiler.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator): Compute new variables.
(ACCEL_COMPILER): Define if the compiler is built as the accel compiler.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
(ENABLE_OFFLOADING): Define if list of offload targets is not empty.
gcc/cp/
* Make-lang.in (c++.install-common): Do not install for the offload
compiler.
gcc/doc/
* install.texi (Options specification): Document
--enable-as-accelerator-for and --enable-offload-targets.
gcc/fortran/
* Make-lang.in (fortran.install-common): Do not install for the offload
compiler.
libgcc/
* Makefile.in (crtoffloadbegin$(objext)): New rule.
(crtoffloadend$(objext)): Likewise.
* configure: Regenerate.
* configure.ac (accel_dir_suffix): C

Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-30 Thread Thomas Schwinge
Hi!

On Fri, 26 Sep 2014 16:36:21 +0400, Ilya Verbin  wrote:
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -58,6 +58,7 @@ build=@build@
>  host=@host@
>  target=@target@
>  target_noncanonical:=@target_noncanonical@
> +real_target_noncanonical:=@real_target_noncanonical@
>  
>  # Sed command to transform gcc to installed name.
>  program_transform_name := @program_transform_name@
> @@ -66,6 +67,10 @@ program_transform_name := @program_transform_name@
>  # Directories used during build
>  # -
>  
> +# Normally identical to target_noncanonical, except for compilers built
> +# as accelerator targets.
> +accel_dir_suffix = @accel_dir_suffix@

Doesn't that comment belong to real_target_noncanonical just above?  By
default, accel_dir_suffix is empty.  Probably also move accel_dir_suffix
above to where real_target_noncanonical is being set?


> --- a/configure.ac
> +++ b/configure.ac
> @@ -286,6 +286,24 @@ case ${with_newlib} in
>yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
>  esac
>  
> +AC_ARG_ENABLE(as-accelerator-for,
> +[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
> + [build as offload target compiler.
> + Specify offload host triple by ARG])],
> +ENABLE_AS_ACCELERATOR_FOR=$enableval,
> +ENABLE_AS_ACCELERATOR_FOR=no)

I don't see $ENABLE_AS_ACCELERATOR_FOR being used anywhere, so this can
probably be removed?

Also, given that we're addding --enable-as-accelerator-for and
--enable-offload-targets to the top-level configure, do we need really to
repeat (and thus, in the future maintain) those also in the subdirectory
configure files where the respective enable_* flags are evaulated?  If my
understanding of Autoconf is correct, then the enable_* variables will be
available in the subdirectory configure files, even without repeating the
AC_ARG_ENABLE instantiations.

How is this handled for other --enable-[...] flags that are needed in
several configure files?

> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -883,6 +887,53 @@ AC_ARG_ENABLE(languages,
>  esac],
>  [enable_languages=c])
>  
> +AC_ARG_ENABLE(as-accelerator-for,
> +[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
> + [build as offload target compiler.
> + Specify offload host triple by ARG])],
> +[
> +  AC_DEFINE(ACCEL_COMPILER, 1,
> +[Define if this compiler should be built as the offload target 
> compiler.])
> +  enable_as_accelerator=yes
> +  case "${target}" in
> +*-intelmicemul-*)
> +  # In this case we expect offload compiler to be built as native, so we
> +  # need to rename the driver to avoid clashes with host's drivers.
> +  program_transform_name="s&^&${target}-&" ;;
> +  esac
> +  
> sedscript="s#${target_noncanonical}#${enable_as_accelerator_for}-accel-${target_noncanonical}#"
> +  program_transform_name=`echo $program_transform_name | sed $sedscript`
> +  accel_dir_suffix=/accel/${target_noncanonical}
> +  real_target_noncanonical=${enable_as_accelerator_for}
> +], [enable_as_accelerator=no])
> +AC_SUBST(enable_as_accelerator)

Thus, here you should be able to remove the AC_ARG_ENABLE for
--enable-as-accelerator-for, and just do something like (untested):

if test x"$enable_as_accelerator" != x; then
  AC_DEFINE([...])
  [...]
fi

I'm not sure whether the AC_SUBST for enable_as_accelerator needs to be
repeated.  (I think it needs to be repeated.)

> +AC_ARG_ENABLE(offload-targets,

Likewise, and also in the other */configure.ac files.


> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac

> +AC_SUBST(real_target_noncanonical)
> +AC_SUBST(accel_dir_suffix)

Can't we move these two AC_SUBST invocation up to where the variables are
being defined?


> --- /dev/null
> +++ b/libgcc/ompstuff.c
> @@ -0,0 +1,80 @@
> +/* Specialized bits of code needed for the OpenMP offloading tables.

> +#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__gnu_offload_funcs"
> +#define OFFLOAD_VAR_TABLE_SECTION_NAME "__gnu_offload_vars"

Here we use __gnu_offload_* names here, and...

> +void *_omp_func_table[0]
> +  __attribute__ ((__used__, visibility ("hidden"),
> +   section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
> +void *_omp_var_table[0]
> +  __attribute__ ((__used__, visibility ("hidden"),
> +   section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };

..., also use OFFLOAD_*_TABLE_*, but on the other hand use _omp_*_table.
For consistency, shouldn't these also be named _offload_*_table?  Then
the »OpenMP« could be removed from the description in line 1 (just
»needed for the offloading tables«, and the file also be renamed to
offloadstuff.c or similar.  I certainly do acknowledge the role that
OpenMP has played in the development of this, but yet, this
infrastructure is not tied to OpenMP.

> +void *__OPENMP_TARGET__[]
> +  __attribute__ ((__visibility__ ("hidden"))) =
> +{
> +  &_omp_func_table, &_omp_funcs_end,
> +  &_omp_var_table, &_omp_vars_end
> +};

Also, the name __OPENMP_

Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-30 Thread Jakub Jelinek
On Fri, Sep 26, 2014 at 04:36:21PM +0400, Ilya Verbin wrote:
> 2014-09-26  Bernd Schmidt  
>   Thomas Schwinge  
>   Ilya Verbin  
>   Andrey Turetskiy  
> 
>   * configure: Regenerate.
>   * configure.ac (--enable-as-accelerator-for)
>   (--enable-offload-targets): New configure options.
> gcc/
>   * Makefile.in (real_target_noncanonical, accel_dir_suffix)
>   (enable_as_accelerator): New variables substituted by configure.
>   (libsubdir, libexecsubdir, unlibsubdir): Tweak for the possibility of
>   being configured as an offload compiler.
>   (DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
>   ACCEL_DIR_SUFFIX.
>   (install-cpp, install-common, install_driver, install-gcc-ar): Do not
>   install for the offload compiler.
>   * config.in: Regenerate.
>   * configure: Regenerate.
>   * configure.ac (real_target_noncanonical, accel_dir_suffix)
>   (enable_as_accelerator, enable_offload_targets): Compute new variables.
>   (--enable-as-accelerator-for, --enable-offload-targets): New options.
>   (ACCEL_COMPILER): Define if the compiler is built as the accel compiler.
>   (OFFLOAD_TARGETS): List of target names suitable for offloading.
>   (ENABLE_OFFLOADING): Define if list of offload targets is not empty.
> gcc/cp/
>   * Make-lang.in (c++.install-common): Do not install for the offload
>   compiler.
> gcc/fortran/
>   * Make-lang.in (fortran.install-common): Do not install for the offload
>   compiler.
> libgcc/
>   * Makefile.in (crtompbegin$(objext), crtompend$(objext)): New rule.
>   * configure: Regenerate.
>   * configure.ac (--enable-as-accelerator-for)
>   (--enable-offload-targets): New configure options.
>   (extra_parts): Add crtompbegin.o and crtompend.o if
>   enable_offload_targets is not empty.
>   * ompstuff.c: New file.
> libgomp/
>   * config.h.in: Regenerate.
>   * configure: Regenerate.
>   * configure.ac: Check for libdl, required for plugin support.
>   (PLUGIN_SUPPORT): Define if plugins are supported.
>   (--enable-offload-targets): New configure option.
>   (enable_offload_targets): Support Intel MIC targets.
>   (OFFLOAD_TARGETS): List of target names suitable for offloading.
> lto-plugin/
>   * Makefile.am (libexecsubdir): Tweak for the possibility of being
>   configured for offload compiler.
>   (accel_dir_suffix): New variable substituted by configure.
>   * Makefile.in: Regenerate.
>   * configure: Regenerate.
>   * configure.ac (--enable-as-accelerator-for): New option.

If you add the documentation Joseph requested, looks good to me
(once the rest is reviewed too).

Jakub


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-26 Thread Joseph S. Myers
On Fri, 26 Sep 2014, Ilya Verbin wrote:

> 2014-09-26  Bernd Schmidt  
>   Thomas Schwinge  
>   Ilya Verbin  
>   Andrey Turetskiy  
> 
>   * configure: Regenerate.
>   * configure.ac (--enable-as-accelerator-for)
>   (--enable-offload-targets): New configure options.
> gcc/
>   * Makefile.in (real_target_noncanonical, accel_dir_suffix)
>   (enable_as_accelerator): New variables substituted by configure.
>   (libsubdir, libexecsubdir, unlibsubdir): Tweak for the possibility of
>   being configured as an offload compiler.
>   (DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
>   ACCEL_DIR_SUFFIX.
>   (install-cpp, install-common, install_driver, install-gcc-ar): Do not
>   install for the offload compiler.
>   * config.in: Regenerate.
>   * configure: Regenerate.
>   * configure.ac (real_target_noncanonical, accel_dir_suffix)
>   (enable_as_accelerator, enable_offload_targets): Compute new variables.
>   (--enable-as-accelerator-for, --enable-offload-targets): New options.
>   (ACCEL_COMPILER): Define if the compiler is built as the accel compiler.
>   (OFFLOAD_TARGETS): List of target names suitable for offloading.
>   (ENABLE_OFFLOADING): Define if list of offload targets is not empty.

Any patch adding new configure options needs to add documentation of the 
semantics of those options in install.texi.  I see no such documentation 
in this patch.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-26 Thread Ilya Verbin
Hi,

The patch has been updated:

On 17 Sep 15:45, Jakub Jelinek wrote:
> Looks mostly ok, just some nits.  But see the patch I've just posted,
> perhaps we want to tweak the --enable-offload-targets arguments.  And

Now the targets in --enable-offload-targets can have optional path to the build
or install tree of the corresponding offload compiler.

> > --- /dev/null
> > +++ b/libgcc/ompstuff.c
> > @@ -0,0 +1,79 @@
> > +/* FIXME: Including auto-host is incorrect, but until we have
> > +   identified the set of defines that need to go into auto-target.h,
> > +   this will have to do.  */
> > +#include "auto-host.h"
> > +#undef pid_t
> > +#undef rlim_t
> > +#undef ssize_t
> > +#undef vfork
> 
> crtstuff.c undefs here also caddr_t, any reason not to do that too?

caddr_t was added to the crtstuff.c after ompstuff.c was created.  Fixed.

> > +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING)
> > +void *_omp_func_table[0]
> > +  __attribute__ ((__used__, visibility ("hidden"),
> > + section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
> > +void *_omp_var_table[0]
> > +  __attribute__ ((__used__, visibility ("hidden"),
> > + section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };
> > +#endif
> 
> Does this mean that if HAVE_GAS_HIDDEN is not defined, you don't
> define _omp_*_table at all and offloading will fail?
> I wonder if it just should avoid visibility ("hidden") if it isn't
> supported.

Without visibility ("hidden") offloading works in case if there is only an
executable.  If some dso will register their _omp_func_table in libgomp,
offloading will not work, since _omp_func_table from the executable override
the respective symbols in dso.  So, if there are exec and dso with offloading,
but without visibility ("hidden"), I'd prefer to perform host fallback, as is
now, rather than crashing at run-time.

Also, previous patch contains a bug: if a compiler is configured as accelerator,
it installs *-accel-*-g++, and other drivers.  But only *-accel-*-gcc is needed.
Therefore I suppressed their installation in corresponding Makefiles.

The define OFFLOAD_LIBRARY is now removed from libgomp, since it is no longer
needed.

And libexecsubdir in lto-plugin/Makefile.in is tweaked for the possibility of
being configured as accelerator (like it was done in gcc/Makefile.in).
Otherwise offload compiler is unable to find its plugin.

Bootstrapped and regtested on i686-linux and x86_64-linux.
OK for trunk (after everything has been reviewed)?


2014-09-26  Bernd Schmidt  
Thomas Schwinge  
Ilya Verbin  
Andrey Turetskiy  

* configure: Regenerate.
* configure.ac (--enable-as-accelerator-for)
(--enable-offload-targets): New configure options.
gcc/
* Makefile.in (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator): New variables substituted by configure.
(libsubdir, libexecsubdir, unlibsubdir): Tweak for the possibility of
being configured as an offload compiler.
(DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
ACCEL_DIR_SUFFIX.
(install-cpp, install-common, install_driver, install-gcc-ar): Do not
install for the offload compiler.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator, enable_offload_targets): Compute new variables.
(--enable-as-accelerator-for, --enable-offload-targets): New options.
(ACCEL_COMPILER): Define if the compiler is built as the accel compiler.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
(ENABLE_OFFLOADING): Define if list of offload targets is not empty.
gcc/cp/
* Make-lang.in (c++.install-common): Do not install for the offload
compiler.
gcc/fortran/
* Make-lang.in (fortran.install-common): Do not install for the offload
compiler.
libgcc/
* Makefile.in (crtompbegin$(objext), crtompend$(objext)): New rule.
* configure: Regenerate.
* configure.ac (--enable-as-accelerator-for)
(--enable-offload-targets): New configure options.
(extra_parts): Add crtompbegin.o and crtompend.o if
enable_offload_targets is not empty.
* ompstuff.c: New file.
libgomp/
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for libdl, required for plugin support.
(PLUGIN_SUPPORT): Define if plugins are supported.
(--enable-offload-targets): New configure option.
(enable_offload_targets): Support Intel MIC targets.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
lto-plugin/
* Makefile.am (libexecsubdir): Tweak for the possibility of being
configured for offload compiler.
(accel_dir_suffix): New variable substituted by configure.
* Makefile.in: Regenerate.
* config

Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-17 Thread Jakub Jelinek
On Mon, Sep 15, 2014 at 08:52:27PM +0400, Ilya Verbin wrote:
> This patch contains necessary changes for the build system to support 
> offloading.
> It adds 2 new options for configure:
> * --enable-as-accelerator-for=ARG is intended for the offload target compiler.
> * --enable-offload-targets=LIST is intended for the offload host compiler.
> Some more info: 
> https://gcc.gnu.org/wiki/Offloading#Building_host_and_accel_compilers
> 
> Bootstrapped and regtested on i686-linux and x86_64-linux.  Is it OK for 
> trunk?

Looks mostly ok, just some nits.  But see the patch I've just posted,
perhaps we want to tweak the --enable-offload-targets arguments.  And
I'd strongly prefer if the offloading patches are committed after everything
has been reviewed, so what will be acked please stash away for later batch
commits.
> --- /dev/null
> +++ b/libgcc/ompstuff.c
> @@ -0,0 +1,79 @@
> +/* FIXME: Including auto-host is incorrect, but until we have
> +   identified the set of defines that need to go into auto-target.h,
> +   this will have to do.  */
> +#include "auto-host.h"
> +#undef pid_t
> +#undef rlim_t
> +#undef ssize_t
> +#undef vfork

crtstuff.c undefs here also caddr_t, any reason not to do that too?

> +#include "tconfig.h"
> +#include "tsystem.h"
> +#include "coretypes.h"
> +#include "tm.h"
> +#include "libgcc_tm.h"
> +
> +#define OFFLOAD_FUNC_TABLE_SECTION_NAME "__gnu_offload_funcs"
> +#define OFFLOAD_VAR_TABLE_SECTION_NAME "__gnu_offload_vars"
> +
> +#ifdef CRT_BEGIN
> +
> +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING)
> +void *_omp_func_table[0]
> +  __attribute__ ((__used__, visibility ("hidden"),
> +   section (OFFLOAD_FUNC_TABLE_SECTION_NAME))) = { };
> +void *_omp_var_table[0]
> +  __attribute__ ((__used__, visibility ("hidden"),
> +   section (OFFLOAD_VAR_TABLE_SECTION_NAME))) = { };
> +#endif

Does this mean that if HAVE_GAS_HIDDEN is not defined, you don't
define _omp_*_table at all and offloading will fail?
I wonder if it just should avoid visibility ("hidden") if it isn't
supported.

Jakub


[PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-15 Thread Ilya Verbin
Hello,

This patch contains necessary changes for the build system to support 
offloading.
It adds 2 new options for configure:
* --enable-as-accelerator-for=ARG is intended for the offload target compiler.
* --enable-offload-targets=LIST is intended for the offload host compiler.
Some more info: 
https://gcc.gnu.org/wiki/Offloading#Building_host_and_accel_compilers

Bootstrapped and regtested on i686-linux and x86_64-linux.  Is it OK for trunk?


2014-09-15  Bernd Schmidt  
Thomas Schwinge  
Ilya Verbin  
Andrey Turetskiy  

* configure: Regenerate.
* configure.ac (--enable-as-accelerator-for)
(--enable-offload-targets): New configure options.
gcc/
* Makefile.in (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator): New variables substituted by configure.
(libsubdir, libexecsubdir, unlibsubdir, install_driver): Tweak for the
possibility of being configured as an offload compiler.
(DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
ACCEL_DIR_SUFFIX.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator, enable_offload_targets): Compute new variables.
(--enable-as-accelerator-for, --enable-offload-targets): New options.
(ACCEL_COMPILER): Define if the compiler is built as the accel compiler.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
(ENABLE_OFFLOADING): Define if list of offload targets is not empty.
libgcc/
* Makefile.in (crtompbegin$(objext), crtompend$(objext)): New rule.
* configure: Regenerate.
* configure.ac (--enable-offload-targets): New configure option.
(extra_parts): Add crtompbegin.o and crtompend.o if
enable_offload_targets is not empty.
* ompstuff.c: New file.
libgomp/
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for libdl, required for plugin support.
(PLUGIN_SUPPORT): Define if plugins are supported.
(--enable-as-accelerator-for, --enable-offload-targets): New options.
(OFFLOAD_LIBRARY): Define if libgomp is built as offload target library.
(enable_offload_targets): Support Intel MIC targets.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
* testsuite/Makefile.in: Regenerate.

Thanks,
  -- Ilya

---

diff --git a/configure b/configure
index 55fca62..fb40a2f 100755
--- a/configure
+++ b/configure
@@ -747,6 +747,8 @@ ospace_frag'
 ac_user_opts='
 enable_option_checking
 with_build_libsubdir
+enable_as_accelerator_for
+enable_offload_targets
 enable_gold
 enable_ld
 enable_libquadmath
@@ -1466,6 +1468,11 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE   do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-as-accelerator-for=ARG
+  build as offload target compiler. Specify offload
+  host triple by ARG.
+  --enable-offload-targets=LIST
+  enable offloading to devices from LIST
   --enable-gold[=ARG] build gold [ARG={default,yes,no}]
   --enable-ld[=ARG]   build ld [ARG={default,yes,no}]
   --disable-libquadmath   do not build libquadmath directory
@@ -2893,6 +2900,26 @@ case ${with_newlib} in
   yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
 esac
 
+# Check whether --enable-as-accelerator-for was given.
+if test "${enable_as_accelerator_for+set}" = set; then :
+  enableval=$enable_as_accelerator_for; ENABLE_AS_ACCELERATOR_FOR=$enableval
+else
+  ENABLE_AS_ACCELERATOR_FOR=no
+fi
+
+
+# Check whether --enable-offload-targets was given.
+if test "${enable_offload_targets+set}" = set; then :
+  enableval=$enable_offload_targets;
+  if test x"$enable_offload_targets" = x; then
+as_fn_error "no offload targets specified" "$LINENO" 5
+  fi
+
+else
+  enable_offload_targets=
+fi
+
+
 # Handle --enable-gold, --enable-ld.
 # --disable-gold [--enable-ld]
 # Build only ld.  Default option.
diff --git a/configure.ac b/configure.ac
index 2dc657f..69e2d14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -286,6 +286,22 @@ case ${with_newlib} in
   yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
 esac
 
+AC_ARG_ENABLE(as-accelerator-for,
+[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
+   [build as offload target compiler.
+   Specify offload host triple by ARG.])],
+ENABLE_AS_ACCELERATOR_FOR=$enableval,
+ENABLE_AS_ACCELERATOR_FOR=no)
+
+AC_ARG_ENABLE(offload-targets,
+[AS_HELP_STRING([--enable-offload-targets=LIST],
+   [enable offloading to devices from LIST])],
+[
+  if test x"$enable_offload_targets" = x

Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-11 Thread Ilya Verbin
On 11 Sep 13:34, Jakub Jelinek wrote:
> I think it is not useful to split patches on in which sequence they were
> added to the tree.  I'd prefer patches for functional parts for the
> differences between trunk and corresponding offloading branch.
> So, one patch should be all the libgomp changes except for addition of
> plugins, another one generic middle-end changes, then the libmicoffload
> support library, then libgomp plugin for Intel MIC and finally rest of Intel
> MIC enablements.  E.g. the patch you've posted contains tons of FIXMEs that
> really shouldn't make into the trunk, not even short lived.
> 
>   Jakub

Ok.  All other libgomp changes depend on the defines from configure.
So I'll start from the patch, which adds new options for the configure.

Thanks,
  -- Ilya


Re: [PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-11 Thread Jakub Jelinek
On Thu, Sep 11, 2014 at 03:28:02PM +0400, Ilya Verbin wrote:
> I would like to start merging offloading-related patches from gomp-4_0-branch 
> to trunk.
> This is the first patch (from r202620), which adds a splay tree and memory 
> mapping to libgomp.
> I removed temporarily device 257 from it.  Bootstrapped and regtested on 
> x86_64-linux.

I think it is not useful to split patches on in which sequence they were
added to the tree.  I'd prefer patches for functional parts for the
differences between trunk and corresponding offloading branch.
So, one patch should be all the libgomp changes except for addition of
plugins, another one generic middle-end changes, then the libmicoffload
support library, then libgomp plugin for Intel MIC and finally rest of Intel
MIC enablements.  E.g. the patch you've posted contains tons of FIXMEs that
really shouldn't make into the trunk, not even short lived.

Jakub


[PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-11 Thread Ilya Verbin
Hello,

I would like to start merging offloading-related patches from gomp-4_0-branch 
to trunk.
This is the first patch (from r202620), which adds a splay tree and memory 
mapping to libgomp.
I removed temporarily device 257 from it.  Bootstrapped and regtested on 
x86_64-linux.

2014-09-11  Jakub Jelinek  

* splay-tree.h: New file.
* target.c (splay_tree_node, splay_tree, splay_tree_key): New typedefs.
(struct target_mem_desc, struct splay_tree_key_s): New structures.
(splay_compare): New inline function.
(resolve_device): Use default_device_var ICV.
(dev_splay_tree, dev_env_lock): New variables.
(gomp_map_vars_existing, gomp_map_vars, gomp_unmap_tgt,
gomp_unmap_vars, gomp_update): New functions.
(GOMP_target): Arrange for host callback to be performed in a
separate initial thread and contention group, inheriting ICVs from
gomp_global_icv etc.
(GOMP_target_data): Use gomp_map_vars.
(GOMP_target_end_data): Use gomp_unmap_vars.
(GOMP_target_update): Use gomp_update.

Thanks,
  -- Ilya

---

diff --git a/libgomp/splay-tree.h b/libgomp/splay-tree.h
new file mode 100644
index 000..eb8011a
--- /dev/null
+++ b/libgomp/splay-tree.h
@@ -0,0 +1,232 @@
+/* A splay-tree datatype.
+   Copyright 1998-2014
+   Free Software Foundation, Inc.
+   Contributed by Mark Mitchell (m...@markmitchell.com).
+
+   This file is part of the GNU OpenMP Library (libgomp).
+
+   Libgomp is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   .  */
+
+/* The splay tree code copied from include/splay-tree.h and adjusted,
+   so that all the data lives directly in splay_tree_node_s structure
+   and no extra allocations are needed.
+
+   Files including this header should before including it add:
+typedef struct splay_tree_node_s *splay_tree_node;
+typedef struct splay_tree_s *splay_tree;
+typedef struct splay_tree_key_s *splay_tree_key;
+   define splay_tree_key_s structure, and define
+   splay_compare inline function.  */
+
+/* For an easily readable description of splay-trees, see:
+
+ Lewis, Harry R. and Denenberg, Larry.  Data Structures and Their
+ Algorithms.  Harper-Collins, Inc.  1991.
+
+   The major feature of splay trees is that all basic tree operations
+   are amortized O(log n) time for a tree with n nodes.  */
+
+/* The nodes in the splay tree.  */
+struct splay_tree_node_s {
+  struct splay_tree_key_s key;
+  /* The left and right children, respectively.  */
+  splay_tree_node left;
+  splay_tree_node right;
+};
+
+/* The splay tree.  */
+struct splay_tree_s {
+  splay_tree_node root;
+};
+
+/* Rotate the edge joining the left child N with its parent P.  PP is the
+   grandparents' pointer to P.  */
+
+static inline void
+rotate_left (splay_tree_node *pp, splay_tree_node p, splay_tree_node n)
+{
+  splay_tree_node tmp;
+  tmp = n->right;
+  n->right = p;
+  p->left = tmp;
+  *pp = n;
+}
+
+/* Rotate the edge joining the right child N with its parent P.  PP is the
+   grandparents' pointer to P.  */
+
+static inline void
+rotate_right (splay_tree_node *pp, splay_tree_node p, splay_tree_node n)
+{
+  splay_tree_node tmp;
+  tmp = n->left;
+  n->left = p;
+  p->right = tmp;
+  *pp = n;
+}
+
+/* Bottom up splay of KEY.  */
+
+static void
+splay_tree_splay (splay_tree sp, splay_tree_key key)
+{
+  if (sp->root == NULL)
+return;
+
+  do {
+int cmp1, cmp2;
+splay_tree_node n, c;
+
+n = sp->root;
+cmp1 = splay_compare (key, &n->key);
+
+/* Found.  */
+if (cmp1 == 0)
+  return;
+
+/* Left or right?  If no child, then we're done.  */
+if (cmp1 < 0)
+  c = n->left;
+else
+  c = n->right;
+if (!c)
+  return;
+
+/* Next one left or right?  If found or no child, we're done
+   after one rotation.  */
+cmp2 = splay_compare (key, &c->key);
+if (cmp2 == 0
+   || (cmp2 < 0 && !c->left)
+   || (cmp2 > 0 && !c->right))
+  {
+   if (cmp1 < 0)
+ rotate_left (&sp->root, n, c);
+   else
+ rotate_right (&sp->root, n, c);
+   return;
+  }
+
+/* Now we