public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
@ 2014-11-21 18:44 Bernd Edlinger
  2014-11-21 18:59 ` Ilya Verbin
  0 siblings, 1 reply; 27+ messages in thread
From: Bernd Edlinger @ 2014-11-21 18:44 UTC (permalink / raw)
  To: Kirill Yukhin, Andrey Turetskiy; +Cc: Jakub Jelinek, Ilya Verbin, gcc-patches

Aehm Kirill,

excuse me please, but if I do

autogen Makefile.def


I get this from svn diff

Index: Makefile.in
===================================================================
--- Makefile.in    (revision 217890)
+++ Makefile.in    (working copy)
@@ -35238,9 +35238,6 @@
     $(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/liboffloadmic ; \
     $(NORMAL_TARGET_EXPORTS)  \
     echo Configuring in $(TARGET_SUBDIR)/liboffloadmic; \
-     \
-    this_target="${target_alias}"; \
-     \
     cd "$(TARGET_SUBDIR)/liboffloadmic" || exit 1; \
     case $(srcdir) in \
       /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
@@ -35248,14 +35245,12 @@
         sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
     esac; \
     module_srcdir=liboffloadmic; \
-    srcdiroption="--srcdir=$${topdir}/liboffloadmic"; \
-    libsrcdir="$$s/liboffloadmic"; \
     rm -f no-such-file || : ; \
     CONFIG_SITE=no-such-file $(SHELL) \
       $$s/$$module_srcdir/configure \
       --srcdir=$${topdir}/$$module_srcdir \
       $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
-      --target=$${this_target} $${srcdiroption} @extra_liboffloadmic_configure_flags@ \
+      --target=${target_alias} @extra_liboffloadmic_configure_flags@ \
       || exit 1
 @endif target-liboffloadmic
 

svn blame Makefile.in points to:

r217498 | kyukhin | 2014-11-13 15:03:17 +0100 (Thu, 13 Nov 2014) | 110 lines

[PATCH 2/4] OpenMP 4.0 offloading to Intel MIC: liboffloadmic.

    * Makefile.def: Add liboffloadmic to target_modules.  Make
    liboffloadmic depend on libgomp's configure, libstdc++ and libgcc.
    * Makefile.in: Regenerate.
    * configure: Regenerate.
    * configure.ac: Add liboffloadmic to target binaries.
    Restrict liboffloadmic for POSIX and i*86, and x86_64 architectures.
    Add liboffloadmic to noconfig list when C++ is not supported.


so, did you really regenerate Makefile.in in that patch, or am I missing something ?


Regards,
Bernd.
 		 	   		  

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-21 18:44 [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Bernd Edlinger
@ 2014-11-21 18:59 ` Ilya Verbin
  2014-11-21 19:01   ` Bernd Edlinger
  0 siblings, 1 reply; 27+ messages in thread
From: Ilya Verbin @ 2014-11-21 18:59 UTC (permalink / raw)
  To: Bernd Edlinger
  Cc: Kirill Yukhin, Andrey Turetskiy, Jakub Jelinek, gcc-patches

Hi,

On 21 Nov 19:19, Bernd Edlinger wrote:
> so, did you really regenerate Makefile.in in that patch, or am I missing something ?

You're right.  This patch was rebased so many times, that we may forget to
regenerate it before committing.

Do you plan to submit any patch for Makefile.in?
Or should I post this change separately for review? (with regtesting)

  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-21 18:59 ` Ilya Verbin
@ 2014-11-21 19:01   ` Bernd Edlinger
  2014-11-21 19:34     ` Ilya Verbin
  0 siblings, 1 reply; 27+ messages in thread
From: Bernd Edlinger @ 2014-11-21 19:01 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: Kirill Yukhin, Andrey Turetskiy, Jakub Jelinek, gcc-patches

Hi Ilya,

On Fri, 21 Nov 2014 21:44:40, Ilya Verbin wrote:
>
> Hi,
>
> On 21 Nov 19:19, Bernd Edlinger wrote:
>> so, did you really regenerate Makefile.in in that patch, or am I missing something ?
>
> You're right. This patch was rebased so many times, that we may forget to
> regenerate it before committing.
>
> Do you plan to submit any patch for Makefile.in?
> Or should I post this change separately for review? (with regtesting)
>
> -- Ilya


No, at least not immediately, so I would prefer if you go ahead with your patch ASAP.


Thanks,
Bernd.
 		 	   		  

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-21 19:01   ` Bernd Edlinger
@ 2014-11-21 19:34     ` Ilya Verbin
  2014-11-21 20:07       ` Jakub Jelinek
  0 siblings, 1 reply; 27+ messages in thread
From: Ilya Verbin @ 2014-11-21 19:34 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Kirill Yukhin, Andrey Turetskiy, gcc-patches, Bernd Edlinger

Hi Jakub!

> On Fri, 21 Nov 2014 21:44:40, Ilya Verbin wrote:
> > You're right. This patch was rebased so many times, that we may forget to
> > regenerate it before committing.

Build with liboffloadmic passed.  OK for trunk?

  -- Ilya


	* Makefile.in: Regenerate.


diff --git a/Makefile.in b/Makefile.in
index f1ff972..0bae570 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -35238,9 +35238,6 @@ configure-target-liboffloadmic:
 	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/liboffloadmic ; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	echo Configuring in $(TARGET_SUBDIR)/liboffloadmic; \
-	 \
-	this_target="${target_alias}"; \
-	 \
 	cd "$(TARGET_SUBDIR)/liboffloadmic" || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
@@ -35248,14 +35245,12 @@ configure-target-liboffloadmic:
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
 	module_srcdir=liboffloadmic; \
-	srcdiroption="--srcdir=$${topdir}/liboffloadmic"; \
-	libsrcdir="$$s/liboffloadmic"; \
 	rm -f no-such-file || : ; \
 	CONFIG_SITE=no-such-file $(SHELL) \
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
-	  --target=$${this_target} $${srcdiroption} @extra_liboffloadmic_configure_flags@ \
+	  --target=${target_alias} @extra_liboffloadmic_configure_flags@ \
 	  || exit 1
 @endif target-liboffloadmic
 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-21 19:34     ` Ilya Verbin
