This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: check-target-libgomp wall time, without vs. with offloading


Hi!

On Thu, 24 Mar 2016 22:42:10 +0100, I wrote:
> On Wed, 23 Mar 2016 20:02:01 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Tue, Mar 22, 2016 at 11:23:43AM +0100, Thomas Schwinge wrote:
> > > As discussed in
> > > <http://news.gmane.org/find-root.php?message_id=%3C87oaj3z280.fsf%40schwinge.name%3E>
> > > (and similar to what we're already doing for Fortran, and similar to what
> > > recently got committed to libgomp/testsuite/libgomp.hsa.c/c.exp), it has
> > > been helpful to also run C, C++ offloading test cases with -O0 in
> > > addition to the -O2 default.  Making my earlier gomp-4_0-branch patch
> > > conceptually simpler, I came up with the following; OK for trunk?
> > 
> > How big difference in make check-target-libgomp time is that?
> > Without PTX offloading I bet zero, but with PTX offloading configured, is it
> > 10% or 50% slower?
> 
> 15 %.  The major part of the total time is still spent in Fortran
> testing...  ;-/
> 
> Offloading compilation is slow; I suppose because of having to invoke
> several tools (LTO streaming -> mkoffload -> offload compilers,
> assemblers, linkers -> combine the resulting images; but I have not done
> a detailed analysis on that).

Here are three patches to improve that.  OK for gcc-6-branch and trunk?
Before:

    $ grep ^TIME < build-gcc/x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.log
    TIME 1461826886 START [...]/libgomp.c/c.exp
    TIME 1461827229 (343) END [...]/libgomp.c/c.exp
    TIME 1461827230 START [...]/libgomp.c++/c++.exp
    TIME 1461827522 (292) END [...]/libgomp.c++/c++.exp
    TIME 1461827522 START [...]/libgomp.fortran/fortran.exp
    TIME 1461828279 (757) END [...]/libgomp.fortran/fortran.exp
    TIME 1461828280 START [...]/libgomp.graphite/graphite.exp
    TIME 1461828284 (4) END [...]/libgomp.graphite/graphite.exp
    TIME 1461828284 START [...]/libgomp.hsa.c/c.exp
    TIME 1461828285 (1) END [...]/libgomp.hsa.c/c.exp
    TIME 1461828285 START [...]/libgomp.oacc-c/c.exp
    TIME 1461828866 (581) END [...]/libgomp.oacc-c/c.exp
    TIME 1461828866 START [...]/libgomp.oacc-c++/c++.exp
    TIME 1461829685 (819) END [...]/libgomp.oacc-c++/c++.exp
    TIME 1461829685 START [...]/libgomp.oacc-fortran/fortran.exp
    TIME 1461831119 (1434) END [...]/libgomp.oacc-fortran/fortran.exp

After:

    TIME 1461832444 START [...]/libgomp.c/c.exp
    TIME 1461832935 (491) END [...]/libgomp.c/c.exp
    TIME 1461832935 START [...]/libgomp.c++/c++.exp
    TIME 1461833275 (340) END [...]/libgomp.c++/c++.exp
    TIME 1461833275 START [...]/libgomp.fortran/fortran.exp
    TIME 1461833983 (708) END [...]/libgomp.fortran/fortran.exp
    TIME 1461833983 START [...]/libgomp.graphite/graphite.exp
    TIME 1461833986 (3) END [...]/libgomp.graphite/graphite.exp
    TIME 1461833986 START [...]/libgomp.hsa.c/c.exp
    TIME 1461833986 (0) END [...]/libgomp.hsa.c/c.exp
    TIME 1461833986 START [...]/libgomp.oacc-c/c.exp
    TIME 1461834423 (437) END [...]/libgomp.oacc-c/c.exp
    TIME 1461834423 START [...]/libgomp.oacc-c++/c++.exp
    TIME 1461834918 (495) END [...]/libgomp.oacc-c++/c++.exp
    TIME 1461834918 START [...]/libgomp.oacc-fortran/fortran.exp
    TIME 1461835533 (615) END [...]/libgomp.oacc-fortran/fortran.exp

