public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Also test -O0 for OpenACC C, C++ offloading test cases
@ 2016-03-22 12:14 Thomas Schwinge
  2016-03-22 13:04 ` Thomas Schwinge
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Thomas Schwinge @ 2016-03-22 12:14 UTC (permalink / raw)
  To: gcc-patches, Jakub Jelinek

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

Hi!

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?

commit 879c8f6dcb9dad514fb3bf11c721fed37b6574be
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Mar 22 10:26:19 2016 +0100

    Also test -O0 for OpenACC C, C++ offloading test cases
    
    	libgomp/
    	* testsuite/libgomp.oacc-c++/c++.exp: Set up torture testing, use
    	gcc-dg-runtest.
    	* testsuite/libgomp.oacc-c/c.exp: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/acc-on-device-2.c: Specify
    	-fno-builtin-acc_on_device instead of -O0.
    	* testsuite/libgomp.oacc-c-c++-common/acc-on-device.c: Skip for
    	-O0.
    	* testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c:
    	Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-g-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-g-2.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-v-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/routine-v-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c: Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-2.c:
    	Don't specify -O2.
    	* testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-3.c:
    	Likewise.
    	* testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta.c:
    	Likewise.
---
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         | 29 +++++++++++++++++-----
 .../libgomp.oacc-c-c++-common/acc-on-device-2.c    |  5 ++--
 .../libgomp.oacc-c-c++-common/acc-on-device.c      |  3 ++-
 .../kernels-alias-ipa-pta-2.c                      |  2 +-
 .../kernels-alias-ipa-pta-3.c                      |  2 +-
 .../kernels-alias-ipa-pta.c                        |  2 +-
 .../libgomp.oacc-c-c++-common/loop-auto-1.c        |  4 ++-
 .../libgomp.oacc-c-c++-common/loop-dim-default.c   |  6 +++--
 .../testsuite/libgomp.oacc-c-c++-common/loop-g-1.c |  5 ++--
 .../testsuite/libgomp.oacc-c-c++-common/loop-g-2.c |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-gwv-1.c         |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-red-g-1.c       |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-red-gwv-1.c     |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-red-v-1.c       |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-red-v-2.c       |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-red-w-1.c       |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-red-w-2.c       |  5 ++--
 .../testsuite/libgomp.oacc-c-c++-common/loop-v-1.c |  5 ++--
 .../testsuite/libgomp.oacc-c-c++-common/loop-w-1.c |  5 ++--
 .../libgomp.oacc-c-c++-common/loop-wv-1.c          |  5 ++--
 .../libgomp.oacc-c-c++-common/routine-g-1.c        |  5 ++--
 .../libgomp.oacc-c-c++-common/routine-gwv-1.c      |  5 ++--
 .../libgomp.oacc-c-c++-common/routine-v-1.c        |  5 ++--
 .../libgomp.oacc-c-c++-common/routine-w-1.c        |  5 ++--
 .../libgomp.oacc-c-c++-common/routine-wv-1.c       |  5 ++--
 libgomp/testsuite/libgomp.oacc-c/c.exp             | 29 +++++++++++++++++-----
 26 files changed, 111 insertions(+), 56 deletions(-)

diff --git libgomp/testsuite/libgomp.oacc-c++/c++.exp libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 88b0269..bbdbe2f 100644
--- libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -2,6 +2,7 @@
 
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
+load_gcc_lib torture-options.exp
 
 global shlib_ext
 
@@ -13,13 +14,9 @@ if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
 
-# If a testcase doesn't have special options, use these.
-if ![info exists DEFAULT_CFLAGS] then {
-    set DEFAULT_CFLAGS "-O2"
-}
-
 # Initialize dg.
 dg-init
+torture-init
 
 # Turn on OpenACC.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
@@ -104,7 +101,26 @@ if { $lang_test_file_found } {
 
 	setenv ACC_DEVICE_TYPE $offload_target_openacc
 
-	dg-runtest $tests "$tagopt" "$libstdcxx_includes $DEFAULT_CFLAGS"
+	# To get better test coverage for device-specific code that is only
+	# ever used in offloading configurations, we'd like more thorough
+	# testing for test cases that deal with offloading, which most of all
+	# OpenACC test cases are.  We enable torture testing, but limit it to
+	# -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 {
+		set-torture-options [list \
+					 { -O2 } ]
+	    }
+	    default {
+		set-torture-options [list \
+					 { -O0 } \
+					 { -O2 } ]
+	    }
+	}
+
+	gcc-dg-runtest $tests "$tagopt" "$libstdcxx_includes"
     }
 }
 
@@ -112,4 +128,5 @@ if { $lang_test_file_found } {
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
 
 # All done.
+torture-finish
 dg-finish
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device-2.c libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device-2.c
index e5d9c36..bfcb67d 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device-2.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device-2.c
@@ -1,9 +1,8 @@
-/* { dg-additional-options "-O0" } */
+/* Test the acc_on_device library function. */
+/* { dg-additional-options "-fno-builtin-acc_on_device" } */
 
 #include <openacc.h>
 
-/* acc_on_device might not be folded at -O0, but it should work. */
-
 int main ()
 {
   int dev;
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c
index 88c000e..e0d8710 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
-/* { dg-additional-options "-O2" } */
+/* We don't expect this to work with optimizations disabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <openacc.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-2.c libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-2.c
index 0f323c8..e8d65df 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-2.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-2.c
@@ -1,4 +1,4 @@
-/* { dg-additional-options "-O2 -fipa-pta" } */
+/* { dg-additional-options "-fipa-pta" } */
 
 #include <stdlib.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-3.c libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-3.c
index 654e750..dd8ca87 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-3.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-3.c
@@ -1,4 +1,4 @@
-/* { dg-additional-options "-O2 -fipa-pta" } */
+/* { dg-additional-options "-fipa-pta" } */
 
 #include <stdlib.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta.c libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta.c
index 44d4fd2..50e7dc1 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta.c
@@ -1,4 +1,4 @@
-/* { dg-additional-options "-O2 -fipa-pta" } */
+/* { dg-additional-options "-fipa-pta" } */
 
 #include <stdlib.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c
index 4922c9c..e44d26e 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c
@@ -1,5 +1,7 @@
 /* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 #include <openacc.h>
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
index 36b882f..80e4363 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
@@ -1,5 +1,7 @@
-
-/* { dg-additional-options "-O2 -fopenacc-dim=16:16" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* { dg-additional-options "-fopenacc-dim=16:16" } */
 
 #include <openacc.h>
 #include <alloca.h>
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c
index 23c2a75..0c8e9ff 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c
index 1a93db3..2316ce3 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c
index 26b2df9..e05573f 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c
index c14bddd..17a27b1 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c
index 3de8b09..4566568 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c
index bae5c66..94c752f 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c
index ada92e3..3c8b4b8 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c
index 706d0d8..7616b19 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c
index a073ac8..5f0a439 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c
index b9ec95b..cdba658 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c
index 539e41d..a65d535 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c
index fcb9079..df1a9fc 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c
index 201dc72..b30424f 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c
index 8fc4cb5..b1cdfd0 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c
index fefeb93..c49f643 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c
index 01d1dc8..5806cb3 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c
index bd9f1df..49761ce 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
-/* { dg-additional-options "-O2" } */
+/* Dead code elimination for blocks guarded by acc_on_device () only works with
+   optimizations enabled.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 #include <stdio.h>
 
diff --git libgomp/testsuite/libgomp.oacc-c/c.exp libgomp/testsuite/libgomp.oacc-c/c.exp
index 5020e6a..b509a10 100644
--- libgomp/testsuite/libgomp.oacc-c/c.exp
+++ libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -13,14 +13,11 @@ if [info exists lang_include_flags] then {
 
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
-
-# If a testcase doesn't have special options, use these.
-if ![info exists DEFAULT_CFLAGS] then {
-    set DEFAULT_CFLAGS "-O2"
-}
+load_gcc_lib torture-options.exp
 
 # Initialize dg.
 dg-init
+torture-init
 
 # Turn on OpenACC.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
@@ -67,8 +64,28 @@ foreach offload_target_openacc $offload_targets_s_openacc {
 
     setenv ACC_DEVICE_TYPE $offload_target_openacc
 
-    dg-runtest $tests "$tagopt" $DEFAULT_CFLAGS
+    # To get better test coverage for device-specific code that is only
+    # ever used in offloading configurations, we'd like more thorough
+    # testing for test cases that deal with offloading, which most of all
+    # OpenACC test cases are.  We enable torture testing, but limit it to
+    # -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 {
+	    set-torture-options [list \
+				     { -O2 } ]
+	}
+	default {
+	    set-torture-options [list \
+				     { -O0 } \
+				     { -O2 } ]
+	}
+    }
+
+    gcc-dg-runtest $tests "$tagopt" ""
 }
 
 # All done.
+torture-finish
 dg-finish


Grüße
 Thomas

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

^ permalink raw reply	[flat|nested] 23+ messages in thread
* libgomp: Unconfuse offload plugins vs. offload targets
@ 2016-06-08 13:28 Thomas Schwinge
  2016-06-08 14:08 ` Jakub Jelinek
  0 siblings, 1 reply; 23+ messages in thread