@ 2014-11-21 20:07       ` Jakub Jelinek
  0 siblings, 0 replies; 27+ messages in thread
From: Jakub Jelinek @ 2014-11-21 20:07 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: Kirill Yukhin, Andrey Turetskiy, gcc-patches, Bernd Edlinger

On Fri, Nov 21, 2014 at 10:14:21PM +0300, Ilya Verbin wrote:
> > On Fri, 21 Nov 2014 21:44:40, Ilya Verbin wrote:
> > > You're right. This patch was rebased so many times, that we may forget to
> > > regenerate it before committing.
> 
> Build with liboffloadmic passed.  OK for trunk?
> 
>   -- Ilya
> 
> 
> 	* Makefile.in: Regenerate.

Ok.
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -35238,9 +35238,6 @@ configure-target-liboffloadmic:
>  	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/liboffloadmic ; \
>  	$(NORMAL_TARGET_EXPORTS)  \
>  	echo Configuring in $(TARGET_SUBDIR)/liboffloadmic; \
> -	 \
> -	this_target="${target_alias}"; \
> -	 \
>  	cd "$(TARGET_SUBDIR)/liboffloadmic" || exit 1; \
>  	case $(srcdir) in \
>  	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
> @@ -35248,14 +35245,12 @@ configure-target-liboffloadmic:
>  		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
>  	esac; \
>  	module_srcdir=liboffloadmic; \
> -	srcdiroption="--srcdir=$${topdir}/liboffloadmic"; \
> -	libsrcdir="$$s/liboffloadmic"; \
>  	rm -f no-such-file || : ; \
>  	CONFIG_SITE=no-such-file $(SHELL) \
>  	  $$s/$$module_srcdir/configure \
>  	  --srcdir=$${topdir}/$$module_srcdir \
>  	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
> -	  --target=$${this_target} $${srcdiroption} @extra_liboffloadmic_configure_flags@ \
> +	  --target=${target_alias} @extra_liboffloadmic_configure_flags@ \
>  	  || exit 1
>  @endif target-liboffloadmic
>  

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-10-30 12:45 ` [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Ilya Verbin
  2014-11-06 17:55   ` Jakub Jelinek
  2014-12-18 15:56   ` Thomas Schwinge
@ 2016-03-13 19:10   ` Thomas Schwinge
  2 siblings, 0 replies; 27+ messages in thread
From: Thomas Schwinge @ 2016-03-13 19:10 UTC (permalink / raw)
  To: Ilya Verbin, Jakub Jelinek, gcc-patches; +Cc: Kirill Yukhin

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

Hi!

On Thu, 30 Oct 2014 14:40:01 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> This patch allows to run non-fallback 'make check-target-libgomp'.  It passes to
> the host compiler additional -B options with the paths to the offload compilers,
> since non-installed host compiler doesn't know where to find mkoffload tools.
> Also in case of intelmic offload targets it appends paths to liboffloadmic lib.

> --- a/libgomp/testsuite/lib/libgomp.exp
> +++ b/libgomp/testsuite/lib/libgomp.exp

> @@ -107,6 +110,20 @@ proc libgomp_init { args } {
>      # Compute what needs to be put into LD_LIBRARY_PATH
>      set always_ld_library_path ".:${blddir}/.libs"
>  
> +    # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
> +    # non-fallback testing for Intel MIC targets
> +    if { [string match "*-intelmic-*" $offload_targets]
> +	|| [string match "*-intelmicemul-*" $offload_targets] } {
> +	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
> +	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
> +	# libstdc++ is required by liboffloadmic
> +	append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
> +    }
> +
> +    if { $offload_additional_lib_paths != ""} {
> +	append always_ld_library_path "${offload_additional_lib_paths}"
> +    }

Hmm, looking at this again.  Suddenly/unexpectedly (after a long-overdue
system reboot, software upgrades, etc.), the
libgomp.oacc-c/../libgomp.oacc-c-c++-common/context-1.c execution test
(on gomp-4_0-branch) regressed from PASS to FAIL, with the very first
cublasCreate call not returning the exptected CUBLAS_STATUS_SUCCESS.
While I could never figure out what exactly is going wrong in/with
libcublas, I did figure out that the problem comes to existence in GCC
configurations with Intel MIC offloading enabled, where the above stanza
is active.  Remember that offload_additional_lib_paths specifies paths to
the Intel MIC offloading libraries' builds
(x86_64-intelmicemul-linux-gnu), and these are prepended by paths to
satisfy liboffloadmic's dependencies: libstdc++ (x86_64-pc-linux-gnu).
But: libstdc++ depends on libgcc_s, whose path is not specified here, but
a path to libgcc_s is specified with offload_additional_lib_paths, but
that's the variant for Intel MIC offloading
(x86_64-intelmicemul-linux-gnu), not the regular target library
(x86_64-pc-linux-gnu).  And, for some reason this caused breakage in/with
libcublas.

All in all, this whole setup still seems fragile to me (I
wondered/worried about this before): as the x86_64-pc-linux-gnu (target)
and x86_64-intelmicemul-linux-gnu (Intel MIC offloading) libraries are
ABI compatible, ld.so is free to intermix these...  For certain libraries
it may not matter, but certainly the libgomp builds for
x86_64-pc-linux-gnu vs. x86_64-intelmicemul-linux-gnu will have different
semantics for certain functions, for example.

In r234170, I applied the following fix as obvious, but this may still
need further attention; compare the stanza cited above to the potentially
more compilated dependencies of libstdc++.  See
libgomp/testsuite/libgomp.c++/c++.exp, and
libstdc++-v3/testsuite/lib/libstdc++.exp:libstdc++_init mentions that in
certain configurations, also libvtv may be a dependency of libstdc++, for
example.

Also, is the stanza cited above doing the right thing for GCC multilib
configurations?

commit 16603d6b5b9073537c00b706b854f0a87101b991
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sun Mar 13 19:08:21 2016 +0000

    libgcc_s is required by libstdc++
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_init): Potentially append to
    	always_ld_library_path the path to libgcc_s.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234170 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog                 | 5 +++++
 libgomp/testsuite/lib/libgomp.exp | 2 ++
 2 files changed, 7 insertions(+)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index 7293e69..5a91504 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2016-03-13  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* testsuite/lib/libgomp.exp (libgomp_init): Potentially append to
+	always_ld_library_path the path to libgcc_s.
+
 2016-03-10  Cesar Philippidis  <cesar@codesourcery.com>
 
 	PR testsuite/70009
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 0d5b6d4..1cb4991 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -142,6 +142,8 @@ proc libgomp_init { args } {
 	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
 	# libstdc++ is required by liboffloadmic
 	append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
+	# libgcc_s is required by libstdc++
+	append always_ld_library_path ":${blddir}/../libgcc"
     }
 
     global offload_additional_lib_paths


Grüße
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2015-01-28 17:51                   ` Ilya Verbin
@ 2015-02-02 14:03                     ` Ilya Verbin
  0 siblings, 0 replies; 27+ messages in thread
From: Ilya Verbin @ 2015-02-02 14:03 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Thomas Schwinge, Kirill Yukhin, gcc-patches

On 28 Jan 19:20, Ilya Verbin wrote:
> On 28 Jan 17:15, Jakub Jelinek wrote:
> > On Wed, Jan 28, 2015 at 07:02:59PM +0300, Ilya Verbin wrote:
> > > +	= XNEWVEC (char, len + sizeof ("-B" "../" DEFAULT_TARGET_MACHINE
> > > +				       "/libgomp/"));
> > > +      sprintf (optional_target_path2, "-B%s/../../../" DEFAULT_TARGET_MACHINE
> > > +				      "/libgomp/", current_path);
> > 
> > This will surely overflow the buffer, won't it?  There is space just for
> > "../" but you put there "/../../../".
> > 
> > I'd strongly prefer if you rewrote all these XNEWVEC or XRESIZEVEC etc.
> > + sprintf cases into concat, like
> >   optional_target_path2 = concat ("-B", current_path,
> > 				  "/../../../" DEFAULT_TARGET_MACHINE
> > 				  "/libgomp/", NULL);
> > and similar.  That way you avoid all such bugs.
> 
> The variable 'len' contains sizeof ("/../../").
> I agree that this code looks ugly :)  I'll rewrite it using concat.

Here is the patch with concat.


diff --git a/gcc/config.gcc b/gcc/config.gcc
index abd915e..0ebdbd2 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4374,7 +4374,7 @@ fi
 case ${target} in
 i[34567]86-*-* | x86_64-*-*)
 	if test x$enable_as_accelerator = xyes; then
-		extra_programs="mkoffload\$(exeext)"
+		extra_programs="mkoffload\$(exeext) accel/${target_noncanonical}/mkoffload$(exeext)"
 	fi
 	;;
 esac
diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c
index edc3f92e..bc71004 100644
--- a/gcc/config/i386/intelmic-mkoffload.c
+++ b/gcc/config/i386/intelmic-mkoffload.c
@@ -22,13 +22,13 @@
 
 #include "config.h"
 #include <libgen.h>
-#include "libgomp-plugin.h"
 #include "system.h"
 #include "coretypes.h"
 #include "obstack.h"
 #include "intl.h"
 #include "diagnostic.h"
 #include "collect-utils.h"
+#include "intelmic-offload.h"
 
 const char tool_name[] = "intelmic mkoffload";
 
@@ -45,6 +45,13 @@ const char *temp_files[MAX_NUM_TEMPS];
 /* Shows if we should compile binaries for i386 instead of x86-64.  */
 bool target_ilp32 = false;
 
+/* Optional prefixes for the target compiler, which are required when target
+   compiler is not installed.  */
+char *optional_target_path1 = NULL;
+char *optional_target_path2 = NULL;
+char *optional_target_lib_path = NULL;
+
+
 /* Delete tempfiles and exit function.  */
 void
 tool_cleanup (bool from_signal ATTRIBUTE_UNUSED)
@@ -151,14 +158,17 @@ access_check (const char *name, int mode)
   return access (name, mode);
 }
 
-/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH.  */
+/* Find target compiler using a path from COLLECT_GCC, COMPILER_PATH, or a path
+   relative to ARGV0.  */
 static char *
-find_target_compiler (const char *name)
+find_target_compiler (const char *argv0)
 {
   bool found = false;
   char **paths = NULL;
   unsigned n_paths, i;
+  const char *current_path;
   const char *collect_path = dirname (ASTRDUP (getenv ("COLLECT_GCC")));
+  const char *name = GCC_INSTALL_NAME;
   size_t len = strlen (collect_path) + 1 + strlen (name) + 1;
   char *target_compiler = XNEWVEC (char, len);
   sprintf (target_compiler, "%s/%s", collect_path, name);
@@ -177,13 +187,32 @@ find_target_compiler (const char *name)
       if (access_check (target_compiler, X_OK) == 0)
 	{
 	  found = true;
-	  break;
+	  goto out;
 	}
     }
+  XDELETEVEC (target_compiler);
+
+  /* If installed compiler wasn't found, try to find a non-installed compiler,
+     using a path relative to mkoffload.  */
+  current_path = dirname (ASTRDUP (argv0));
+  target_compiler = concat (current_path, "/../../xgcc", NULL);
+  if (access_check (target_compiler, X_OK) == 0)
+    {
+      optional_target_path1 = concat ("-B", current_path, "/../../", NULL);
+      optional_target_path2
+	= concat ("-B", current_path,
+		  "/../../../" DEFAULT_TARGET_MACHINE "/libgomp/", NULL);
+      optional_target_lib_path
+	= concat ("-L", current_path,
+		  "/../../../" DEFAULT_TARGET_MACHINE "/libgomp/.libs/", NULL);
+      found = true;
+    }
 
 out:
   free_array_of_ptrs ((void **) paths, n_paths);
-  return found ? target_compiler : NULL;
+  if (!found)
+    fatal_error ("offload compiler %s not found", name);
+  return target_compiler;
 }
 
 static void
@@ -193,6 +222,14 @@ compile_for_target (struct obstack *argv_obstack)
     obstack_ptr_grow (argv_obstack, "-m32");
   else
     obstack_ptr_grow (argv_obstack, "-m64");
+
+  if (optional_target_path1)
+    obstack_ptr_grow (argv_obstack, optional_target_path1);
+  if (optional_target_path2)
+    obstack_ptr_grow (argv_obstack, optional_target_path2);
+  if (optional_target_lib_path)
+    obstack_ptr_grow (argv_obstack, optional_target_lib_path);
+
   obstack_ptr_grow (argv_obstack, NULL);
   char **argv = XOBFINISH (argv_obstack, char **);
 
@@ -346,7 +383,7 @@ generate_host_descr_file (const char *host_compiler)
 	   "init (void)\n"
 	   "{\n"
 	   "  GOMP_offload_register (&__OFFLOAD_TABLE__, %d, __offload_target_data);\n"
-	   "}\n", OFFLOAD_TARGET_TYPE_INTEL_MIC);
+	   "}\n", GOMP_DEVICE_INTEL_MIC);
   fclose (src_file);
 
   unsigned new_argc = 0;
@@ -483,11 +520,7 @@ main (int argc, char **argv)
   if (!host_compiler)
     fatal_error ("COLLECT_GCC must be set");
 
-  const char *target_driver_name
-    = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
-  char *target_compiler = find_target_compiler (target_driver_name);
-  if (target_compiler == NULL)
-    fatal_error ("offload compiler %s not found", target_driver_name);
+  char *target_compiler = find_target_compiler (argv[0]);
 
   /* We may be called with all the arguments stored in some file and
      passed with @file.  Expand them into argv before processing.  */
diff --git a/gcc/config/i386/t-intelmic b/gcc/config/i386/t-intelmic
index 8b36e0d..86e10eb 100644
--- a/gcc/config/i386/t-intelmic
+++ b/gcc/config/i386/t-intelmic
@@ -1,9 +1,16 @@
+CFLAGS-mkoffload.o += $(DRIVER_DEFINES) \
+	-DGCC_INSTALL_NAME=\"$(GCC_INSTALL_NAME)\"
+
 mkoffload.o: $(srcdir)/config/i386/intelmic-mkoffload.c | insn-modes.h
-	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-	  -I$(srcdir)/../libgomp \
-	  -DDEFAULT_REAL_TARGET_MACHINE=\"$(real_target_noncanonical)\" \
-	  -DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\" \
-	  $< $(OUTPUT_OPTION)
+	$(COMPILE) $<
+	$(POSTCOMPILE)
 
 mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS)
-	$(COMPILER) -o $@ mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
+	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+	  mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
+
+accel/$(target_noncanonical)/mkoffload$(exeext): mkoffload$(exeext)
+	test -d accel || mkdir accel
+	test -d accel/$(target_noncanonical) || mkdir accel/$(target_noncanonical)
+	rm -f $@
+	$(LN) mkoffload$(exeext) $@
diff --git a/libgomp/configure b/libgomp/configure
index 0818707..8d96950 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15226,6 +15226,9 @@ if test x"$enable_offload_targets" != x; then
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
 	tgt_name=intelmic
+	if test x"$tgt_dir" != x; then
+	  offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+	fi
 	;;
       nvptx*)
         tgt_name=nvptx
@@ -15276,7 +15279,7 @@ rm -f core conftest.err conftest.$ac_objext \
       offload_targets=$offload_targets,$tgt_name
     fi
     if test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index 254c688..2861e68 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -94,6 +94,9 @@ if test x"$enable_offload_targets" != x; then
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
 	tgt_name=intelmic
+	if test x"$tgt_dir" != x; then
+	  offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+	fi
 	;;
       nvptx*)
         tgt_name=nvptx
@@ -133,7 +136,7 @@ if test x"$enable_offload_targets" != x; then
       offload_targets=$offload_targets,$tgt_name
     fi
     if test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"


  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2015-01-28 17:42                 ` Jakub Jelinek
@ 2015-01-28 17:51                   ` Ilya Verbin
  2015-02-02 14:03                     ` Ilya Verbin
  0 siblings, 1 reply; 27+ messages in thread
From: Ilya Verbin @ 2015-01-28 17:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Thomas Schwinge, Kirill Yukhin, gcc-patches

On 28 Jan 17:15, Jakub Jelinek wrote:
> On Wed, Jan 28, 2015 at 07:02:59PM +0300, Ilya Verbin wrote:
> > +	= XNEWVEC (char, len + sizeof ("-B" "../" DEFAULT_TARGET_MACHINE
> > +				       "/libgomp/"));
> > +      sprintf (optional_target_path2, "-B%s/../../../" DEFAULT_TARGET_MACHINE
> > +				      "/libgomp/", current_path);
> 
> This will surely overflow the buffer, won't it?  There is space just for
> "../" but you put there "/../../../".
> 
> I'd strongly prefer if you rewrote all these XNEWVEC or XRESIZEVEC etc.
> + sprintf cases into concat, like
>   optional_target_path2 = concat ("-B", current_path,
> 				  "/../../../" DEFAULT_TARGET_MACHINE
> 				  "/libgomp/", NULL);
> and similar.  That way you avoid all such bugs.

The variable 'len' contains sizeof ("/../../").
I agree that this code looks ugly :)  I'll rewrite it using concat.

  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2015-01-28 17:28               ` Ilya Verbin
@ 2015-01-28 17:42                 ` Jakub Jelinek
  2015-01-28 17:51                   ` Ilya Verbin
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Jelinek @ 2015-01-28 17:42 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: Thomas Schwinge, Kirill Yukhin, gcc-patches

On Wed, Jan 28, 2015 at 07:02:59PM +0300, Ilya Verbin wrote:
> +	= XNEWVEC (char, len + sizeof ("-B" "../" DEFAULT_TARGET_MACHINE
> +				       "/libgomp/"));
> +      sprintf (optional_target_path2, "-B%s/../../../" DEFAULT_TARGET_MACHINE
> +				      "/libgomp/", current_path);

This will surely overflow the buffer, won't it?  There is space just for
"../" but you put there "/../../../".

I'd strongly prefer if you rewrote all these XNEWVEC or XRESIZEVEC etc.
+ sprintf cases into concat, like
  optional_target_path2 = concat ("-B", current_path,
				  "/../../../" DEFAULT_TARGET_MACHINE
				  "/libgomp/", NULL);
and similar.  That way you avoid all such bugs.

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2015-01-15 19:25             ` Jakub Jelinek
@ 2015-01-28 17:28               ` Ilya Verbin
  2015-01-28 17:42                 ` Jakub Jelinek
  0 siblings, 1 reply; 27+ messages in thread
From: Ilya Verbin @ 2015-01-28 17:28 UTC (permalink / raw)
  To: Jakub Jelinek, Thomas Schwinge; +Cc: Kirill Yukhin, gcc-patches

On 15 Jan 19:58, Jakub Jelinek wrote:
> On Thu, Jan 15, 2015 at 09:55:40PM +0300, Ilya Verbin wrote:
> > This patch enables 'make check-target-libgomp' with noninstalled offloading
> > compilers.  It creates gcc/accel/<target>/ directory in the build tree of the
> > offloading compiler, this allows lto-wrapper to find corresponding mkoffload in
> > case if there is more than one offloading compiler.  Is this approach ok?
> > I don't like changes in config.gcc and t-intelmic, probably there is a better
> > way to create a link?
> 
> Let's wait until Thomas hopefully checks in the OpenACC merge in order not
> to make him work even harder.
> I'll look at your patch afterwards.

I've rebased this patch.


diff --git a/gcc/config.gcc b/gcc/config.gcc
index bf67beb..c56c055 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4371,7 +4371,7 @@ fi
 case ${target} in
 i[34567]86-*-* | x86_64-*-*)
 	if test x$enable_as_accelerator = xyes; then
-		extra_programs="mkoffload\$(exeext)"
+		extra_programs="mkoffload\$(exeext) accel/${target_noncanonical}/mkoffload$(exeext)"
 	fi
 	;;
 esac
diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c
index 5d9ed33..73ca9ce 100644
--- a/gcc/config/i386/intelmic-mkoffload.c
+++ b/gcc/config/i386/intelmic-mkoffload.c
@@ -45,6 +45,13 @@ const char *temp_files[MAX_NUM_TEMPS];
 /* Shows if we should compile binaries for i386 instead of x86-64.  */
 bool target_ilp32 = false;
 
+/* Optional prefixes for the target compiler, which are required when target
+   compiler is not installed.  */
+char *optional_target_path1 = NULL;
+char *optional_target_path2 = NULL;
+char *optional_target_lib_path = NULL;
+
+
 /* Delete tempfiles and exit function.  */
 void
 tool_cleanup (bool from_signal ATTRIBUTE_UNUSED)
@@ -151,14 +158,18 @@ access_check (const char *name, int mode)
   return access (name, mode);
 }
 
-/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH.  */
+/* Find target compiler using a path from COLLECT_GCC, COMPILER_PATH, or a path
+   relative to ARGV0.  */
 static char *
-find_target_compiler (const char *name)
+find_target_compiler (const char *argv0)
 {
   bool found = false;
   char **paths = NULL;
   unsigned n_paths, i;
+  const char *current_path;
   const char *collect_path = dirname (ASTRDUP (getenv ("COLLECT_GCC")));
+  const char *name
+    = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
   size_t len = strlen (collect_path) + 1 + strlen (name) + 1;
   char *target_compiler = XNEWVEC (char, len);
   sprintf (target_compiler, "%s/%s", collect_path, name);
@@ -177,13 +188,38 @@ find_target_compiler (const char *name)
       if (access_check (target_compiler, X_OK) == 0)
 	{
 	  found = true;
-	  break;
+	  goto out;
 	}
     }
 