This is on a rather busy system; my patch can't have any effect on
libgomp OpenMP offloading testing (which has taken longer in the second
run, due to higher system load); in light of this, the reduced duration
of OpenACC testing "shines" ;-) even better.

commit 3b521f3e35fdb4b320e95b5f6a82b8d89399481a
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Apr 21 11:36:39 2016 +0200

    libgomp: Unconfuse offload plugins vs. offload targets
---
 libgomp/Makefile.in                           |    2 +-
 libgomp/config.h.in                           |    4 +--
 libgomp/configure                             |   34 +++++++++++++------------
 libgomp/plugin/configfrag.ac                  |   34 +++++++++++++------------
 libgomp/target.c                              |    8 +++---
 libgomp/testsuite/Makefile.in                 |    2 +-
 libgomp/testsuite/lib/libgomp.exp             |   25 ++++++++----------
 libgomp/testsuite/libgomp-test-support.exp.in |    2 +-
 8 files changed, 56 insertions(+), 55 deletions(-)

diff --git libgomp/Makefile.in libgomp/Makefile.in
[snipped]
diff --git libgomp/config.h.in libgomp/config.h.in
[snipped]
diff --git libgomp/configure libgomp/configure
[snipped]
diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac
index 88b4156..93d3a71 100644
--- libgomp/plugin/configfrag.ac
+++ libgomp/plugin/configfrag.ac
@@ -26,8 +26,6 @@
 # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-offload_targets=
-AC_SUBST(offload_targets)
 plugin_support=yes
 AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
 if test x"$plugin_support" = xyes; then
@@ -142,7 +140,10 @@ AC_SUBST(PLUGIN_HSA_LIBS)
 
 
 
-# Get offload targets and path to install tree of offloading compiler.
+# Parse offload targets, and figure out libgomp plugin, and configure the
+# corresponding offload compiler.
+offload_plugins=
+AC_SUBST(offload_plugins)
 offload_additional_options=
 offload_additional_lib_paths=
 AC_SUBST(offload_additional_options)
@@ -151,13 +152,13 @@ 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/=.*//'`
-    tgt_name=
+    tgt_plugin=
     case $tgt in
       *-intelmic-* | *-intelmicemul-*)
-	tgt_name=intelmic
+	tgt_plugin=intelmic
 	;;
       nvptx*)
-        tgt_name=nvptx
+	tgt_plugin=nvptx
 	PLUGIN_NVPTX=$tgt
 	PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
 	PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
@@ -184,7 +185,7 @@ if test x"$enable_offload_targets" != x; then
 	    ;;
 	esac
 	;;
-      hsa*)
+      hsa)
 	case "${target}" in
 	  x86_64-*-*)
 	    case " ${CC} ${CFLAGS} " in
@@ -192,7 +193,7 @@ if test x"$enable_offload_targets" != x; then
 	        PLUGIN_HSA=0
 		;;
 	      *)
-	        tgt_name=hsa
+		tgt_plugin=hsa
 	        PLUGIN_HSA=$tgt
 	        PLUGIN_HSA_CPPFLAGS=$HSA_RUNTIME_CPPFLAGS
 	        PLUGIN_HSA_LDFLAGS="$HSA_RUNTIME_LDFLAGS $HSA_KMT_LDFLAGS"
@@ -214,7 +215,7 @@ if test x"$enable_offload_targets" != x; then
 	        LDFLAGS=$PLUGIN_HSA_save_LDFLAGS
 	        LIBS=$PLUGIN_HSA_save_LIBS
 	        case $PLUGIN_HSA in
-	          hsa*)
+		  hsa)
 	            HSA_PLUGIN=0
 	            AC_MSG_ERROR([HSA run-time package required for HSA support])
 	            ;;
@@ -231,16 +232,17 @@ if test x"$enable_offload_targets" != x; then
 	AC_MSG_ERROR([unknown offload target specified])
 	;;
     esac
