On 02/28/2014 05:21 PM, Bernd Schmidt wrote:
On 02/28/2014 05:09 PM, Ilya Verbin wrote:
Unfortunately I don't fully understand this configure magic... When a
user specifies 2 or 3 accelerators during configuration with
--enable-accelerators, will several different accel-gccs be built?

No - the idea is that --enable-accelerator= is likely specific to ptx,
where we really just want to build a gcc and no target libraries, so
building it alongside the host in an accel-gcc subdirectory is ideal.

For your use case, I'd imagine the offload compiler would be built
relatively normally as a full build with
"--enable-as-accelerator-for=x86_64-linux", which would install it into
locations where the host will eventually be able to find it. Then the
host compiler would be built with another new configure option (as yet
unimplemented in my patch set) "--enable-offload-targets=mic,..." which
would tell the host compiler about the pre-built offload target
compilers. On the ptx side, "--enable-accelerator=ptx" would then also
add ptx to the list of --enable-offload-targets.
Naming of all these configure options can be discussed, I have no real
preference for any of them.

IOW, something like the following on top of the other patches. Ideally we'd also add error checking to make sure the offload compilers exist in the places we'll be looking for them.


Bernd

Index: gomp-4_0-branch/gcc/config.in
===================================================================
--- gomp-4_0-branch.orig/gcc/config.in
+++ gomp-4_0-branch/gcc/config.in
@@ -1748,6 +1748,12 @@
 #endif
 
 
+/* Define to hold the list of target names suitable for offloading. */
+#ifndef USED_FOR_TARGET
+#undef OFFLOAD_TARGETS
+#endif
+
+
 /* Define to the address where bug reports for this package should be sent. */
 #ifndef USED_FOR_TARGET
 #undef PACKAGE_BUGREPORT
Index: gomp-4_0-branch/gcc/configure
===================================================================
--- gomp-4_0-branch.orig/gcc/configure
+++ gomp-4_0-branch/gcc/configure
@@ -908,6 +908,7 @@ with_bugurl
 enable_languages
 enable_accelerator
 enable_as_accelerator_for
+enable_offload_targets
 with_multilib_list
 enable_rpath
 with_libiconv_prefix
@@ -1618,6 +1619,8 @@ Optional Features:
   --enable-accelerator    build accelerator [ARG={no,device-triplet}]
   --enable-as-accelerator-for
                           build compiler as accelerator target for given host
+  --enable-offload-targets=LIST
+                          enable offloading to devices from LIST
   --disable-rpath         do not hardcode runtime library paths
   --enable-sjlj-exceptions
                           arrange to use setjmp/longjmp exception handling
@@ -7299,12 +7302,14 @@ else
 fi
 
 
+offload_targets=
 # Check whether --enable-accelerator was given.
 if test "${enable_accelerator+set}" = set; then :
   enableval=$enable_accelerator;
   case $enable_accelerator in
   no) ;;
   *)
+    offload_targets=$enable_accelerator
 
 $as_echo "#define ENABLE_OFFLOADING 1" >>confdefs.h
 
@@ -7343,6 +7348,31 @@ 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
+  else
+    if test x$offload_targets = x; then
+      offload_targets=$enable_offload_targets
+    else
+      offload_targets=$offload_targets,$enable_offload_targets
+    fi
+  fi
+
+else
+  enable_accelerator=no
+fi
+
+
+offload_targets=`echo $offload_targets | sed -e 's#,#:#'`
+
+cat >>confdefs.h <<_ACEOF
+#define OFFLOAD_TARGETS "$offload_targets"
+_ACEOF
+
+
 
 # Check whether --with-multilib-list was given.
 if test "${with_multilib_list+set}" = set; then :
@@ -17983,7 +18013,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17986 "configure"
+#line 18016 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18089,7 +18119,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18092 "configure"
+#line 18122 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gomp-4_0-branch/gcc/configure.ac
===================================================================
--- gomp-4_0-branch.orig/gcc/configure.ac
+++ gomp-4_0-branch/gcc/configure.ac
@@ -839,12 +839,14 @@ AC_ARG_ENABLE(languages,
 esac],
 [enable_languages=c])
 
+offload_targets=
 AC_ARG_ENABLE(accelerator,
 [AS_HELP_STRING([--enable-accelerator], [build accelerator @<:@ARG={no,device-triplet}@:>@])],
 [
   case $enable_accelerator in
   no) ;;
   *)
+    offload_targets=$enable_accelerator
     AC_DEFINE(ENABLE_OFFLOADING, 1,
      [Define this to enable support for offloading.])
     AC_DEFINE_UNQUOTED(ACCEL_TARGET,"${enable_accelerator}",
@@ -871,6 +873,25 @@ AC_ARG_ENABLE(as-accelerator-for,
 ], [enable_as_accelerator=no])
 AC_SUBST(enable_as_accelerator)
 
+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; then
+    AC_MSG_ERROR([no offload targets specified])
+  else
+    if test x$offload_targets = x; then
+      offload_targets=$enable_offload_targets
+    else
+      offload_targets=$offload_targets,$enable_offload_targets
+    fi
+  fi
+], [enable_accelerator=no])
+AC_SUBST(enable_accelerator)
+offload_targets=`echo $offload_targets | sed -e 's#,#:#'`
+AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
+ [Define to hold the list of target names suitable for offloading.])
+
 AC_ARG_WITH(multilib-list,
 [AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, SH and x86-64 only)])],
 :,
Index: gomp-4_0-branch/gcc/gcc.c
===================================================================
--- gomp-4_0-branch.orig/gcc/gcc.c
+++ gomp-4_0-branch/gcc/gcc.c
@@ -6687,6 +6687,16 @@ main (int argc, char **argv)
   obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1);
   xputenv (XOBFINISH (&collect_obstack, char *));
 
+  if (strlen (OFFLOAD_TARGETS) > 0)
+    {
+      obstack_init (&collect_obstack);
+      obstack_grow (&collect_obstack, "OFFLOAD_TARGET_NAMES=",
+		    sizeof ("OFFLOAD_TARGET_NAMES=") - 1);
+      obstack_grow (&collect_obstack, OFFLOAD_TARGETS,
+		    strlen (OFFLOAD_TARGETS) + 1);
+      xputenv (XOBFINISH (&collect_obstack, char *));
+    }
+
   /* Set up to remember the pathname of the lto wrapper. */
 
   if (have_c)

Reply via email to