+  /* If installed compiler wasn't found, try to find a non-installed compiler,
+     using a path relative to mkoffload.  */
+  current_path = dirname (ASTRDUP (argv0));
+  len = strlen (current_path) + sizeof ("/../../") - 1;
+  target_compiler = XRESIZEVEC (char, target_compiler, len + sizeof ("xgcc"));
+  sprintf (target_compiler, "%s/../../xgcc", current_path);
+  if (access_check (target_compiler, X_OK) == 0)
+    {
+      optional_target_path1 = XNEWVEC (char, len + sizeof ("-B"));
+      sprintf (optional_target_path1, "-B%s/../../", current_path);
+      optional_target_path2
+	= XNEWVEC (char, len + sizeof ("-B" "../" DEFAULT_TARGET_MACHINE
+				       "/libgomp/"));
+      sprintf (optional_target_path2, "-B%s/../../../" DEFAULT_TARGET_MACHINE
+				      "/libgomp/", current_path);
+      optional_target_lib_path
+	= XNEWVEC (char, len + sizeof ("-L" "../" DEFAULT_TARGET_MACHINE
+				       "/libgomp/.libs/"));
+      sprintf (optional_target_lib_path, "-L%s/../../../" DEFAULT_TARGET_MACHINE
+					 "/libgomp/.libs/", current_path);
+      found = true;
+    }
+
 out:
   free_array_of_ptrs ((void **) paths, n_paths);
-  return found ? target_compiler : NULL;
+  if (!found)
+    fatal_error ("offload compiler %s not found", name);
+  return target_compiler;
 }
 
 static void
@@ -193,6 +229,14 @@ compile_for_target (struct obstack *argv_obstack)
     obstack_ptr_grow (argv_obstack, "-m32");
   else
     obstack_ptr_grow (argv_obstack, "-m64");
+
+  if (optional_target_path1)
+    obstack_ptr_grow (argv_obstack, optional_target_path1);
+  if (optional_target_path2)
+    obstack_ptr_grow (argv_obstack, optional_target_path2);
+  if (optional_target_lib_path)
+    obstack_ptr_grow (argv_obstack, optional_target_lib_path);
+
   obstack_ptr_grow (argv_obstack, NULL);
   char **argv = XOBFINISH (argv_obstack, char **);
 
@@ -492,11 +536,7 @@ main (int argc, char **argv)
   if (!host_compiler)
     fatal_error ("COLLECT_GCC must be set");
 
-  const char *target_driver_name
-    = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
-  char *target_compiler = find_target_compiler (target_driver_name);
-  if (target_compiler == NULL)
-    fatal_error ("offload compiler %s not found", target_driver_name);
+  char *target_compiler = find_target_compiler (argv[0]);
 
   /* We may be called with all the arguments stored in some file and
      passed with @file.  Expand them into argv before processing.  */
diff --git a/gcc/config/i386/t-intelmic b/gcc/config/i386/t-intelmic
index 8b36e0d..efc50fca 100644
--- a/gcc/config/i386/t-intelmic
+++ b/gcc/config/i386/t-intelmic
@@ -7,3 +7,9 @@ mkoffload.o: $(srcdir)/config/i386/intelmic-mkoffload.c | insn-modes.h
 
 mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS)
 	$(COMPILER) -o $@ mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
+
+accel/$(target_noncanonical)/mkoffload$(exeext): mkoffload$(exeext)
+	test -d accel || mkdir accel
+	test -d accel/$(target_noncanonical) || mkdir accel/$(target_noncanonical)
+	rm -f $@
+	$(LN) mkoffload$(exeext) $@
diff --git a/libgomp/configure b/libgomp/configure
index 0818707..8d96950 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15226,6 +15226,9 @@ if test x"$enable_offload_targets" != x; then
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
 	tgt_name=intelmic
+	if test x"$tgt_dir" != x; then
+	  offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+	fi
 	;;
       nvptx*)
         tgt_name=nvptx
@@ -15276,7 +15279,7 @@ rm -f core conftest.err conftest.$ac_objext \
       offload_targets=$offload_targets,$tgt_name
     fi
     if test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac
index 254c688..2861e68 100644
--- a/libgomp/plugin/configfrag.ac
+++ b/libgomp/plugin/configfrag.ac
@@ -94,6 +94,9 @@ if test x"$enable_offload_targets" != x; then
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
 	tgt_name=intelmic
+	if test x"$tgt_dir" != x; then
+	  offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+	fi
 	;;
       nvptx*)
         tgt_name=nvptx
@@ -133,7 +136,7 @@ if test x"$enable_offload_targets" != x; then
       offload_targets=$offload_targets,$tgt_name
     fi
     if test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"


  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2015-01-15 19:21           ` Ilya Verbin
@ 2015-01-15 19:25             ` Jakub Jelinek
  2015-01-28 17:28               ` Ilya Verbin
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Jelinek @ 2015-01-15 19:25 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: Thomas Schwinge, Kirill Yukhin, gcc-patches

On Thu, Jan 15, 2015 at 09:55:40PM +0300, Ilya Verbin wrote:
> This patch enables 'make check-target-libgomp' with noninstalled offloading
> compilers.  It creates gcc/accel/<target>/ directory in the build tree of the
> offloading compiler, this allows lto-wrapper to find corresponding mkoffload in
> case if there is more than one offloading compiler.  Is this approach ok?
> I don't like changes in config.gcc and t-intelmic, probably there is a better
> way to create a link?

Let's wait until Thomas hopefully checks in the OpenACC merge in order not
to make him work even harder.
I'll look at your patch afterwards.

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-22 12:50         ` Jakub Jelinek
@ 2015-01-15 19:21           ` Ilya Verbin
  2015-01-15 19:25             ` Jakub Jelinek
  0 siblings, 1 reply; 27+ messages in thread
From: Ilya Verbin @ 2015-01-15 19:21 UTC (permalink / raw)
  To: Jakub Jelinek, Thomas Schwinge; +Cc: Kirill Yukhin, gcc-patches

On 22 Dec 13:35, Jakub Jelinek wrote:
> On Mon, Dec 22, 2014 at 12:48:08PM +0100, Thomas Schwinge wrote:
> > In my understanding, we'd like to support the modes that either all
> > compilers are installed (which is what a user will be using), or all are
> > tested from their build trees.  Or, do we also have to support the mode
> > that only the offloading compilers are installed, but the target
> > (offloading host) compiler is not?  (Doesn't make much sense to me.)
> 
> All 3 of these, yes.
> The nothing is installed yet mode supposedly doesn't work properly on the
> trunk yet (and is what I'd like to use e.g. in distro rpm builds), the offloading
> compilers installed, host is not is useful that you actually test the host compiler
> before installing, and that supposedly works on the trunk, the all installed testing
> I've never used myself, but some people are using it.

This patch enables 'make check-target-libgomp' with noninstalled offloading
compilers.  It creates gcc/accel/<target>/ directory in the build tree of the
offloading compiler, this allows lto-wrapper to find corresponding mkoffload in
case if there is more than one offloading compiler.  Is this approach ok?
I don't like changes in config.gcc and t-intelmic, probably there is a better
way to create a link?


diff --git a/gcc/config.gcc b/gcc/config.gcc
index 0dfc08f..76eef6f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4369,7 +4369,7 @@ fi
 case ${target} in
 i[34567]86-*-* | x86_64-*-*)
 	if test x$enable_as_accelerator = xyes; then
-		extra_programs="mkoffload\$(exeext)"
+		extra_programs="mkoffload\$(exeext) accel/${target_noncanonical}/mkoffload$(exeext)"
 	fi
 	;;
 esac
diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c
index 8e490ff..41807cf 100644
--- a/gcc/config/i386/intelmic-mkoffload.c
+++ b/gcc/config/i386/intelmic-mkoffload.c
@@ -45,6 +45,11 @@ const char *temp_files[MAX_NUM_TEMPS];
 /* Shows if we should compile binaries for i386 instead of x86-64.  */
 bool target_ilp32 = false;
 
+/* An optional prefix for the target compiler, which is required when target
+   compiler is not installed.  */
+char *optional_target_path = NULL;
+
+
 /* Delete tempfiles and exit function.  */
 void
 tool_cleanup (bool from_signal ATTRIBUTE_UNUSED)
@@ -151,14 +156,18 @@ access_check (const char *name, int mode)
   return access (name, mode);
 }
 
-/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH.  */
+/* Find target compiler using a path from COLLECT_GCC, COMPILER_PATH, or a path
+   relative to ARGV0.  */
 static char *
-find_target_compiler (const char *name)
+find_target_compiler (const char *argv0)
 {
   bool found = false;
   char **paths = NULL;
   unsigned n_paths, i;
+  const char *current_path;
   const char *collect_path = dirname (ASTRDUP (getenv ("COLLECT_GCC")));
+  const char *name
+    = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
   size_t len = strlen (collect_path) + 1 + strlen (name) + 1;
   char *target_compiler = XNEWVEC (char, len);
   sprintf (target_compiler, "%s/%s", collect_path, name);
@@ -177,13 +186,28 @@ find_target_compiler (const char *name)
       if (access_check (target_compiler, X_OK) == 0)
 	{
 	  found = true;
-	  break;
+	  goto out;
 	}
     }
 
+  /* If installed compiler wasn't found, try to find a non-installed compiler,
+     using a path relative to mkoffload.  */
+  current_path = dirname (ASTRDUP (argv0));
+  len = strlen (current_path) + sizeof ("/../../") - 1;
+  target_compiler = XRESIZEVEC (char, target_compiler, len + sizeof ("xgcc"));
+  sprintf (target_compiler, "%s/../../xgcc", current_path);
+  if (access_check (target_compiler, X_OK) == 0)
+    {
+      optional_target_path = XNEWVEC (char, len + sizeof ("-B"));
+      sprintf (optional_target_path, "-B%s/../../", current_path);
+      found = true;
+    }
+
 out:
   free_array_of_ptrs ((void **) paths, n_paths);
-  return found ? target_compiler : NULL;
+  if (!found)
+    fatal_error ("offload compiler %s not found", name);
+  return target_compiler;
 }
 
 static void
@@ -193,6 +217,10 @@ compile_for_target (struct obstack *argv_obstack)
     obstack_ptr_grow (argv_obstack, "-m32");
   else
     obstack_ptr_grow (argv_obstack, "-m64");
+
+  if (optional_target_path)
+    obstack_ptr_grow (argv_obstack, optional_target_path);
+
   obstack_ptr_grow (argv_obstack, NULL);
   char **argv = XOBFINISH (argv_obstack, char **);
 
@@ -492,11 +520,7 @@ main (int argc, char **argv)
   if (!host_compiler)
     fatal_error ("COLLECT_GCC must be set");
 
-  const char *target_driver_name
-    = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc";
-  char *target_compiler = find_target_compiler (target_driver_name);
-  if (target_compiler == NULL)
-    fatal_error ("offload compiler %s not found", target_driver_name);
+  char *target_compiler = find_target_compiler (argv[0]);
 
   /* We may be called with all the arguments stored in some file and
      passed with @file.  Expand them into argv before processing.  */
diff --git a/gcc/config/i386/t-intelmic b/gcc/config/i386/t-intelmic
index 8b36e0d..efc50fca 100644
--- a/gcc/config/i386/t-intelmic
+++ b/gcc/config/i386/t-intelmic
@@ -7,3 +7,9 @@ mkoffload.o: $(srcdir)/config/i386/intelmic-mkoffload.c | insn-modes.h
 
 mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS)
 	$(COMPILER) -o $@ mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS)
+
+accel/$(target_noncanonical)/mkoffload$(exeext): mkoffload$(exeext)
+	test -d accel || mkdir accel
+	test -d accel/$(target_noncanonical) || mkdir accel/$(target_noncanonical)
+	rm -f $@
+	$(LN) mkoffload$(exeext) $@
diff --git a/libgomp/configure b/libgomp/configure
index 3214e9d..134064a 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -16251,7 +16251,11 @@ if test x"$enable_offload_targets" != x; then
     tgt=`echo $tgt | sed 's/=.*//'`
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
-	tgt_name="intelmic" ;;
+	tgt_name="intelmic"
+	if test x"$tgt_dir" != x; then
+	  offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+	fi
+	;;
       *)
 	as_fn_error "unknown offload target specified" "$LINENO" 5 ;;
     esac
@@ -16261,7 +16265,7 @@ if test x"$enable_offload_targets" != x; then
       offload_targets=$offload_targets,$tgt_name
     fi
     if test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 8ed1bae..d74fce0 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -293,7 +293,11 @@ if test x"$enable_offload_targets" != x; then
     tgt=`echo $tgt | sed 's/=.*//'`
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
-	tgt_name="intelmic" ;;
+	tgt_name="intelmic"
+	if test x"$tgt_dir" != x; then
+	  offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs"
+	fi
+	;;
       *)
 	AC_MSG_ERROR([unknown offload target specified]) ;;
     esac
@@ -303,7 +307,7 @@ if test x"$enable_offload_targets" != x; then
       offload_targets=$offload_targets,$tgt_name
     fi
     if test x"$tgt_dir" != x; then
-      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin"
       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"


  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-26 20:53         ` Ilya Verbin
@ 2015-01-08 16:03           ` Thomas Schwinge
  0 siblings, 0 replies; 27+ messages in thread
From: Thomas Schwinge @ 2015-01-08 16:03 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: Jakub Jelinek, Kirill Yukhin, Andrey Turetskiy, gcc

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