-    if test x"$tgt_name" = x; then
+    if test x"$tgt_plugin" = x; then
       # Don't configure libgomp for this offloading target if we don't build
       # the corresponding plugin.
       continue
-    elif test x"$offload_targets" = x; then
-      offload_targets=$tgt_name
+    elif test x"$offload_plugins" = x; then
+      offload_plugins=$tgt_plugin
     else
-      offload_targets=$offload_targets,$tgt_name
+      offload_plugins=$offload_plugins,$tgt_plugin
     fi
-    if test "$tgt_name" = hsa; then
+    # Configure additional search paths.
+    if test "$tgt_plugin" = hsa; then
       # Offloading compilation is all handled by the target compiler.
       :
     elif test x"$tgt_dir" != x; then
@@ -252,8 +254,8 @@ if test x"$enable_offload_targets" != x; then
     fi
   done
 fi
-AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
-  [Define to offload targets, separated by commas.])
+AC_DEFINE_UNQUOTED(OFFLOAD_PLUGINS, "$offload_plugins",
+  [Define to offload plugins, separated by commas.])
 AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
 AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
   [Define to 1 if the NVIDIA plugin is built, 0 if not.])
diff --git libgomp/target.c libgomp/target.c
index e2dd0e0..c12c085 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -2467,9 +2467,9 @@ gomp_target_fini (void)
     }
 }
 
-/* This function initializes the runtime needed for offloading.
-   It parses the list of offload targets and tries to load the plugins for
-   these targets.  On return, the variables NUM_DEVICES and NUM_DEVICES_OPENMP
+/* This function initializes the runtime for offloading.
+   It parses the list of offload plugins, and tries to load these.
+   On return, the variables NUM_DEVICES and NUM_DEVICES_OPENMP
    will be set, and the array DEVICES initialized, containing descriptors for
    corresponding devices, first the GOMP_OFFLOAD_CAP_OPENMP_400 ones, follows
    by the others.  */
@@ -2486,7 +2486,7 @@ gomp_target_init (void)
   num_devices = 0;
   devices = NULL;
 
