Re: Also test -O0 for OpenACC C, C++ offloading test cases

2016-03-29 Thread Thomas Schwinge
Hi!

On Thu, 24 Mar 2016 22:31:29 +0100, I wrote:
> --- libgomp/testsuite/libgomp.oacc-c++/c++.exp
> +++ libgomp/testsuite/libgomp.oacc-c++/c++.exp

>  # 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

In a nvptx-none configuration (that is, without libstdc++), this caused:

 Running [...]/libgomp/testsuite/libgomp.oacc-c++/c++.exp ...
+ERROR: tcl error sourcing [...]/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+ERROR: torture-finish: torture_without_loops is not defined
+while executing
+"error "torture-finish: torture_without_loops is not defined""
+invoked from within
+"if [info exists torture_without_loops] {
+  unset torture_without_loops
+} else {
+  error "torture-finish: torture_without_loops is not defined"
+}"
+(procedure "torture-finish" line 4)
+invoked from within
+"torture-finish"
+(file "[...]/libgomp/testsuite/libgomp.oacc-c++/c++.exp" line 131)
+invoked from within
+"source [...]/libgomp/testsuite/libgomp.oacc-c++/c++.exp"
+("uplevel" body line 1)
+invoked from within
+"uplevel #0 source [...]/libgomp/testsuite/libgomp.oacc-c++/c++.exp"
+invoked from within
+"catch "uplevel #0 source $test_file_name""
 Running [...]/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp ...

torture_with_loops and torture_without_loops are set in
gcc/testsuite/lib/torture-options.exp:set-torture-options -- which we
don't call in libgomp.oacc-c++/c++.exp if skipping C++ testing.  As
obvious, fixed in r234519 as follows:

commit 53c452eee566d997bdef3ee0b20e7bb4485d77a4
Author: tschwinge 
Date:   Tue Mar 29 13:24:22 2016 +

Avoid ERROR in libgomp.oacc-c++/c++.exp in non-C++ configurations

libgomp/
* testsuite/libgomp.oacc-c++/c++.exp [!lang_test_file_found]: Call
set-torture-options.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234519 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog  |5 +
 libgomp/testsuite/libgomp.oacc-c++/c++.exp |4 
 2 files changed, 9 insertions(+)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index e0cd567..f4f30fb 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2016-03-29  Thomas Schwinge  
+
+   * testsuite/libgomp.oacc-c++/c++.exp [!lang_test_file_found]: Call
+   set-torture-options.
+
 2016-03-24  Thomas Schwinge  
 
* testsuite/libgomp.oacc-c++/c++.exp: Set up torture testing, use
diff --git libgomp/testsuite/libgomp.oacc-c++/c++.exp 
libgomp/testsuite/libgomp.oacc-c++/c++.exp
index bbdbe2f..608b298 100644
--- libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -122,6 +122,10 @@ if { $lang_test_file_found } {
 
gcc-dg-runtest $tests "$tagopt" "$libstdcxx_includes"
 }
+} else {
+# Call this once, which placates the subsequent torture-finish.
+set-torture-options [list \
+{ INVALID } ]
 }
 
 # See above.


Grüße
 Thomas


Re: Also test -O0 for OpenACC C, C++ offloading test cases

2016-03-24 Thread Thomas Schwinge
Hi!

On Wed, 23 Mar 2016 19:57:50 +0100, Bernd Schmidt  wrote:
> Ok with [...].

Thanks for the review; committed in r234471:

commit 02662647911b3296b07d7f4e3e3ed0200619da48
Author: tschwinge 
Date:   Thu Mar 24 21:29:55 2016 +

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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234471 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog  | 36 ++
 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|  5 +--
 .../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 +
 27 files changed, 147 insertions(+), 57 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index 5f2c401..e0cd567 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,39 @@
+2016-03-24  Thomas Schwinge  
+
+   * 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.
+   * 

Re: Also test -O0 for OpenACC C, C++ offloading test cases

2016-03-23 Thread Jakub Jelinek
On Tue, Mar 22, 2016 at 11:23:43AM +0100, Thomas Schwinge wrote:
> As discussed in
> 
> (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?

Jakub


Re: Also test -O0 for OpenACC C, C++ offloading test cases

2016-03-23 Thread Bernd Schmidt

On 03/23/2016 07:47 AM, Thomas Schwinge wrote:

Want me to re-word that?  :-| I thought it would be obvious from looking
at the test case code; will not be a problem in practice.  It's because
of constructs used in the test cases, like the following, for example:



   if (__builtin_acc_on_device (5))
 {
   int g = 0, w = 0, v = 0;

   __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
   __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
   __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
   ary[ix] = (g << 16) | (w << 8) | v;


Ok, maybe write "This code uses nvptx assembly guarded with 
__builtin_acc_on_device, which fails to be optimized away at -O0."


Ok with something like that.


Bernd


Re: Also test -O0 for OpenACC C, C++ offloading test cases

2016-03-23 Thread Thomas Schwinge
Hi!

On Tue, 22 Mar 2016 23:52:11 +0100, Bernd Schmidt  wrote:
> On 03/22/2016 11:23 AM, Thomas Schwinge wrote:
> > --- 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" } { "" } } */
> 
> What exactly is going on with these? Do these tests fail with -O0, and 
> is that likely to be a problem in practice?

Want me to re-word that?  :-| I thought it would be obvious from looking
at the test case code; will not be a problem in practice.  It's because
of constructs used in the test cases, like the following, for example:

#pragma acc loop worker
  for (unsigned ix = 0; ix < N; ix++)
{
  if (__builtin_acc_on_device (5))
{
  int g = 0, w = 0, v = 0;

  __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
  __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
  __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
  ary[ix] = (g << 16) | (w << 8) | v;
}
  else
ary[ix] = ix;
}

Without optimizations, the target (x86_64) assembler will bail out seeing
the device (nvptx) inline assembly code, even if it's dead code always
because of the acc_on_device () conditional.

Long ago, my suggestion has been to have GCC provide builtin functions
for users to retrieve the number of gangs, workers, vectors, and the
current thread's IDs of these; not sure why Nathan didn't implement that?
(Should be easy to do -- want me to have a look at that, as a separate
patch?)


> Also, why remove the dg-do run?

Because that's the default anyway.


Grüße
 Thomas


Re: Also test -O0 for OpenACC C, C++ offloading test cases

2016-03-22 Thread Bernd Schmidt

On 03/22/2016 11:23 AM, Thomas Schwinge wrote:

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" } { "" } } */


What exactly is going on with these? Do these tests fail with -O0, and 
is that likely to be a problem in practice?


Also, why remove the dg-do run?


Bernd