From: Thomas Schwinge @ 2016-06-08 13:28 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches

Hi!

This got me confused recently, so I took the effort to clean it up.  OK
to commit?

commit 5a1b2d8440a459fd2c623ba76fd6cab478ada54f
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Jun 8 15:18:11 2016 +0200

    libgomp: Unconfuse offload plugins vs. offload targets
    
    	libgomp/
    	* plugin/configfrag.ac: Populate and AC_SUBST offload_plugins
    	instead of offload_targets, and AC_DEFINE_UNQUOTED OFFLOAD_PLUGINS
    	instead of OFFLOAD_TARGETS.
    	* target.c (gomp_target_init): Adjust to that.
    	* testsuite/lib/libgomp.exp: Likewise.
    	* testsuite/libgomp-test-support.exp.in: Likewise.
    	* Makefile.in: Regenerate.
    	* config.h.in: Regenerate.
    	* configure: Regenerate.
    	* testsuite/Makefile.in: Regenerate.
---
 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
[...]
diff --git libgomp/config.h.in libgomp/config.h.in
[...]
diff --git libgomp/configure libgomp/configure
[...]
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 48b9ab8..2b7e627 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -2474,9 +2474,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.  */
@@ -2493,7 +2493,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
[...]
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@"


Grüße
 Thomas