-  cur = OFFLOAD_TARGETS;
+  cur = OFFLOAD_PLUGINS;
   if (*cur)
     do
       {
diff --git libgomp/testsuite/Makefile.in libgomp/testsuite/Makefile.in
[snipped]
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 1cb4991..ae65e68 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -36,12 +36,11 @@ load_gcc_lib fortran-modules.exp
 # Try to load a test support file, built during libgomp configuration.
 load_file libgomp-test-support.exp
 
-# Populate offload_targets_s (offloading targets separated by a space), and
-# offload_targets_s_openacc (the same, but with OpenACC names; OpenACC spells
-# some of them a little differently).
-set offload_targets_s [split $offload_targets ","]
+# Populate offload_plugins_s (offloading plugins separated by a space), and
+# offload_targets_s_openacc (offload targets with OpenACC device type names).
+set offload_plugins_s [split $offload_plugins ","]
 set offload_targets_s_openacc {}
-foreach offload_target_openacc $offload_targets_s {
+foreach offload_target_openacc $offload_plugins_s {
     # Translate to OpenACC names, or skip if not yet supported.
     switch $offload_target_openacc {
 	intelmic {
@@ -135,9 +134,9 @@ proc libgomp_init { args } {
     set always_ld_library_path ".:${blddir}/.libs"
 
     # 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,"] } {
+    # Intel MIC offloading testing.
+    global offload_plugins
+    if { [string match "*,intelmic,*" ",$offload_plugins,"] } {
 	append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
 	append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
 	# libstdc++ is required by liboffloadmic
@@ -245,8 +244,7 @@ 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.
+    # Help GCC to find offload compilers' mkoffload.
     global offload_additional_options
     if { $offload_additional_options != "" } {
 	lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
@@ -373,9 +371,8 @@ proc check_effective_target_openacc_nvidia_accel_present { } {
     } "" ]
 }
 
-# Return 1 if at least one nvidia board is present, and the nvidia device type
-# is selected by default by means of setting the environment variable
-# ACC_DEVICE_TYPE.
+# Return 1 if at least one nvidia board is present, and the OpenACC "nvidia"
+# device type is selected.
 
 proc check_effective_target_openacc_nvidia_accel_selected { } {
     if { ![check_effective_target_openacc_nvidia_accel_present] } {
@@ -388,7 +385,7 @@ proc check_effective_target_openacc_nvidia_accel_selected { } {
     return 0;
 }
 
-# Return 1 if the host target is selected for offloaded
+# Return 1 if the OpenACC "host" device type is selected.
 
 proc check_effective_target_openacc_host_selected { } {
     global offload_target_openacc
diff --git libgomp/testsuite/libgomp-test-support.exp.in libgomp/testsuite/libgomp-test-support.exp.in
index 5a724fb..1068483 100644
--- libgomp/testsuite/libgomp-test-support.exp.in
+++ libgomp/testsuite/libgomp-test-support.exp.in
@@ -3,4 +3,4 @@ set cuda_driver_lib "@CUDA_DRIVER_LIB@"
 set hsa_runtime_lib "@HSA_RUNTIME_LIB@"
 set hsa_kmt_lib "@HSA_KMT_LIB@"
 
-set offload_targets "@offload_targets@"
+set offload_plugins "@offload_plugins@"

commit b7a0a14646663aaa25bf7c60e684317f935cd6ca
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Apr 21 14:29:21 2016 +0200

    libgomp: In OpenACC testing, cycle though $offload_target
    
    Conflicts:
    	libgomp/configure
---
 libgomp/Makefile.in                                |    1 +
 libgomp/configure                                  |   12 +++-
 libgomp/plugin/configfrag.ac                       |    7 ++-
 libgomp/testsuite/Makefile.in                      |    1 +
 libgomp/testsuite/lib/libgomp.exp                  |   61 +++++++++-----------
 libgomp/testsuite/libgomp-test-support.exp.in      |    2 +-
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         |   27 +++++----
 libgomp/testsuite/libgomp.oacc-c/c.exp             |   27 +++++----
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp |   19 +++---
 9 files changed, 90 insertions(+), 67 deletions(-)

diff --git libgomp/Makefile.in libgomp/Makefile.in
[snipped]
diff --git libgomp/configure libgomp/configure
[snipped]
diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac
index 93d3a71..de0a6f6 100644
--- libgomp/plugin/configfrag.ac
+++ libgomp/plugin/configfrag.ac
@@ -141,9 +141,12 @@ AC_SUBST(PLUGIN_HSA_LIBS)
 
 
 # Parse offload targets, and figure out libgomp plugin, and configure the
-# corresponding offload compiler.
+# corresponding offload compiler.  offload_plugins and offload_targets will be
+# populated in the same order.
 offload_plugins=
+offload_targets=
 AC_SUBST(offload_plugins)
+AC_SUBST(offload_targets)
 offload_additional_options=
 offload_additional_lib_paths=
 AC_SUBST(offload_additional_options)
@@ -238,8 +241,10 @@ if test x"$enable_offload_targets" != x; then
       continue
     elif test x"$offload_plugins" = x; then
       offload_plugins=$tgt_plugin
+      offload_targets=$tgt
     else
       offload_plugins=$offload_plugins,$tgt_plugin
+      offload_targets=$offload_targets,$tgt
     fi
     # Configure additional search paths.
     if test "$tgt_plugin" = hsa; then
diff --git libgomp/testsuite/Makefile.in libgomp/testsuite/Makefile.in
[snipped]
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index ae65e68..4a25421 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -36,27 +36,6 @@ load_gcc_lib fortran-modules.exp
 # Try to load a test support file, built during libgomp configuration.
 load_file libgomp-test-support.exp
 
-# Populate offload_plugins_s (offloading plugins separated by a space), and
-# offload_targets_s_openacc (offload targets with OpenACC device type names).
-set offload_plugins_s [split $offload_plugins ","]
-set offload_targets_s_openacc {}
-foreach offload_target_openacc $offload_plugins_s {
-    # Translate to OpenACC names, or skip if not yet supported.
-    switch $offload_target_openacc {
-	intelmic {
-	    continue
-	}
-	nvptx {
-	    set offload_target_openacc "nvidia"
-	}
-	hsa {
-	    continue
-	}
-    }
-    lappend offload_targets_s_openacc "$offload_target_openacc"
-}
-lappend offload_targets_s_openacc "host"
-
 set dg-do-what-default run
 
 #
@@ -135,8 +114,8 @@ proc libgomp_init { args } {
 
     # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
     # Intel MIC offloading testing.
-    global offload_plugins
-    if { [string match "*,intelmic,*" ",$offload_plugins,"] } {
+    global 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
@@ -320,6 +299,28 @@ proc libgomp_option_proc { option } {
     }
 }
 
+# Translate offload target to OpenACC device type.  Return the empty string if
+# not suitable or not yet supported, and "host" for offload target "disable".
+proc offload_target_to_openacc_device_type { offload_target } {
+    switch -glob $offload_target {
+	disable {
+	    return "host"
+	}
+	hsa {
+	    return ""
+	}
+	*-intelmic* {
+	    return ""
+	}
+	nvptx* {
+	    return "nvidia"
+	}
+	default {
+	    error "Unknwon offload target: $offload_target"
+	}
+    }
+}
+
 # Return 1 if offload device is available.
 proc check_effective_target_offload_device { } {
     return [check_runtime_nocache offload_device_available_ {
@@ -378,21 +379,15 @@ proc check_effective_target_openacc_nvidia_accel_selected { } {
     if { ![check_effective_target_openacc_nvidia_accel_present] } {
 	return 0;
     }
-    global offload_target_openacc
-    if { $offload_target_openacc == "nvidia" } {
-        return 1;
-    }
-    return 0;
+    global openacc_device_type
+    return [string match "nvidia" $openacc_device_type]
 }
 
 # Return 1 if the OpenACC "host" device type is selected.
 
 proc check_effective_target_openacc_host_selected { } {
-    global offload_target_openacc
-    if { $offload_target_openacc == "host" } {
-        return 1;
-    }
-    return 0;
+    global openacc_device_type
+    return [string match "host" $openacc_device_type]
 }
 
 # Return 1 if the selected OMP device is actually a HSA device
diff --git libgomp/testsuite/libgomp-test-support.exp.in libgomp/testsuite/libgomp-test-support.exp.in
index 1068483..5a724fb 100644
--- libgomp/testsuite/libgomp-test-support.exp.in
+++ libgomp/testsuite/libgomp-test-support.exp.in
@@ -3,4 +3,4 @@ set cuda_driver_lib "@CUDA_DRIVER_LIB@"
 set hsa_runtime_lib "@HSA_RUNTIME_LIB@"
 set hsa_kmt_lib "@HSA_KMT_LIB@"
 
-set offload_plugins "@offload_plugins@"
+set offload_targets "@offload_targets@"
diff --git libgomp/testsuite/libgomp.oacc-c++/c++.exp libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 608b298..7c8a29b 100644
--- libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -70,18 +70,23 @@ if { $lang_test_file_found } {
 	set libstdcxx_includes ""
     }
 
-    # Test OpenACC with available accelerators.
-    foreach offload_target_openacc $offload_targets_s_openacc {
-	set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
+    # Test with all offload targets, and with offloading disabled.
+    foreach offload_target [concat [split $offload_targets ","] "disable"] {
+	set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
+	set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
 
-	switch $offload_target_openacc {
-	    host {
+	switch $openacc_device_type {
+	    "" {
+		untested "$subdir $offload_target offloading"
+		continue
+	    }
+	    "host" {
 		set acc_mem_shared 1
 	    }
-	    nvidia {
+	    "nvidia" {
 		if { ![check_effective_target_openacc_nvidia_accel_present] } {
 		    # Don't bother; execution testing is going to FAIL.
-		    untested "$subdir $offload_target_openacc offloading"
+		    untested "$subdir $offload_target offloading"
 		    continue
 		}
 
@@ -94,12 +99,12 @@ if { $lang_test_file_found } {
 		set acc_mem_shared 0
 	    }
 	    default {
-		set acc_mem_shared 0
+		error "Unknwon OpenACC device type: $openacc_device_type (offload target: $offload_target)"
 	    }
 	}
 	set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
 
-	setenv ACC_DEVICE_TYPE $offload_target_openacc
+	setenv ACC_DEVICE_TYPE $openacc_device_type
 
 	# To get better test coverage for device-specific code that is only
 	# ever used in offloading configurations, we'd like more thorough
@@ -108,8 +113,8 @@ if { $lang_test_file_found } {
 	# -O0 and -O2 only, to avoid testing times exploding too much, under
 	# the assumption that between -O0 and -O[something] there is the
 	# biggest difference in the overall structure of the generated code.
-	switch $offload_target_openacc {
-	    host {
+	switch $offload_target {
+	    "disable" {
 		set-torture-options [list \
 					 { -O2 } ]
 	    }
diff --git libgomp/testsuite/libgomp.oacc-c/c.exp libgomp/testsuite/libgomp.oacc-c/c.exp
index b509a10..3f9a3c6 100644
--- libgomp/testsuite/libgomp.oacc-c/c.exp
+++ libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -31,20 +31,25 @@ set ld_library_path $always_ld_library_path
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
 
-# Test OpenACC with available accelerators.
+# Test with all offload targets, and with offloading disabled.
 set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
-foreach offload_target_openacc $offload_targets_s_openacc {
+foreach offload_target [concat [split $offload_targets ","] "disable"] {
     set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
-    set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
+    set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
+    set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
 
-    switch $offload_target_openacc {
-	host {
+    switch $openacc_device_type {
+	"" {
+	    untested "$subdir $offload_target offloading"
+	    continue
+	}
+	"host" {
 	    set acc_mem_shared 1
 	}
-	nvidia {
+	"nvidia" {
 	    if { ![check_effective_target_openacc_nvidia_accel_present] } {
 		# Don't bother; execution testing is going to FAIL.
-		untested "$subdir $offload_target_openacc offloading"
+		untested "$subdir $offload_target offloading"
 		continue
 	    }
 
@@ -57,12 +62,12 @@ foreach offload_target_openacc $offload_targets_s_openacc {
 	    set acc_mem_shared 0
 	}
 	default {
-	    set acc_mem_shared 0
+	    error "Unknwon OpenACC device type: $openacc_device_type (offload target: $offload_target)"
 	}
     }
     set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
 
-    setenv ACC_DEVICE_TYPE $offload_target_openacc
+    setenv ACC_DEVICE_TYPE $openacc_device_type
 
     # To get better test coverage for device-specific code that is only
     # ever used in offloading configurations, we'd like more thorough
@@ -71,8 +76,8 @@ foreach offload_target_openacc $offload_targets_s_openacc {
     # -O0 and -O2 only, to avoid testing times exploding too much, under
     # the assumption that between -O0 and -O[something] there is the
     # biggest difference in the overall structure of the generated code.
-    switch $offload_target_openacc {
-	host {
+    switch $offload_target {
+	"disable" {
 	    set-torture-options [list \
 				     { -O2 } ]
 	}
diff --git libgomp/testsuite/libgomp.oacc-fortran/fortran.exp libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 2d6b647..7ce92c0 100644
--- libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -65,30 +65,35 @@ if { $lang_test_file_found } {
     append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
     set_ld_library_path_env_vars
 
-    # Test OpenACC with available accelerators.
-    foreach offload_target_openacc $offload_targets_s_openacc {
-	set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
+    # Test with all offload targets, and with offloading disabled.
+    foreach offload_target [concat [split $offload_targets ","] "disable"] {
+	set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
+	set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
 
-	switch $offload_target_openacc {
+	switch $openacc_device_type {
+	    "" {
+		untested "$subdir $offload_target offloading"
+		continue
+	    }
 	    host {
 		set acc_mem_shared 1
 	    }
 	    nvidia {
 		if { ![check_effective_target_openacc_nvidia_accel_present] } {
 		    # Don't bother; execution testing is going to FAIL.
-		    untested "$subdir $offload_target_openacc offloading"
+		    untested "$subdir $offload_target offloading"
 		    continue
 		}
 
 		set acc_mem_shared 0
 	    }
 	    default {
-		set acc_mem_shared 0
+		error "Unknwon OpenACC device type: $openacc_device_type (offload target: $offload_target)"
 	    }
 	}
 	set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
 
-	setenv ACC_DEVICE_TYPE $offload_target_openacc
+	setenv ACC_DEVICE_TYPE $openacc_device_type
 
 	# For Fortran we're doing torture testing, as Fortran has far more tests
 	# with arrays etc. that testing just -O0 or -O2 is insufficient, that is

commit 08ee4f41d0ec562f7f2f7310b3439fe46c1dd0b4
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Apr 21 15:10:08 2016 +0200

    libgomp: In OpenACC testing, by default only build for the offload target that we're actually going to test
---
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         |    3 +++
 libgomp/testsuite/libgomp.oacc-c/c.exp             |    3 +++
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp |    3 +++
 3 files changed, 9 insertions(+)

diff --git libgomp/testsuite/libgomp.oacc-c++/c++.exp libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 7c8a29b..befb921 100644
--- libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -104,6 +104,9 @@ if { $lang_test_file_found } {
 	}
 	set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
 
+	# To avoid overhead, by default only build for the offload target that
+	# we're actually going to test.
+	set tagopt "$tagopt -foffload=$offload_target"
 	setenv ACC_DEVICE_TYPE $openacc_device_type
 
 	# To get better test coverage for device-specific code that is only
diff --git libgomp/testsuite/libgomp.oacc-c/c.exp libgomp/testsuite/libgomp.oacc-c/c.exp
index 3f9a3c6..5355b87 100644
--- libgomp/testsuite/libgomp.oacc-c/c.exp
+++ libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -67,6 +67,9 @@ foreach offload_target [concat [split $offload_targets ","] "disable"] {
     }
     set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
 
+    # To avoid overhead, by default only build for the offload target that
+    # we're actually going to test.
+    set tagopt "$tagopt -foffload=$offload_target"
     setenv ACC_DEVICE_TYPE $openacc_device_type
 
     # To get better test coverage for device-specific code that is only
diff --git libgomp/testsuite/libgomp.oacc-fortran/fortran.exp libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 7ce92c0..8507b67 100644
--- libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -93,6 +93,9 @@ if { $lang_test_file_found } {
 	}
 	set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
 
+	# To avoid overhead, by default only build for the offload target that
+	# we're actually going to test.
+	set tagopt "$tagopt -foffload=$offload_target"
 	setenv ACC_DEVICE_TYPE $openacc_device_type
 
 	# For Fortran we're doing torture testing, as Fortran has far more tests


For reference:

> I used the following patch to gather the
> [...] numbers:

> --- libgomp/testsuite/lib/libgomp-dg.exp
> +++ libgomp/testsuite/lib/libgomp-dg.exp
> @@ -1,3 +1,18 @@
> +rename dg-init dg-init_
> +proc dg-init { } {
> +    dg-init_
> +    global CLOCK_START
> +    set CLOCK_START [clock seconds]
> +    verbose "TIME $CLOCK_START START [info script]" 0
> +}
> +rename dg-finish dg-finish_
> +proc dg-finish { } {
> +    dg-finish_
> +    set CLOCK [clock seconds]
> +    global CLOCK_START
> +    verbose "TIME $CLOCK ([expr $CLOCK - $CLOCK_START]) END [info script]" 0
> +}
> +
>  proc libgomp-dg-test { prog do_what extra_tool_flags } {
>      return [gcc-dg-test-1 libgomp_target_compile $prog $do_what $extra_tool_flags]
>  }


GrÃÃe
 Thomas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]