Hi!

On Fri, 26 Dec 2014 22:15:24 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> On 22 Dec 12:48, Thomas Schwinge wrote:
> > Here is a patch to correctly match intelmic in $offload_targets; OK to
> > commit, I assume?  I suppose I'm the first one to ever do build-tree
> > testing?  (Jakub?)

> OK, thanks.
> I verified this case some time ago, but missed when it started failing, since
> tests just become UNSUPPORTED or PASSED with host fallback, rather than FAILing.

Yeah.  (I diff the *.sum files, so I do see such regressions.)  Committed
to trunk in r219348:

commit b21c795fa27f6fcefdb38d1bc50f1d1634f4e0b3
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Jan 8 16:01:24 2015 +0000

    libgomp: Fix "intelmic" offloading in build-tree testing.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_init): Correctly match
    	"intelmic" in $offload_targets.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219348 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog                 | 5 +++++
 libgomp/testsuite/lib/libgomp.exp | 3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index afbde87..beecba9 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-08  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* testsuite/lib/libgomp.exp (libgomp_init): Correctly match
+	"intelmic" in $offload_targets.
+
 2015-01-05  Jakub Jelinek  <jakub@redhat.com>
 
 	Update copyright years.
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index ff22f10..2d6f822 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -115,8 +115,7 @@ proc libgomp_init { args } {
 
     # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
     # non-fallback testing for Intel MIC targets
-    if { [string match "*-intelmic-*" $offload_targets]
-	|| [string match "*-intelmicemul-*" $offload_targets] } {
+    if { [string match "*,intelmic,*" ",$offload_targets,"] } {
 	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
 	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
 	# libstdc++ is required by liboffloadmic


> > Here is a patch to fix 32-bit x86 Intel MIC offloading; OK to commit, I
> > assume?

> OK, thanks.

Committed to trunk in r219349:

commit 49b6c472197cbb443c55cc1064de5b24384bbf7f
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Jan 8 16:01:37 2015 +0000

    libgomp: Fix 32-bit x86 Intel MIC offloading testing.
    
        [...]
        spawn [...]/build-gcc/gcc/xgcc -B[...]/build-gcc/gcc/ [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.50.1.c -B[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/ -B[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs -I[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp -I[...]/source-gcc/libgomp/testsuite/.. -march=i486 -fmessage-length=0 -fno-diagnostics-show-caret -fdiagnostics-color=never -B[...]/install/offload-x86_64-intelmicemul-linux-gnu/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0 -B[...]/install/offload-x86_64-intelmicemul-linux-gnu/bin -fopenmp -O2 -L[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs -lm -m32 -o ./e.50.1.exe
        PASS: libgomp.c/examples-4/e.50.1.c (test for excess errors)
        Setting LD_LIBRARY_PATH to .:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/plugin/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../libstdc++-v3/src/.libs:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib64:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib:[...]/build-gcc/gcc:[...]/build-gcc/gcc/32:.:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/plugin/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../libstdc++-v3/src/.libs:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib64:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib:[...]/build-gcc/gcc:[...]/build-gcc/gcc/32:[...]/build-gcc/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libsanitizer/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libvtv/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libcilkrts/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/liboffloadmic/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libssp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libgomp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libitm/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libatomic/.libs:[...]/build-gcc/./gcc:[...]/build-gcc/./prev-gcc
        spawn [open ...]
        /tmp/offload_WCXKRZ/offload_target_main: error while loading shared libraries: liboffloadmic_target.so.5: wrong ELF class: ELFCLASS64
        WARNING: program timed out.
        FAIL: libgomp.c/examples-4/e.50.1.c execution test
        [...]
    
        $ find -name liboffloadmic_target.so.5
        ./install/offload-x86_64-intelmicemul-linux-gnu/lib64/liboffloadmic_target.so.5
        ./install/offload-x86_64-intelmicemul-linux-gnu/lib32/liboffloadmic_target.so.5
        ./build-gcc-offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/32/liboffloadmic/.libs/liboffloadmic_target.so.5
        ./build-gcc-offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/liboffloadmic/.libs/liboffloadmic_target.so.5
    
    This is a "standard" GCC configuration: x86_64-intelmicemul-linux-gnu with
    (default) multilibs enabled.
    
    	libgomp/
    	* configure.ac [tgt_dir] (offload_additional_lib_paths): Also add
    	"$tgt_dir/lib32".
    	* configure: Regenerate.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219349 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog    | 4 ++++
 libgomp/configure    | 2 +-
 libgomp/configure.ac | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index beecba9..11e0086 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,5 +1,9 @@
 2015-01-08  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* configure.ac [tgt_dir] (offload_additional_lib_paths): Also add
+	"$tgt_dir/lib32".
+	* configure: Regenerate.
+
 	* testsuite/lib/libgomp.exp (libgomp_init): Correctly match
 	"intelmic" in $offload_targets.
 
diff --git libgomp/configure libgomp/configure
index f5d6b6b..d109fc1 100755
--- libgomp/configure
+++ libgomp/configure
@@ -16262,7 +16262,7 @@ if test x"$enable_offload_targets" != x; then
     fi
     if test x"$tgt_dir" != x; then
       offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
-      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
       offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
diff --git libgomp/configure.ac libgomp/configure.ac
index 16ec158..c8a98f0 100644
--- libgomp/configure.ac
+++ libgomp/configure.ac
@@ -304,7 +304,7 @@ if test x"$enable_offload_targets" != x; then
     fi
     if test x"$tgt_dir" != x; then
       offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
-      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
       offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-22 11:49       ` Thomas Schwinge
  2014-12-22 12:50         ` Jakub Jelinek
@ 2014-12-26 20:53         ` Ilya Verbin
  2015-01-08 16:03           ` Thomas Schwinge
  1 sibling, 1 reply; 27+ messages in thread
From: Ilya Verbin @ 2014-12-26 20:53 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Jakub Jelinek, Kirill Yukhin, Andrey Turetskiy, gcc

On 22 Dec 12:48, Thomas Schwinge wrote:
> What is the reason for adding paths if $tgt_dir is empty?  (I mean, if
> properly installed and $tgt_dir empty, this should just work, because
> that's what a user will be doing, so why does the libgomp testsuite have
> to do differently?)

The case for empty $tgt_dir is required when offload compiler is installed, but
host compiler isn't.

> These paths will (basically) point to GCC's
> configured --prefix=[...] -- which may not actually match where the
> installed offloading compilers are to be found, for example, in the
> common case that DESTDIR is used with make install.  And, isn't it that
> GCC by default will already be looking into "$prefix" installation
> directories, or is this solving an actual problem for you?  If not, is it
> then OK to remove the cases for empty $tgt_dir?

If DESTDIR is used, then $tgt_dir can not be empty, otherwise during the build
of host compiler the host's part of MIC plugin for libgomp will not find
target's part, which is built along with target compiler.

> Here is a patch to correctly match intelmic in $offload_targets; OK to
> commit, I assume?  I suppose I'm the first one to ever do build-tree
> testing?  (Jakub?)
> 
> --- libgomp/testsuite/lib/libgomp.exp
> +++ libgomp/testsuite/lib/libgomp.exp
> @@ -115,8 +115,7 @@ proc libgomp_init { args } {
>  
>      # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
>      # non-fallback testing for Intel MIC targets
> -    if { [string match "*-intelmic-*" $offload_targets]
> -	|| [string match "*-intelmicemul-*" $offload_targets] } {
> +    if { [string match "*,intelmic,*" ",$offload_targets,"] } {
>  	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
>  	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
>  	# libstdc++ is required by liboffloadmic

OK, thanks.
I verified this case some time ago, but missed when it started failing, since
tests just become UNSUPPORTED or PASSED with host fallback, rather than FAILing.

> Here is a patch to fix 32-bit x86 Intel MIC offloading; OK to commit, I
> assume?
> 
>     $ find -name liboffloadmic_target.so.5
>     ./install/offload-x86_64-intelmicemul-linux-gnu/lib64/liboffloadmic_target.so.5
>     ./install/offload-x86_64-intelmicemul-linux-gnu/lib32/liboffloadmic_target.so.5
>     ./build-gcc-offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/32/liboffloadmic/.libs/liboffloadmic_target.so.5
>     ./build-gcc-offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/liboffloadmic/.libs/liboffloadmic_target.so.5
> 
> --- libgomp/configure.ac
> +++ libgomp/configure.ac
> @@ -304,7 +304,7 @@ if test x"$enable_offload_targets" != x; then
>      fi
>      if test x"$tgt_dir" != x; then
>        offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
> -      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
> +      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
>      else
>        offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
>        offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"

OK, thanks.

  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-18 10:46         ` Jakub Jelinek
@ 2014-12-22 16:37           ` Thomas Schwinge
  0 siblings, 0 replies; 27+ messages in thread
From: Thomas Schwinge @ 2014-12-22 16:37 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches; +Cc: Ilya Verbin, Kirill Yukhin, Andrey Turetskiy

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

Hi!

On Thu, 18 Dec 2014 11:21:20 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Dec 17, 2014 at 11:48:01PM +0100, Thomas Schwinge wrote:
> > I have another suggestion: on gomp-4_0-branch, we had already started
> > using a libgomp-test-support.exp file for a similar purpose.  I now
> > changed your code on gomp-4_0-branch in r218845 as follows (though, not
> > very much tested).  The advantage here is that people who are not using
> > GCC build-tree testing, but are directly invoking runtest, then don't
> > have to set various environment variables, but instead just have to copy
> > this one libgomp-test-support.exp file from the build tree to the testing
> > tree.  Does this make sense?
> > 
> > commit de01639bf47e29a20959771e587fb6f30c372a45
> > Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
> > Date:   Wed Dec 17 22:45:05 2014 +0000
> > 
> >     libgomp: Route offloading data through the libgomp-test-support.exp file.
> >     
> >     	libgomp/
> >     	* testsuite/Makefile.am: Don't export OFFLOAD_TARGETS,
> >     	OFFLOAD_ADDITIONAL_OPTIONS, and OFFLOAD_ADDITIONAL_LIB_PATHS...
> >     	* testsuite/libgomp-test-support.exp.in: ..., and instead set
> >     	offload_targets, offload_additional_options, and
> >     	offload_additional_lib_paths here.  Update all users.
> 
> LGTM.

As discussed in
<http://news.gmane.org/find-root.php?message_id=%3C87388dropf.fsf%40schwinge.name%3E>,
that doesn't really work: there may be additional (recursive) expansions
required (similar to: libexecdir being defined in terms of exec_prefix,
that in terms of prefix, and so on), so we really need to handle that in
the Makefile, where all these variables are available.  Committed to
gomp-4_0-branch in r219016:

commit 6bb8cfa151e40ab1e991112d2bbe2719f0a2c46a
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Dec 22 16:17:15 2014 +0000

    libgomp: Handle Makefile variable usage in testsuite/libgomp-test-support.exp.
    
    	libgomp/
    	* testsuite/libgomp-test-support.exp.in
    	(offload_additional_options, offload_additional_lib_paths): Don't
    	set.
    	* configure.ac: Instantiate testsuite/libgomp-test-support.pt.exp
    	instead of testsuite/libgomp-test-support.exp.
    	* testsuite/Makefile.am (libgomp-test-support.exp): New rule.
    	(all-local): Depend on it.
    	* configure: Regenerate.
    	* testsuite/Makefile.in: Likewise.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@219016 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp                        | 12 ++++++++
 libgomp/configure                             |  4 +--
 libgomp/configure.ac                          |  2 +-
 libgomp/testsuite/Makefile.am                 | 14 +++++++++
 libgomp/testsuite/Makefile.in                 | 41 ++++++++++++++++++---------
 libgomp/testsuite/libgomp-test-support.exp.in |  2 --
 6 files changed, 56 insertions(+), 19 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index b7a0e7d..6653e58 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,3 +1,15 @@
+2014-12-22  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* testsuite/libgomp-test-support.exp.in
+	(offload_additional_options, offload_additional_lib_paths): Don't
+	set.
+	* configure.ac: Instantiate testsuite/libgomp-test-support.pt.exp
+	instead of testsuite/libgomp-test-support.exp.
+	* testsuite/Makefile.am (libgomp-test-support.exp): New rule.
+	(all-local): Depend on it.
+	* configure: Regenerate.
+	* testsuite/Makefile.in: Likewise.
+
 2014-12-17  Thomas Schwinge  <thomas@codesourcery.com>
 	    Tom de Vries  <tom@codesourcery.com>
 
diff --git libgomp/configure libgomp/configure
index f72378e..839b2c6 100755
--- libgomp/configure
+++ libgomp/configure
@@ -16553,7 +16553,7 @@ ac_config_files="$ac_config_files omp.h omp_lib.h omp_lib.f90 libgomp_f.h"
 
 ac_config_files="$ac_config_files Makefile testsuite/Makefile libgomp.spec"
 
-ac_config_files="$ac_config_files testsuite/libgomp-test-support.exp"
+ac_config_files="$ac_config_files testsuite/libgomp-test-support.pt.exp:testsuite/libgomp-test-support.exp.in"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -17699,7 +17699,7 @@ do
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
     "libgomp.spec") CONFIG_FILES="$CONFIG_FILES libgomp.spec" ;;
-    "testsuite/libgomp-test-support.exp") CONFIG_FILES="$CONFIG_FILES testsuite/libgomp-test-support.exp" ;;
+    "testsuite/libgomp-test-support.pt.exp") CONFIG_FILES="$CONFIG_FILES testsuite/libgomp-test-support.pt.exp:testsuite/libgomp-test-support.exp.in" ;;
 
   *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
diff --git libgomp/configure.ac libgomp/configure.ac
index 178c34d..4687b01 100644
--- libgomp/configure.ac
+++ libgomp/configure.ac
@@ -352,5 +352,5 @@ CFLAGS="$save_CFLAGS"
 
 AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h)
 AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec)
-AC_CONFIG_FILES([testsuite/libgomp-test-support.exp])
+AC_CONFIG_FILES([testsuite/libgomp-test-support.pt.exp:testsuite/libgomp-test-support.exp.in])
 AC_OUTPUT
diff --git libgomp/testsuite/Makefile.am libgomp/testsuite/Makefile.am
index 561b7e2..66a9d94 100644
--- libgomp/testsuite/Makefile.am
+++ libgomp/testsuite/Makefile.am
@@ -11,3 +11,17 @@ EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
 _RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
 	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
 RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
+
+
+# Instead of directly in ../testsuite/libgomp-test-support.exp.in, the
+# following variables have to be "routed through" this Makefile, for expansion
+# of the several (Makefile) variables used therein.
+libgomp-test-support.exp: libgomp-test-support.pt.exp Makefile
+	cp $< $@.tmp
+	echo >> $@.tmp \
+	  'set offload_additional_options "$(offload_additional_options)"'
+	echo >> $@.tmp \
+	  'set offload_additional_lib_paths "$(offload_additional_lib_paths)"'
+	mv $@.tmp $@
+
+all-local: libgomp-test-support.exp
diff --git libgomp/testsuite/Makefile.in libgomp/testsuite/Makefile.in
index 016d0d4..352fc3f 100644
--- libgomp/testsuite/Makefile.in
+++ libgomp/testsuite/Makefile.in
@@ -56,7 +56,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES = libgomp-test-support.exp
+CONFIG_CLEAN_FILES = libgomp-test-support.pt.exp
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DEJATOOL = $(PACKAGE)
@@ -258,7 +258,7 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
-libgomp-test-support.exp: $(top_builddir)/config.status $(srcdir)/libgomp-test-support.exp.in
+libgomp-test-support.pt.exp: $(top_builddir)/config.status $(srcdir)/libgomp-test-support.exp.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 
 mostlyclean-libtool:
@@ -313,7 +313,7 @@ distclean-DEJAGNU:
 check-am: all-am
 	$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
 check: check-am
-all-am: Makefile
+all-am: Makefile all-local
 installdirs:
 install: install-am
 install-exec: install-exec-am
@@ -408,19 +408,32 @@ uninstall-am:
 
 .MAKE: check-am install-am install-strip
 
-.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
-	clean-libtool distclean distclean-DEJAGNU distclean-generic \
-	distclean-libtool dvi dvi-am html html-am info info-am install \
-	install-am install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	uninstall uninstall-am
+.PHONY: all all-am all-local check check-DEJAGNU check-am clean \
+	clean-generic clean-libtool distclean distclean-DEJAGNU \
+	distclean-generic distclean-libtool dvi dvi-am html html-am \
+	info info-am install install-am install-data install-data-am \
+	install-dvi install-dvi-am install-exec install-exec-am \
+	install-html install-html-am install-info install-info-am \
+	install-man install-pdf install-pdf-am install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+	ps ps-am uninstall uninstall-am
 
 
+# Instead of directly in ../testsuite/libgomp-test-support.exp.in, the
+# following variables have to be "routed through" this Makefile, for expansion
+# of the several (Makefile) variables used therein.
+libgomp-test-support.exp: libgomp-test-support.pt.exp Makefile
+	cp $< $@.tmp
+	echo >> $@.tmp \
+	  'set offload_additional_options "$(offload_additional_options)"'
+	echo >> $@.tmp \
+	  'set offload_additional_lib_paths "$(offload_additional_lib_paths)"'
+	mv $@.tmp $@
+
+all-local: libgomp-test-support.exp
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git libgomp/testsuite/libgomp-test-support.exp.in libgomp/testsuite/libgomp-test-support.exp.in
index 4586fbe..764bec0 100644
--- libgomp/testsuite/libgomp-test-support.exp.in
+++ libgomp/testsuite/libgomp-test-support.exp.in
@@ -2,5 +2,3 @@ set cuda_driver_include "@CUDA_DRIVER_INCLUDE@"
 set cuda_driver_lib "@CUDA_DRIVER_LIB@"
 
 set offload_targets "@offload_targets@"
-set offload_additional_options "@offload_additional_options@"
-set offload_additional_lib_paths "@offload_additional_lib_paths@"


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-22 11:49       ` Thomas Schwinge
@ 2014-12-22 12:50         ` Jakub Jelinek
  2015-01-15 19:21           ` Ilya Verbin
  2014-12-26 20:53         ` Ilya Verbin
  1 sibling, 1 reply; 27+ messages in thread
From: Jakub Jelinek @ 2014-12-22 12:50 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Ilya Verbin, Kirill Yukhin, Andrey Turetskiy, gcc

On Mon, Dec 22, 2014 at 12:48:08PM +0100, Thomas Schwinge wrote:
> In my understanding, we'd like to support the modes that either all
> compilers are installed (which is what a user will be using), or all are
> tested from their build trees.  Or, do we also have to support the mode
> that only the offloading compilers are installed, but the target
> (offloading host) compiler is not?  (Doesn't make much sense to me.)

All 3 of these, yes.
The nothing is installed yet mode supposedly doesn't work properly on the
trunk yet (and is what I'd like to use e.g. in distro rpm builds), the offloading
compilers installed, host is not is useful that you actually test the host compiler
before installing, and that supposedly works on the trunk, the all installed testing
I've never used myself, but some people are using it.

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-18 17:43     ` Ilya Verbin
  2014-12-18 17:56       ` Jakub Jelinek
@ 2014-12-22 11:49       ` Thomas Schwinge
  2014-12-22 12:50         ` Jakub Jelinek
  2014-12-26 20:53         ` Ilya Verbin
  1 sibling, 2 replies; 27+ messages in thread
From: Thomas Schwinge @ 2014-12-22 11:49 UTC (permalink / raw)
  To: Ilya Verbin, Jakub Jelinek; +Cc: Kirill Yukhin, Andrey Turetskiy, gcc

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

Hi!

On Thu, 18 Dec 2014 18:41:18 +0100, Ilya Verbin <iverbin@gmail.com> wrote:
> 2014-12-18 16:27 GMT+01:00 Thomas Schwinge <thomas@codesourcery.com>:
> > On Thu, 30 Oct 2014 14:40:01 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> >> This patch allows to run non-fallback 'make check-target-libgomp'.  It passes to
> >> the host compiler additional -B options with the paths to the offload compilers,
> >> since non-installed host compiler doesn't know where to find mkoffload tools.
> >> Also in case of intelmic offload targets it appends paths to liboffloadmic lib.
> >
> >> --- a/libgomp/configure.ac
> >> +++ b/libgomp/configure.ac
> >> @@ -280,9 +280,13 @@ else
> >>    multilib_arg=
> >>  fi
> >>
> >> +# Get accel target and path to install tree of accel compiler
> >> +offload_additional_options=
> >> +offload_additional_lib_paths=
> >>  offload_targets=
> >>  if test x"$enable_offload_targets" != x; then
> >>    for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
> >> +    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
> >>      tgt=`echo $tgt | sed 's/=.*//'`
> >>      case $tgt in
> >>        *-intelmic-* | *-intelmicemul-*)
> >> @@ -295,10 +299,20 @@ if test x"$enable_offload_targets" != x; then
> >>      else
> >>        offload_targets=$offload_targets,$tgt_name
> >>      fi
> >> +    if test x"$tgt_dir" != x; then
> >> +      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
> >> +      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
> >> +    else
> >> +      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
> >> +      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
> >> +    fi
> >>    done
> >>  fi
> >
> > Hmm, maybe I'm seeing a problem where there isn't one, but in case I'm
> > not: how will this work if there is more than one offloading compiler
> > configured?  Won't you get conflicting -B paths added to
> > offload_additional_options in this case?

> In this place I don't see any problems, at least for the case with
> installed offloading compilers.
> One -B allows to find mkoffload in lto-wrapper:compile_offload_image.
> This function tries to open all paths + '/accel/target_name/mkoffload'
> suffix. So, there should be no conflicts.
> Another -B allows mkoffload to find target driver. It tries to open
> 'host_name-accel-target_name-gcc', so, there also should be no
> conflicts.

Aha, thanks for the explanation, and yes, that seems all good.


What is the reason for adding paths if $tgt_dir is empty?  (I mean, if
properly installed and $tgt_dir empty, this should just work, because
that's what a user will be doing, so why does the libgomp testsuite have
to do differently?)  These paths will (basically) point to GCC's
configured --prefix=[...] -- which may not actually match where the
installed offloading compilers are to be found, for example, in the
common case that DESTDIR is used with make install.  And, isn't it that
GCC by default will already be looking into "$prefix" installation
directories, or is this solving an actual problem for you?  If not, is it
then OK to remove the cases for empty $tgt_dir?


> However, I still did not tried to enable 'make check' with
> non-installed offloading compilers.

I'm working of that (with low priority, though).

In my understanding, we'd like to support the modes that either all
compilers are installed (which is what a user will be using), or all are
tested from their build trees.  Or, do we also have to support the mode
that only the offloading compilers are installed, but the target
(offloading host) compiler is not?  (Doesn't make much sense to me.)


Here is a patch to correctly match intelmic in $offload_targets; OK to
commit, I assume?  I suppose I'm the first one to ever do build-tree
testing?  (Jakub?)

--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -115,8 +115,7 @@ proc libgomp_init { args } {
 
     # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
     # non-fallback testing for Intel MIC targets
-    if { [string match "*-intelmic-*" $offload_targets]
-	|| [string match "*-intelmicemul-*" $offload_targets] } {
+    if { [string match "*,intelmic,*" ",$offload_targets,"] } {
 	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
 	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
 	# libstdc++ is required by liboffloadmic


Such things also need to be guarded to be done for build-tree testing
only; I'll address this later on, where missing.


Here is a patch to fix 32-bit x86 Intel MIC offloading; OK to commit, I
assume?

    [...]
    spawn [...]/build-gcc/gcc/xgcc -B[...]/build-gcc/gcc/ [...]/source-gcc/libgomp/testsuite/libgomp.c/examples-4/e.50.1.c -B[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/ -B[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs -I[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp -I[...]/source-gcc/libgomp/testsuite/.. -march=i486 -fmessage-length=0 -fno-diagnostics-show-caret -fdiagnostics-color=never -B[...]/install/offload-x86_64-intelmicemul-linux-gnu/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0 -B[...]/install/offload-x86_64-intelmicemul-linux-gnu/bin -fopenmp -O2 -L[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs -lm -m32 -o ./e.50.1.exe
    PASS: libgomp.c/examples-4/e.50.1.c (test for excess errors)
    Setting LD_LIBRARY_PATH to .:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/plugin/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../libstdc++-v3/src/.libs:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib64:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib:[...]/build-gcc/gcc:[...]/build-gcc/gcc/32:.:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../liboffloadmic/plugin/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/32/libgomp/../libstdc++-v3/src/.libs:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib64:[...]/install/offload-x86_64-intelmicemul-linux-gnu/lib:[...]/build-gcc/gcc:[...]/build-gcc/gcc/32:[...]/build-gcc/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libsanitizer/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libvtv/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libcilkrts/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/liboffloadmic/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libssp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libgomp/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libitm/.libs:[...]/build-gcc/x86_64-unknown-linux-gnu/libatomic/.libs:[...]/build-gcc/./gcc:[...]/build-gcc/./prev-gcc
    spawn [open ...]
    /tmp/offload_WCXKRZ/offload_target_main: error while loading shared libraries: liboffloadmic_target.so.5: wrong ELF class: ELFCLASS64
    WARNING: program timed out.
    FAIL: libgomp.c/examples-4/e.50.1.c execution test
    [...]

(It is bad that testing is running into loooong timeouts for every single
offloading test case, but I'm not addressing that with my patch.)

This is a "standard" GCC configuration: x86_64-intelmicemul-linux-gnu with
(default) multilibs enabled:

    $ find -name liboffloadmic_target.so.5
    ./install/offload-x86_64-intelmicemul-linux-gnu/lib64/liboffloadmic_target.so.5
    ./install/offload-x86_64-intelmicemul-linux-gnu/lib32/liboffloadmic_target.so.5
    ./build-gcc-offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/32/liboffloadmic/.libs/liboffloadmic_target.so.5
    ./build-gcc-offload-x86_64-intelmicemul-linux-gnu/x86_64-intelmicemul-linux-gnu/liboffloadmic/.libs/liboffloadmic_target.so.5

--- libgomp/configure.ac
+++ libgomp/configure.ac
@@ -304,7 +304,7 @@ if test x"$enable_offload_targets" != x; then
     fi
     if test x"$tgt_dir" != x; then
       offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
-      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
     else
       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
       offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"


Grüße,
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-18 17:43     ` Ilya Verbin
@ 2014-12-18 17:56       ` Jakub Jelinek
  2014-12-22 11:49       ` Thomas Schwinge
  1 sibling, 0 replies; 27+ messages in thread
From: Jakub Jelinek @ 2014-12-18 17:56 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: Thomas Schwinge, Kirill Yukhin, Andrey Turetskiy, gcc

On Thu, Dec 18, 2014 at 06:41:18PM +0100, Ilya Verbin wrote:
> > What we're doing in OpenACC offloading testing (gomp-4_0-branch), is in
> > the libgomp.oacc-c/c.exp (etc.) file cycle through all the available
> > offloading devices, and then in there -- I think -- such options should
> > be set, that are specific to one particular offloading device/compiler?
> 
> I have not tested a compiler, configured to support 2 different
> offloading targets, so there might be some corner cases.
> 
> In this place I don't see any problems, at least for the case with
> installed offloading compilers.
> One -B allows to find mkoffload in lto-wrapper:compile_offload_image.
> This function tries to open all paths + '/accel/target_name/mkoffload'
> suffix. So, there should be no conflicts.
> Another -B allows mkoffload to find target driver. It tries to open
> 'host_name-accel-target_name-gcc', so, there also should be no
> conflicts.
> 
> However, I still did not tried to enable 'make check' with
> non-installed offloading compilers. Probably such target specific
> paths can help there.

Yeah, generally we want to be able to support all 3 (or 4 etc.) compilers
installed into the same DESTDIR and prefix, so extra -B arguments in there
should not break anything, for each of the offloading compilers you'd just
add what -B options it needs.

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-18 15:56   ` Thomas Schwinge
@ 2014-12-18 17:43     ` Ilya Verbin
  2014-12-18 17:56       ` Jakub Jelinek
  2014-12-22 11:49       ` Thomas Schwinge
  0 siblings, 2 replies; 27+ messages in thread
From: Ilya Verbin @ 2014-12-18 17:43 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Jakub Jelinek, Kirill Yukhin, Andrey Turetskiy, gcc

Hi,

2014-12-18 16:27 GMT+01:00 Thomas Schwinge <thomas@codesourcery.com>:
> Hi!
>
> On Thu, 30 Oct 2014 14:40:01 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
>> This patch allows to run non-fallback 'make check-target-libgomp'.  It passes to
>> the host compiler additional -B options with the paths to the offload compilers,
>> since non-installed host compiler doesn't know where to find mkoffload tools.
>> Also in case of intelmic offload targets it appends paths to liboffloadmic lib.
>
>> --- a/libgomp/configure.ac
>> +++ b/libgomp/configure.ac
>> @@ -280,9 +280,13 @@ else
>>    multilib_arg=
>>  fi
>>
>> +# Get accel target and path to install tree of accel compiler
>> +offload_additional_options=
>> +offload_additional_lib_paths=
>>  offload_targets=
>>  if test x"$enable_offload_targets" != x; then
>>    for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
>> +    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
>>      tgt=`echo $tgt | sed 's/=.*//'`
>>      case $tgt in
>>        *-intelmic-* | *-intelmicemul-*)
>> @@ -295,10 +299,20 @@ if test x"$enable_offload_targets" != x; then
>>      else
>>        offload_targets=$offload_targets,$tgt_name
>>      fi
>> +    if test x"$tgt_dir" != x; then
>> +      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
>> +      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
>> +    else
>> +      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
>> +      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
>> +    fi
>>    done
>>  fi
>
> Hmm, maybe I'm seeing a problem where there isn't one, but in case I'm
> not: how will this work if there is more than one offloading compiler
> configured?  Won't you get conflicting -B paths added to
> offload_additional_options in this case?
>
>> --- a/libgomp/testsuite/lib/libgomp.exp
>> +++ b/libgomp/testsuite/lib/libgomp.exp
>> @@ -169,6 +186,10 @@ proc libgomp_init { args } {
>>
>>      # Disable color diagnostics
>>      lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
>> +
>> +    # Required to support non-fallback testing of '#pragma omp target'.
>> +    # Help GCC to find target mkoffload.
>> +    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
>>  }
>
> What we're doing in OpenACC offloading testing (gomp-4_0-branch), is in
> the libgomp.oacc-c/c.exp (etc.) file cycle through all the available
> offloading devices, and then in there -- I think -- such options should
> be set, that are specific to one particular offloading device/compiler?
>
>
> Grüße,
>  Thomas

I have not tested a compiler, configured to support 2 different
offloading targets, so there might be some corner cases.

In this place I don't see any problems, at least for the case with
installed offloading compilers.
One -B allows to find mkoffload in lto-wrapper:compile_offload_image.
This function tries to open all paths + '/accel/target_name/mkoffload'
suffix. So, there should be no conflicts.
Another -B allows mkoffload to find target driver. It tries to open
'host_name-accel-target_name-gcc', so, there also should be no
conflicts.

However, I still did not tried to enable 'make check' with
non-installed offloading compilers. Probably such target specific
paths can help there.

  -- Ilya

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-10-30 12:45 ` [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Ilya Verbin
  2014-11-06 17:55   ` Jakub Jelinek
@ 2014-12-18 15:56   ` Thomas Schwinge
  2014-12-18 17:43     ` Ilya Verbin
  2016-03-13 19:10   ` Thomas Schwinge
  2 siblings, 1 reply; 27+ messages in thread
From: Thomas Schwinge @ 2014-12-18 15:56 UTC (permalink / raw)
  To: Ilya Verbin, Jakub Jelinek; +Cc: Kirill Yukhin, Andrey Turetskiy, gcc-patches

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

Hi!

On Thu, 30 Oct 2014 14:40:01 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> This patch allows to run non-fallback 'make check-target-libgomp'.  It passes to
> the host compiler additional -B options with the paths to the offload compilers,
> since non-installed host compiler doesn't know where to find mkoffload tools.
> Also in case of intelmic offload targets it appends paths to liboffloadmic lib.

> --- a/libgomp/configure.ac
> +++ b/libgomp/configure.ac
> @@ -280,9 +280,13 @@ else
>    multilib_arg=
>  fi
>  
> +# Get accel target and path to install tree of accel compiler
> +offload_additional_options=
> +offload_additional_lib_paths=
>  offload_targets=
>  if test x"$enable_offload_targets" != x; then
>    for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
> +    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
>      tgt=`echo $tgt | sed 's/=.*//'`
>      case $tgt in
>        *-intelmic-* | *-intelmicemul-*)
> @@ -295,10 +299,20 @@ if test x"$enable_offload_targets" != x; then
>      else
>        offload_targets=$offload_targets,$tgt_name
>      fi
> +    if test x"$tgt_dir" != x; then
> +      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
> +      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
> +    else
> +      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
> +      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
> +    fi
>    done
>  fi

Hmm, maybe I'm seeing a problem where there isn't one, but in case I'm
not: how will this work if there is more than one offloading compiler
configured?  Won't you get conflicting -B paths added to
offload_additional_options in this case?

> --- a/libgomp/testsuite/lib/libgomp.exp
> +++ b/libgomp/testsuite/lib/libgomp.exp
> @@ -169,6 +186,10 @@ proc libgomp_init { args } {
>  
>      # Disable color diagnostics
>      lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
> +
> +    # Required to support non-fallback testing of '#pragma omp target'.
> +    # Help GCC to find target mkoffload.
> +    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
>  }

What we're doing in OpenACC offloading testing (gomp-4_0-branch), is in
the libgomp.oacc-c/c.exp (etc.) file cycle through all the available
offloading devices, and then in there -- I think -- such options should
be set, that are specific to one particular offloading device/compiler?


Grüße,
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-12-17 22:53       ` Thomas Schwinge
@ 2014-12-18 10:46         ` Jakub Jelinek
  2014-12-22 16:37           ` Thomas Schwinge
  0 siblings, 1 reply; 27+ messages in thread
From: Jakub Jelinek @ 2014-12-18 10:46 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Ilya Verbin, gcc-patches, Kirill Yukhin, Andrey Turetskiy

On Wed, Dec 17, 2014 at 11:48:01PM +0100, Thomas Schwinge wrote:
> I have another suggestion: on gomp-4_0-branch, we had already started
> using a libgomp-test-support.exp file for a similar purpose.  I now
> changed your code on gomp-4_0-branch in r218845 as follows (though, not
> very much tested).  The advantage here is that people who are not using
> GCC build-tree testing, but are directly invoking runtest, then don't
> have to set various environment variables, but instead just have to copy
> this one libgomp-test-support.exp file from the build tree to the testing
> tree.  Does this make sense?
> 
> commit de01639bf47e29a20959771e587fb6f30c372a45
> Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date:   Wed Dec 17 22:45:05 2014 +0000
> 
>     libgomp: Route offloading data through the libgomp-test-support.exp file.
>     
>     	libgomp/
>     	* testsuite/Makefile.am: Don't export OFFLOAD_TARGETS,
>     	OFFLOAD_ADDITIONAL_OPTIONS, and OFFLOAD_ADDITIONAL_LIB_PATHS...
>     	* testsuite/libgomp-test-support.exp.in: ..., and instead set
>     	offload_targets, offload_additional_options, and
>     	offload_additional_lib_paths here.  Update all users.

LGTM.

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-10 14:51     ` Ilya Verbin
  2014-11-11  7:10       ` Jakub Jelinek
  2014-11-12  9:18       ` Jakub Jelinek
@ 2014-12-17 22:53       ` Thomas Schwinge
  2014-12-18 10:46         ` Jakub Jelinek
  2 siblings, 1 reply; 27+ messages in thread
From: Thomas Schwinge @ 2014-12-17 22:53 UTC (permalink / raw)
  To: Ilya Verbin, Jakub Jelinek; +Cc: gcc-patches, Kirill Yukhin, Andrey Turetskiy

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

Hi!

On Mon, 10 Nov 2014 17:34:30 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> On 06 Nov 18:55, Jakub Jelinek wrote:
> > Looks mostly good, but:
> > 
> > > +# We need more things in site.exp, but automake completely controls the
> > > +# creation of that file; there's no way to append to it without messing up
> > > +# the dependancy chains.  So we overrule automake.  This rule is exactly
> > > +# what it would have generated, plus our own additions.
> > > +site.exp: Makefile
> > > +	@echo 'Making a new site.exp file...'
> > > +	@echo '## these variables are automatically generated by make ##' >site.tmp
> > > +	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
> > > +	@echo '# edit the last section' >>site.tmp
> > > +	@echo 'set srcdir $(srcdir)' >>site.tmp
> > > +[...]
> > > +	@echo 'set target_triplet $(target_triplet)' >>site.tmp
> > > +	@echo 'set offload_targets "$(offload_targets)"' >>site.tmp
> > > +	@echo 'set offload_additional_options "$(offload_additional_options)"' >>site.tmp
> > > +	@echo 'set offload_additional_lib_paths "$(offload_additional_lib_paths)"' >>site.tmp
> > > +	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
> > > +	@test ! -f site.exp || \
> > > +	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
> > > +	@-rm -f site.bak
> > > +	@test ! -f site.exp || mv site.exp site.bak
> > > +	@mv site.tmp site.exp
> > 
> > I don't like this, that is too fragile.  If automake is changed, we'll
> > forget to update this.

(The same problem exists elsewhere in GCC.  But I certainly do agree that
it's ugly.)

> > If all you are about are the 3 additional variables, can't you instead
> > put them into env vars and query them in the tcl code using getenv?
> > Or append them into AM_RUNTESTFLAGS ?
> > AM_RUNTESTFLAGS += @something@
> 
> Done, I put them into env vars.

> --- a/libgomp/testsuite/Makefile.am
> +++ b/libgomp/testsuite/Makefile.am
> @@ -11,3 +11,8 @@ EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
>  _RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
>  	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
>  RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
> +
> +# Used for support non-fallback offloading.
> +export OFFLOAD_TARGETS = $(offload_targets)
> +export OFFLOAD_ADDITIONAL_OPTIONS = $(offload_additional_options)
> +export OFFLOAD_ADDITIONAL_LIB_PATHS = $(offload_additional_lib_paths)

> --- a/libgomp/testsuite/lib/libgomp.exp
> +++ b/libgomp/testsuite/lib/libgomp.exp
> @@ -107,6 +107,25 @@ proc libgomp_init { args } {
>      # Compute what needs to be put into LD_LIBRARY_PATH
>      set always_ld_library_path ".:${blddir}/.libs"
>  
> +    # Get offload-related variables from environment (exported by Makefile)
> +    set offload_targets [getenv OFFLOAD_TARGETS]
> +    set offload_additional_options [getenv OFFLOAD_ADDITIONAL_OPTIONS]
> +    set offload_additional_lib_paths [getenv OFFLOAD_ADDITIONAL_LIB_PATHS]
> +[...]

I have another suggestion: on gomp-4_0-branch, we had already started
using a libgomp-test-support.exp file for a similar purpose.  I now
changed your code on gomp-4_0-branch in r218845 as follows (though, not
very much tested).  The advantage here is that people who are not using
GCC build-tree testing, but are directly invoking runtest, then don't
have to set various environment variables, but instead just have to copy
this one libgomp-test-support.exp file from the build tree to the testing
tree.  Does this make sense?

commit de01639bf47e29a20959771e587fb6f30c372a45
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Dec 17 22:45:05 2014 +0000

    libgomp: Route offloading data through the libgomp-test-support.exp file.
    
    	libgomp/
    	* testsuite/Makefile.am: Don't export OFFLOAD_TARGETS,
    	OFFLOAD_ADDITIONAL_OPTIONS, and OFFLOAD_ADDITIONAL_LIB_PATHS...
    	* testsuite/libgomp-test-support.exp.in: ..., and instead set
    	offload_targets, offload_additional_options, and
    	offload_additional_lib_paths here.  Update all users.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@218845 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp                        | 6 ++++++
 libgomp/testsuite/Makefile.am                 | 5 -----
 libgomp/testsuite/Makefile.in                 | 5 -----
 libgomp/testsuite/lib/libgomp.exp             | 8 +++-----
 libgomp/testsuite/libgomp-test-support.exp.in | 4 ++++
 5 files changed, 13 insertions(+), 15 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index 1fca220..9c23c80 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,11 @@
 2014-12-17  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* testsuite/Makefile.am: Don't export OFFLOAD_TARGETS,
+	OFFLOAD_ADDITIONAL_OPTIONS, and OFFLOAD_ADDITIONAL_LIB_PATHS...
+	* testsuite/libgomp-test-support.exp.in: ..., and instead set
+	offload_targets, offload_additional_options, and
+	offload_additional_lib_paths here.  Update all users.
+
 	* testsuite/libgomp.oacc-c++/c++.exp
 	(check_effective_target_oacc_c): Remove, and ...
 	* testsuite/libgomp.oacc-c/c.exp (check_effective_target_oacc_c):
diff --git libgomp/testsuite/Makefile.am libgomp/testsuite/Makefile.am
index 9cc103a..561b7e2 100644
--- libgomp/testsuite/Makefile.am
+++ libgomp/testsuite/Makefile.am
@@ -11,8 +11,3 @@ EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
 _RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
 	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
 RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
-
-# Used for support non-fallback offloading.
-export OFFLOAD_TARGETS = $(offload_targets)
-export OFFLOAD_ADDITIONAL_OPTIONS = $(offload_additional_options)
-export OFFLOAD_ADDITIONAL_LIB_PATHS = $(offload_additional_lib_paths)
diff --git libgomp/testsuite/Makefile.in libgomp/testsuite/Makefile.in
index 78b6351..016d0d4 100644
--- libgomp/testsuite/Makefile.in
+++ libgomp/testsuite/Makefile.in
@@ -421,11 +421,6 @@ uninstall-am:
 	uninstall uninstall-am
 
 
-# Used for support non-fallback offloading.
-export OFFLOAD_TARGETS = $(offload_targets)
-export OFFLOAD_ADDITIONAL_OPTIONS = $(offload_additional_options)
-export OFFLOAD_ADDITIONAL_LIB_PATHS = $(offload_additional_lib_paths)
-
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 81545db..6600c25 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -111,13 +111,9 @@ proc libgomp_init { args } {
     # Compute what needs to be put into LD_LIBRARY_PATH
     set always_ld_library_path ".:${blddir}/.libs"
 
-    # Get offload-related variables from environment (exported by Makefile)
-    set offload_targets [getenv OFFLOAD_TARGETS]
-    set offload_additional_options [getenv OFFLOAD_ADDITIONAL_OPTIONS]
-    set offload_additional_lib_paths [getenv OFFLOAD_ADDITIONAL_LIB_PATHS]
-
     # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
     # non-fallback testing for Intel MIC targets
+    global offload_targets
     if { [string match "*-intelmic-*" $offload_targets]
 	|| [string match "*-intelmicemul-*" $offload_targets] } {
 	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
@@ -126,6 +122,7 @@ proc libgomp_init { args } {
 	append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
     }
 
+    global offload_additional_lib_paths
     if { $offload_additional_lib_paths != "" } {
 	append always_ld_library_path "${offload_additional_lib_paths}"
     }
@@ -215,6 +212,7 @@ proc libgomp_init { args } {
 
     # Used for support non-fallback offloading.
     # Help GCC to find target mkoffload.
+    global offload_additional_options
     if { $offload_additional_options != "" } {
 	lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
     }
diff --git libgomp/testsuite/libgomp-test-support.exp.in libgomp/testsuite/libgomp-test-support.exp.in
index dcadad7..4586fbe 100644
--- libgomp/testsuite/libgomp-test-support.exp.in
+++ libgomp/testsuite/libgomp-test-support.exp.in
@@ -1,2 +1,6 @@
 set cuda_driver_include "@CUDA_DRIVER_INCLUDE@"
 set cuda_driver_lib "@CUDA_DRIVER_LIB@"
+
+set offload_targets "@offload_targets@"
+set offload_additional_options "@offload_additional_options@"
+set offload_additional_lib_paths "@offload_additional_lib_paths@"


Grüße,
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-10 14:51     ` Ilya Verbin
  2014-11-11  7:10       ` Jakub Jelinek
@ 2014-11-12  9:18       ` Jakub Jelinek
  2014-12-17 22:53       ` Thomas Schwinge
  2 siblings, 0 replies; 27+ messages in thread
From: Jakub Jelinek @ 2014-11-12  9:18 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: gcc-patches, Kirill Yukhin, Andrey Turetskiy

On Mon, Nov 10, 2014 at 05:34:30PM +0300, Ilya Verbin wrote:
> > I don't like this, that is too fragile.  If automake is changed, we'll
> > forget to update this.
> > If all you are about are the 3 additional variables, can't you instead
> > put them into env vars and query them in the tcl code using getenv?
> > Or append them into AM_RUNTESTFLAGS ?
> > AM_RUNTESTFLAGS += @something@
> 
> Done, I put them into env vars.

Thanks.

> > > +    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
> > >  }
> > 
> > Perhaps add this only if offload_additional_options is non-empty?
> 
> Done.

Ok for trunk.

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-10 14:51     ` Ilya Verbin
@ 2014-11-11  7:10       ` Jakub Jelinek
  2014-11-12  9:18       ` Jakub Jelinek
  2014-12-17 22:53       ` Thomas Schwinge
  2 siblings, 0 replies; 27+ messages in thread
From: Jakub Jelinek @ 2014-11-11  7:10 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: gcc-patches, Kirill Yukhin, Andrey Turetskiy

On Mon, Nov 10, 2014 at 05:34:30PM +0300, Ilya Verbin wrote:
> Done, I put them into env vars.
> 
> > > +    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
> > >  }
> > 
> > Perhaps add this only if offload_additional_options is non-empty?
> 
> Done.

Ok (with appropriate ChangeLog entry).

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-11-06 17:55   ` Jakub Jelinek
@ 2014-11-10 14:51     ` Ilya Verbin
  2014-11-11  7:10       ` Jakub Jelinek
                         ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Ilya Verbin @ 2014-11-10 14:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Kirill Yukhin, Andrey Turetskiy

On 06 Nov 18:55, Jakub Jelinek wrote:
> Looks mostly good, but:
> 
> > +# We need more things in site.exp, but automake completely controls the
> > +# creation of that file; there's no way to append to it without messing up
> > +# the dependancy chains.  So we overrule automake.  This rule is exactly
> > +# what it would have generated, plus our own additions.
> > +site.exp: Makefile
> > +	@echo 'Making a new site.exp file...'
> > +	@echo '## these variables are automatically generated by make ##' >site.tmp
> > +	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
> > +	@echo '# edit the last section' >>site.tmp
> > +	@echo 'set srcdir $(srcdir)' >>site.tmp
> > +	@echo "set objdir `pwd`" >>site.tmp
> > +	@echo 'set build_alias "$(build_alias)"' >>site.tmp
> > +	@echo 'set build_triplet $(build_triplet)' >>site.tmp
> > +	@echo 'set host_alias "$(host_alias)"' >>site.tmp
> > +	@echo 'set host_triplet $(host_triplet)' >>site.tmp
> > +	@echo 'set target_alias "$(target_alias)"' >>site.tmp
> > +	@echo 'set target_triplet $(target_triplet)' >>site.tmp
> > +	@echo 'set offload_targets "$(offload_targets)"' >>site.tmp
> > +	@echo 'set offload_additional_options "$(offload_additional_options)"' >>site.tmp
> > +	@echo 'set offload_additional_lib_paths "$(offload_additional_lib_paths)"' >>site.tmp
> > +	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
> > +	@test ! -f site.exp || \
> > +	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
> > +	@-rm -f site.bak
> > +	@test ! -f site.exp || mv site.exp site.bak
> > +	@mv site.tmp site.exp
> 
> I don't like this, that is too fragile.  If automake is changed, we'll
> forget to update this.
> If all you are about are the 3 additional variables, can't you instead
> put them into env vars and query them in the tcl code using getenv?
> Or append them into AM_RUNTESTFLAGS ?
> AM_RUNTESTFLAGS += @something@

Done, I put them into env vars.

> > +    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
> >  }
> 
> Perhaps add this only if offload_additional_options is non-empty?

Done.

Thanks,
  -- Ilya


---

diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 5cd666f..8e4774f 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -268,6 +268,9 @@ lt_host_flags = @lt_host_flags@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 multi_basedir = @multi_basedir@
+offload_additional_lib_paths = @offload_additional_lib_paths@
+offload_additional_options = @offload_additional_options@
+offload_targets = @offload_targets@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
diff --git a/libgomp/configure b/libgomp/configure
index 97c9be6..aabf25f 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -616,6 +616,9 @@ OMP_LOCK_SIZE
 USE_FORTRAN_FALSE
 USE_FORTRAN_TRUE
 link_gomp
+offload_additional_lib_paths
+offload_additional_options
+offload_targets
 XLDFLAGS
 XCFLAGS
 config_path
@@ -11094,7 +11097,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11097 "configure"
+#line 11100 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11200,7 +11203,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11203 "configure"
+#line 11206 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16207,9 +16210,13 @@ else
   multilib_arg=
 fi
 
+# Get accel target and path to install tree of accel compiler
+offload_additional_options=
+offload_additional_lib_paths=
 offload_targets=
 if test x"$enable_offload_targets" != x; then
   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
+    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
     tgt=`echo $tgt | sed 's/=.*//'`
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
@@ -16222,6 +16229,13 @@ if test x"$enable_offload_targets" != x; then
     else
       offload_targets=$offload_targets,$tgt_name
     fi
+    if test x"$tgt_dir" != x; then
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+    else
+      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
+    fi
   done
 fi
 
@@ -16230,6 +16244,9 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+
+
 # Set up the set of libraries that we need to link against for libgomp.
 # Note that the GOMP_SELF_SPEC in gcc.c may force -pthread,
 # which will force linkage against -lpthread (or equivalent for the system).
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 3f34ff8..cea6366 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -280,9 +280,13 @@ else
   multilib_arg=
 fi
 
+# Get accel target and path to install tree of accel compiler
+offload_additional_options=
+offload_additional_lib_paths=
 offload_targets=
 if test x"$enable_offload_targets" != x; then
   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
+    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
     tgt=`echo $tgt | sed 's/=.*//'`
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
@@ -295,10 +299,20 @@ if test x"$enable_offload_targets" != x; then
     else
       offload_targets=$offload_targets,$tgt_name
     fi
+    if test x"$tgt_dir" != x; then
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+    else
+      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
+    fi
   done
 fi
 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
   [Define to hold the list of target names suitable for offloading.])
+AC_SUBST(offload_targets)
+AC_SUBST(offload_additional_options)
+AC_SUBST(offload_additional_lib_paths)
 
 # Set up the set of libraries that we need to link against for libgomp.
 # Note that the GOMP_SELF_SPEC in gcc.c may force -pthread,
diff --git a/libgomp/testsuite/Makefile.am b/libgomp/testsuite/Makefile.am
index 561b7e2..9cc103a 100644
--- a/libgomp/testsuite/Makefile.am
+++ b/libgomp/testsuite/Makefile.am
@@ -11,3 +11,8 @@ EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
 _RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
 	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
 RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
+
+# Used for support non-fallback offloading.
+export OFFLOAD_TARGETS = $(offload_targets)
+export OFFLOAD_ADDITIONAL_OPTIONS = $(offload_additional_options)
+export OFFLOAD_ADDITIONAL_LIB_PATHS = $(offload_additional_lib_paths)
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 5273eaa..2f845f0 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -184,6 +184,9 @@ lt_host_flags = @lt_host_flags@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 multi_basedir = @multi_basedir@
+offload_additional_lib_paths = @offload_additional_lib_paths@
+offload_additional_options = @offload_additional_options@
+offload_targets = @offload_targets@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
@@ -408,6 +411,11 @@ uninstall-am:
 	uninstall uninstall-am
 
 
+# Used for support non-fallback offloading.
+export OFFLOAD_TARGETS = $(offload_targets)
+export OFFLOAD_ADDITIONAL_OPTIONS = $(offload_additional_options)
+export OFFLOAD_ADDITIONAL_LIB_PATHS = $(offload_additional_lib_paths)
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 071e22f..a154684 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -107,6 +107,25 @@ proc libgomp_init { args } {
     # Compute what needs to be put into LD_LIBRARY_PATH
     set always_ld_library_path ".:${blddir}/.libs"
 
+    # Get offload-related variables from environment (exported by Makefile)
+    set offload_targets [getenv OFFLOAD_TARGETS]
+    set offload_additional_options [getenv OFFLOAD_ADDITIONAL_OPTIONS]
+    set offload_additional_lib_paths [getenv OFFLOAD_ADDITIONAL_LIB_PATHS]
+
+    # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
+    # non-fallback testing for Intel MIC targets
+    if { [string match "*-intelmic-*" $offload_targets]
+	|| [string match "*-intelmicemul-*" $offload_targets] } {
+	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
+	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
+	# libstdc++ is required by liboffloadmic
+	append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
+    }
+
+    if { $offload_additional_lib_paths != "" } {
+	append always_ld_library_path "${offload_additional_lib_paths}"
+    }
+
     # Compute what needs to be added to the existing LD_LIBRARY_PATH.
     if {$gccdir != ""} {
 	# Add AIX pthread directory first.
@@ -169,6 +188,12 @@ proc libgomp_init { args } {
 
     # Disable color diagnostics
     lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
+
+    # Used for support non-fallback offloading.
+    # Help GCC to find target mkoffload.
+    if { $offload_additional_options != "" } {
+	lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
+    }
 }
 
 #
-- 
1.7.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-10-30 12:45 ` [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Ilya Verbin
@ 2014-11-06 17:55   ` Jakub Jelinek
  2014-11-10 14:51     ` Ilya Verbin
  2014-12-18 15:56   ` Thomas Schwinge
  2016-03-13 19:10   ` Thomas Schwinge
  2 siblings, 1 reply; 27+ messages in thread
From: Jakub Jelinek @ 2014-11-06 17:55 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: gcc-patches, Kirill Yukhin, Andrey Turetskiy

On Thu, Oct 30, 2014 at 02:40:01PM +0300, Ilya Verbin wrote:
> 2014-10-30  Andrey Turetskiy  <andrey.turetskiy@intel.com>
> 	    Ilya Verbin  <ilya.verbin@intel.com>
> 
> libgomp/
> 	* Makefile.in: Regenerate.
> 	* configure: Regenerate.
> 	* configure.ac: Set up offload_additional_options,
> 	offload_additional_lib_paths and offload_targets.
> 	* testsuite/Makefile.am: Overrule site.exp.
> 	* testsuite/Makefile.in: Regenerate.
> 	* testsuite/lib/libgomp.exp (libgomp_init): Append
> 	offload_additional_lib_paths to LD_LIBRARY_PATH.  Append
> 	offload_additional_options to ALWAYS_CFLAGS.  Append liboffloadmic
> 	build directory to LD_LIBRARY_PATH for intelmic offload targets.

Looks mostly good, but:

> --- a/libgomp/testsuite/Makefile.am
> +++ b/libgomp/testsuite/Makefile.am
> @@ -11,3 +11,30 @@ EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
>  _RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
>  	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
>  RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
> +
> +# We need more things in site.exp, but automake completely controls the
> +# creation of that file; there's no way to append to it without messing up
> +# the dependancy chains.  So we overrule automake.  This rule is exactly
> +# what it would have generated, plus our own additions.
> +site.exp: Makefile
> +	@echo 'Making a new site.exp file...'
> +	@echo '## these variables are automatically generated by make ##' >site.tmp
> +	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
> +	@echo '# edit the last section' >>site.tmp
> +	@echo 'set srcdir $(srcdir)' >>site.tmp
> +	@echo "set objdir `pwd`" >>site.tmp
> +	@echo 'set build_alias "$(build_alias)"' >>site.tmp
> +	@echo 'set build_triplet $(build_triplet)' >>site.tmp
> +	@echo 'set host_alias "$(host_alias)"' >>site.tmp
> +	@echo 'set host_triplet $(host_triplet)' >>site.tmp
> +	@echo 'set target_alias "$(target_alias)"' >>site.tmp
> +	@echo 'set target_triplet $(target_triplet)' >>site.tmp
> +	@echo 'set offload_targets "$(offload_targets)"' >>site.tmp
> +	@echo 'set offload_additional_options "$(offload_additional_options)"' >>site.tmp
> +	@echo 'set offload_additional_lib_paths "$(offload_additional_lib_paths)"' >>site.tmp
> +	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
> +	@test ! -f site.exp || \
> +	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
> +	@-rm -f site.bak
> +	@test ! -f site.exp || mv site.exp site.bak
> +	@mv site.tmp site.exp

I don't like this, that is too fragile.  If automake is changed, we'll
forget to update this.
If all you are about are the 3 additional variables, can't you instead
put them into env vars and query them in the tcl code using getenv?
Or append them into AM_RUNTESTFLAGS ?
AM_RUNTESTFLAGS += @something@

> @@ -169,6 +186,10 @@ proc libgomp_init { args } {
>  
>      # Disable color diagnostics
>      lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
> +
> +    # Required to support non-fallback testing of '#pragma omp target'.
> +    # Help GCC to find target mkoffload.
> +    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
>  }

Perhaps add this only if offload_additional_options is non-empty?

	Jakub

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
  2014-10-21 17:16 [PATCH 0/4] OpenMP 4.0 offloading to Intel MIC Ilya Verbin
@ 2014-10-30 12:45 ` Ilya Verbin
  2014-11-06 17:55   ` Jakub Jelinek
                     ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Ilya Verbin @ 2014-10-30 12:45 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches; +Cc: Kirill Yukhin, Andrey Turetskiy

Hello,

This patch allows to run non-fallback 'make check-target-libgomp'.  It passes to
the host compiler additional -B options with the paths to the offload compilers,
since non-installed host compiler doesn't know where to find mkoffload tools.
Also in case of intelmic offload targets it appends paths to liboffloadmic lib.
Is it ok for trunk?

Thanks,
  -- Ilya


2014-10-30  Andrey Turetskiy  <andrey.turetskiy@intel.com>
	    Ilya Verbin  <ilya.verbin@intel.com>

libgomp/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Set up offload_additional_options,
	offload_additional_lib_paths and offload_targets.
	* testsuite/Makefile.am: Overrule site.exp.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/lib/libgomp.exp (libgomp_init): Append
	offload_additional_lib_paths to LD_LIBRARY_PATH.  Append
	offload_additional_options to ALWAYS_CFLAGS.  Append liboffloadmic
	build directory to LD_LIBRARY_PATH for intelmic offload targets.

---

diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 5cd666f..8e4774f 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -268,6 +268,9 @@ lt_host_flags = @lt_host_flags@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 multi_basedir = @multi_basedir@
+offload_additional_lib_paths = @offload_additional_lib_paths@
+offload_additional_options = @offload_additional_options@
+offload_targets = @offload_targets@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
diff --git a/libgomp/configure b/libgomp/configure
index 97c9be6..aabf25f 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -616,6 +616,9 @@ OMP_LOCK_SIZE
 USE_FORTRAN_FALSE
 USE_FORTRAN_TRUE
 link_gomp
+offload_additional_lib_paths
+offload_additional_options
+offload_targets
 XLDFLAGS
 XCFLAGS
 config_path
@@ -11094,7 +11097,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11097 "configure"
+#line 11100 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11200,7 +11203,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11203 "configure"
+#line 11206 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16207,9 +16210,13 @@ else
   multilib_arg=
 fi
 
+# Get accel target and path to install tree of accel compiler
+offload_additional_options=
+offload_additional_lib_paths=
 offload_targets=
 if test x"$enable_offload_targets" != x; then
   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
+    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
     tgt=`echo $tgt | sed 's/=.*//'`
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
@@ -16222,6 +16229,13 @@ if test x"$enable_offload_targets" != x; then
     else
       offload_targets=$offload_targets,$tgt_name
     fi
+    if test x"$tgt_dir" != x; then
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+    else
+      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
+    fi
   done
 fi
 
@@ -16230,6 +16244,9 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+
+
 # Set up the set of libraries that we need to link against for libgomp.
 # Note that the GOMP_SELF_SPEC in gcc.c may force -pthread,
 # which will force linkage against -lpthread (or equivalent for the system).
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 3f34ff8..cea6366 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -280,9 +280,13 @@ else
   multilib_arg=
 fi
 
+# Get accel target and path to install tree of accel compiler
+offload_additional_options=
+offload_additional_lib_paths=
 offload_targets=
 if test x"$enable_offload_targets" != x; then
   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
+    tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
     tgt=`echo $tgt | sed 's/=.*//'`
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
@@ -295,10 +299,20 @@ if test x"$enable_offload_targets" != x; then
     else
       offload_targets=$offload_targets,$tgt_name
     fi
+    if test x"$tgt_dir" != x; then
+      offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib"
+    else
+      offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
+      offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
+    fi
   done
 fi
 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
   [Define to hold the list of target names suitable for offloading.])
+AC_SUBST(offload_targets)
+AC_SUBST(offload_additional_options)
+AC_SUBST(offload_additional_lib_paths)
 
 # Set up the set of libraries that we need to link against for libgomp.
 # Note that the GOMP_SELF_SPEC in gcc.c may force -pthread,
diff --git a/libgomp/testsuite/Makefile.am b/libgomp/testsuite/Makefile.am
index 561b7e2..d2ff1ed 100644
--- a/libgomp/testsuite/Makefile.am
+++ b/libgomp/testsuite/Makefile.am
@@ -11,3 +11,30 @@ EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
 _RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
 	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
 RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
+
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains.  So we overrule automake.  This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo 'set build_alias "$(build_alias)"' >>site.tmp
+	@echo 'set build_triplet $(build_triplet)' >>site.tmp
+	@echo 'set host_alias "$(host_alias)"' >>site.tmp
+	@echo 'set host_triplet $(host_triplet)' >>site.tmp
+	@echo 'set target_alias "$(target_alias)"' >>site.tmp
+	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set offload_targets "$(offload_targets)"' >>site.tmp
+	@echo 'set offload_additional_options "$(offload_additional_options)"' >>site.tmp
+	@echo 'set offload_additional_lib_paths "$(offload_additional_lib_paths)"' >>site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+	@test ! -f site.exp || \
+	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 5273eaa..ab326cf 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -184,6 +184,9 @@ lt_host_flags = @lt_host_flags@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 multi_basedir = @multi_basedir@
+offload_additional_lib_paths = @offload_additional_lib_paths@
+offload_additional_options = @offload_additional_options@
+offload_targets = @offload_targets@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
@@ -272,25 +275,6 @@ check-DEJAGNU: site.exp
 	else echo "WARNING: could not find \`runtest'" 1>&2; :;\
 	fi; \
 	exit $$exit_status
-site.exp: Makefile
-	@echo 'Making a new site.exp file...'
-	@echo '## these variables are automatically generated by make ##' >site.tmp
-	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
-	@echo '# edit the last section' >>site.tmp
-	@echo 'set srcdir $(srcdir)' >>site.tmp
-	@echo "set objdir `pwd`" >>site.tmp
-	@echo 'set build_alias "$(build_alias)"' >>site.tmp
-	@echo 'set build_triplet $(build_triplet)' >>site.tmp
-	@echo 'set host_alias "$(host_alias)"' >>site.tmp
-	@echo 'set host_triplet $(host_triplet)' >>site.tmp
-	@echo 'set target_alias "$(target_alias)"' >>site.tmp
-	@echo 'set target_triplet $(target_triplet)' >>site.tmp
-	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
-	@test ! -f site.exp || \
-	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
-	@-rm -f site.bak
-	@test ! -f site.exp || mv site.exp site.bak
-	@mv site.tmp site.exp
 
 distclean-DEJAGNU:
 	-rm -f site.exp site.bak
@@ -408,6 +392,33 @@ uninstall-am:
 	uninstall uninstall-am
 
 
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains.  So we overrule automake.  This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo 'set build_alias "$(build_alias)"' >>site.tmp
+	@echo 'set build_triplet $(build_triplet)' >>site.tmp
+	@echo 'set host_alias "$(host_alias)"' >>site.tmp
+	@echo 'set host_triplet $(host_triplet)' >>site.tmp
+	@echo 'set target_alias "$(target_alias)"' >>site.tmp
+	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set offload_targets "$(offload_targets)"' >>site.tmp
+	@echo 'set offload_additional_options "$(offload_additional_options)"' >>site.tmp
+	@echo 'set offload_additional_lib_paths "$(offload_additional_lib_paths)"' >>site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+	@test ! -f site.exp || \
+	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 071e22f..cea4520 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -62,6 +62,9 @@ proc libgomp_init { args } {
     global TESTING_IN_BUILD_TREE
     global target_triplet
     global always_ld_library_path
+    global offload_targets
+    global offload_additional_options
+    global offload_additional_lib_paths
 
     set blddir [lookfor_file [get_multilibs] libgomp]
 
@@ -107,6 +110,20 @@ proc libgomp_init { args } {
     # Compute what needs to be put into LD_LIBRARY_PATH
     set always_ld_library_path ".:${blddir}/.libs"
 
+    # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
+    # non-fallback testing for Intel MIC targets
+    if { [string match "*-intelmic-*" $offload_targets]
+	|| [string match "*-intelmicemul-*" $offload_targets] } {
+	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
+	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
+	# libstdc++ is required by liboffloadmic
+	append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
+    }
+
+    if { $offload_additional_lib_paths != ""} {
+	append always_ld_library_path "${offload_additional_lib_paths}"
+    }
+
     # Compute what needs to be added to the existing LD_LIBRARY_PATH.
     if {$gccdir != ""} {
 	# Add AIX pthread directory first.
@@ -169,6 +186,10 @@ proc libgomp_init { args } {
 
     # Disable color diagnostics
     lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
+
+    # Required to support non-fallback testing of '#pragma omp target'.
+    # Help GCC to find target mkoffload.
+    lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
 }
 
 #
-- 
1.7.1

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2016-03-13 19:10 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-21 18:44 [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Bernd Edlinger
2014-11-21 18:59 ` Ilya Verbin
2014-11-21 19:01   ` Bernd Edlinger
2014-11-21 19:34     ` Ilya Verbin
2014-11-21 20:07       ` Jakub Jelinek
  -- strict thread matches above, loose matches on Subject: below --
2014-10-21 17:16 [PATCH 0/4] OpenMP 4.0 offloading to Intel MIC Ilya Verbin
2014-10-30 12:45 ` [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Ilya Verbin
2014-11-06 17:55   ` Jakub Jelinek
2014-11-10 14:51     ` Ilya Verbin
2014-11-11  7:10       ` Jakub Jelinek
2014-11-12  9:18       ` Jakub Jelinek
2014-12-17 22:53       ` Thomas Schwinge
2014-12-18 10:46         ` Jakub Jelinek
2014-12-22 16:37           ` Thomas Schwinge
2014-12-18 15:56   ` Thomas Schwinge
2014-12-18 17:43     ` Ilya Verbin
2014-12-18 17:56       ` Jakub Jelinek
2014-12-22 11:49       ` Thomas Schwinge
2014-12-22 12:50         ` Jakub Jelinek
2015-01-15 19:21           ` Ilya Verbin
2015-01-15 19:25             ` Jakub Jelinek
2015-01-28 17:28               ` Ilya Verbin
2015-01-28 17:42                 ` Jakub Jelinek
2015-01-28 17:51                   ` Ilya Verbin
2015-02-02 14:03                     ` Ilya Verbin
2014-12-26 20:53         ` Ilya Verbin
2015-01-08 16:03           ` Thomas Schwinge
2016-03-13 19:10   ` Thomas Schwinge

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).