^ permalink raw reply	[flat|nested] 23+ messages in thread
* libgomp: In OpenACC testing, cycle though $offload_targets, and by default only build for the offload target that we're actually going to test
@ 2016-07-13 10:37 Thomas Schwinge
  0 siblings, 0 replies; 23+ messages in thread
From: Thomas Schwinge @ 2016-07-13 10:37 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches

Hi!

As discussed before, "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)".  For this reason it is
beneficial (that is, it is measurable in libgomp testing wall time) to
limit offload compilation to the one (in the OpenACC case) offload target
that we're actually going to test (that is, execute).  Another reason is
that -foffload=-fdump-tree-[...] produces clashes (that is,
unpredicatable outcome) in the file names of offload compilations' dump
files' names.  Here is a patch to implement that, to specify
-foffload=[...] during libgomp OpenACC testing.  As that has been
challenged before:

| [...] there actually is a difference between offload_plugins and
| offload_targets (for example, "intelmic"
| vs. "x86_64-intelmicemul-linux-gnu"), and I'm using both variables --
| to avoid having to translate the more specific
| "x86_64-intelmicemul-linux-gnu" (which we required in the test harness)
| into the less specific "intelmic" (for plugin loading) in
| libgomp/target.c.  I can do that, so that we can continue to use just a
| single offload_targets variable, but I consider that a less elegant
| solution.

OK for trunk?

commit 5fdb515826769ebb36bc5c49a3ffac4d17a8a589
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Jul 13 11:37:16 2016 +0200

    libgomp: In OpenACC testing, cycle though $offload_targets, and by default only build for the offload target that we're actually going to test
    
    	libgomp/
    	* plugin/configfrag.ac: Enumerate both offload plugins and offload
    	targets.
    	(OFFLOAD_PLUGINS): Renamed from OFFLOAD_TARGETS.
    	* target.c (gomp_target_init): Adjust to that.
    	* testsuite/lib/libgomp.exp: Likewise.
    	(offload_targets_s, offload_targets_s_openacc): Remove variables.
    	(offload_target_to_openacc_device_type): New proc.
    	(check_effective_target_openacc_nvidia_accel_selected)
    	(check_effective_target_openacc_host_selected): Examine
    	$openacc_device_type instead of $offload_target_openacc.
    	* Makefile.in: Regenerate.
    	* config.h.in: Likewise.
    	* configure: Likewise.
    	* testsuite/Makefile.in: Likewise.
    	* testsuite/libgomp.oacc-c++/c++.exp: Cycle through
    	$offload_targets (plus "disable") instead of
    	$offload_targets_s_openacc, and add "-foffload=$offload_target" to
    	tagopt.
    	* testsuite/libgomp.oacc-c/c.exp: Likewise.
    	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/Makefile.in                                |  1 +
 libgomp/config.h.in                                |  4 +-
 libgomp/configure                                  | 44 +++++++------
 libgomp/plugin/configfrag.ac                       | 39 +++++++-----
 libgomp/target.c                                   |  8 +--
 libgomp/testsuite/Makefile.in                      |  1 +
 libgomp/testsuite/lib/libgomp.exp                  | 72 ++++++++++------------
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         | 30 +++++----
 libgomp/testsuite/libgomp.oacc-c/c.exp             | 30 +++++----
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp | 22 ++++---
 10 files changed, 142 insertions(+), 109 deletions(-)

diff --git libgomp/Makefile.in libgomp/Makefile.in
index 88c8517..33be8c7 100644
--- libgomp/Makefile.in
+++ libgomp/Makefile.in
@@ -380,6 +380,7 @@ mkdir_p = @mkdir_p@
 multi_basedir = @multi_basedir@
 offload_additional_lib_paths = @offload_additional_lib_paths@
 offload_additional_options = @offload_additional_options@
+offload_plugins = @offload_plugins@
 offload_targets = @offload_targets@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
diff --git libgomp/config.h.in libgomp/config.h.in
index 226ac53..28f7b2d 100644
--- libgomp/config.h.in
+++ libgomp/config.h.in
@@ -98,8 +98,8 @@
    */
 #undef LT_OBJDIR
 
-/* Define to offload targets, separated by commas. */
-#undef OFFLOAD_TARGETS
+/* Define to offload plugins, separated by commas. */
+#undef OFFLOAD_PLUGINS
 
 /* Name of package */
 #undef PACKAGE
diff --git libgomp/configure libgomp/configure
index 8d03eb6..4baab20 100755
--- libgomp/configure
+++ libgomp/configure
@@ -633,6 +633,8 @@ PLUGIN_NVPTX_FALSE
 PLUGIN_NVPTX_TRUE
 offload_additional_lib_paths
 offload_additional_options
+offload_targets
+offload_plugins
 PLUGIN_HSA_LIBS
 PLUGIN_HSA_LDFLAGS
 PLUGIN_HSA_CPPFLAGS
@@ -646,7 +648,6 @@ PLUGIN_NVPTX_CPPFLAGS
 PLUGIN_NVPTX
 CUDA_DRIVER_LIB
 CUDA_DRIVER_INCLUDE
-offload_targets
 libtool_VERSION
 ac_ct_FC
 FCFLAGS
@@ -11145,7 +11146,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11148 "configure"
+#line 11149 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11251,7 +11252,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11254 "configure"
+#line 11255 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15140,8 +15141,6 @@ esac
 # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-offload_targets=
-
 plugin_support=yes
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlsym in -ldl" >&5
 $as_echo_n "checking for dlsym in -ldl... " >&6; }
@@ -15320,7 +15319,13 @@ 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 and offload_targets will be
+# populated in the same order.
+offload_plugins=
+offload_targets=
+
+
 offload_additional_options=
 offload_additional_lib_paths=
 
@@ -15329,13 +15334,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
@@ -15373,7 +15378,7 @@ rm -f core conftest.err conftest.$ac_objext \
 	    ;;
 	esac
 	;;
-      hsa*)
+      hsa)
 	case "${target}" in
 	  x86_64-*-*)
 	    case " ${CC} ${CFLAGS} " in
@@ -15381,7 +15386,7 @@ rm -f core conftest.err conftest.$ac_objext \
 	        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"
@@ -15414,7 +15419,7 @@ rm -f core conftest.err conftest.$ac_objext \
 	        LDFLAGS=$PLUGIN_HSA_save_LDFLAGS
 	        LIBS=$PLUGIN_HSA_save_LIBS
 	        case $PLUGIN_HSA in
-	          hsa*)
+		  hsa)
 	            HSA_PLUGIN=0
 	            as_fn_error "HSA run-time package required for HSA support" "$LINENO" 5
 	            ;;
@@ -15431,16 +15436,19 @@ rm -f core conftest.err conftest.$ac_objext \
 	as_fn_error "unknown offload target specified" "$LINENO" 5
 	;;
     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
+      offload_targets=$tgt
     else
-      offload_targets=$offload_targets,$tgt_name
+      offload_plugins=$offload_plugins,$tgt_plugin
+      offload_targets=$offload_targets,$tgt
     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
@@ -15454,7 +15462,7 @@ rm -f core conftest.err conftest.$ac_objext \
 fi
 
 cat >>confdefs.h <<_ACEOF
-#define OFFLOAD_TARGETS "$offload_targets"
+#define OFFLOAD_PLUGINS "$offload_plugins"
 _ACEOF
 
  if test $PLUGIN_NVPTX = 1; then
diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac
index 88b4156..de0a6f6 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,13 @@ 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 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)
@@ -151,13 +155,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 +188,7 @@ if test x"$enable_offload_targets" != x; then
 	    ;;
 	esac
 	;;
-      hsa*)
+      hsa)
 	case "${target}" in
 	  x86_64-*-*)
 	    case " ${CC} ${CFLAGS} " in
@@ -192,7 +196,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 +218,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 +235,19 @@ 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
+      offload_targets=$tgt
     else
-      offload_targets=$offload_targets,$tgt_name
+      offload_plugins=$offload_plugins,$tgt_plugin
+      offload_targets=$offload_targets,$tgt
     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 +259,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 48b9ab8..2b7e627 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -2474,9 +2474,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.  */
@@ -2493,7 +2493,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
index 4dbb406..2092dcd 100644
--- libgomp/testsuite/Makefile.in
+++ libgomp/testsuite/Makefile.in
@@ -223,6 +223,7 @@ mkdir_p = @mkdir_p@
 multi_basedir = @multi_basedir@
 offload_additional_lib_paths = @offload_additional_lib_paths@
 offload_additional_options = @offload_additional_options@
+offload_plugins = @offload_plugins@
 offload_targets = @offload_targets@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 1cb4991..4a25421 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -36,28 +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_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 ","]
-set offload_targets_s_openacc {}
-foreach offload_target_openacc $offload_targets_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,9 +113,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
+    # Intel MIC offloading testing.
     global offload_targets
-    if { [string match "*,intelmic,*" ",$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
@@ -245,8 +223,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}"
@@ -322,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_ {
@@ -373,29 +372,22 @@ 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] } {
 	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 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
-    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.oacc-c++/c++.exp libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 608b298..befb921 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,15 @@ 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
+	# 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
 	# ever used in offloading configurations, we'd like more thorough
@@ -108,8 +116,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..5355b87 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,15 @@ 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
+    # 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
     # ever used in offloading configurations, we'd like more thorough
@@ -71,8 +79,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..8507b67 100644
--- libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -65,30 +65,38 @@ 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
+	# 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
 	# with arrays etc. that testing just -O0 or -O2 is insufficient, that is


Grüße
 Thomas

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

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

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22 12:14 Also test -O0 for OpenACC C, C++ offloading test cases Thomas Schwinge
2016-03-22 13:04 ` Thomas Schwinge
2016-03-23  0:03 ` Bernd Schmidt
2016-03-23  7:35   ` Thomas Schwinge
2016-03-23 19:19     ` Bernd Schmidt
2016-03-24 23:33       ` Thomas Schwinge
2016-03-29 13:35         ` Thomas Schwinge
2016-04-01  8:56         ` [gomp4] " Thomas Schwinge
2016-04-07 16:30           ` Thomas Schwinge
2016-04-08  8:33             ` [gomp4] [PR testsuite/70579, PR testsuite/70580] Fix test cases failing because of the compiler's "avoid offloading" decision (was: Also test -O0 for OpenACC C, C++ offloading test cases) Thomas Schwinge
2016-03-23 19:47 ` Also test -O0 for OpenACC C, C++ offloading test cases Jakub Jelinek
2016-03-25  1:05   ` check-target-libgomp wall time, without vs. with offloading (was: Also test -O0 for OpenACC C, C++ offloading test cases) Thomas Schwinge
2016-04-28 10:44     ` check-target-libgomp wall time, without vs. with offloading Thomas Schwinge
2016-04-29  7:43       ` Jakub Jelinek
2016-05-02  9:56         ` libgomp: In OpenACC testing, cycle though $offload_targets, and by default only build for the offload target that we're actually going to test (was: check-target-libgomp wall time, without vs. with offloading) Thomas Schwinge
2016-05-11 13:45           ` libgomp: In OpenACC testing, cycle though $offload_targets, and by default only build for the offload target that we're actually going to test Thomas Schwinge
2016-05-18 11:42             ` Thomas Schwinge
2016-05-25  8:50               ` Thomas Schwinge
2016-06-29  9:19                 ` [PING, two months] " Thomas Schwinge
2016-06-08 13:28 libgomp: Unconfuse offload plugins vs. offload targets Thomas Schwinge
2016-06-08 14:08 ` Jakub Jelinek
2016-06-08 15:46   ` Thomas Schwinge
2016-07-13 10:37 libgomp: In OpenACC testing, cycle though $offload_targets, and by default only build for the offload target that we're actually going to test 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).