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

2016-04-08 Thread Thomas Schwinge
Hi!

On Thu, 7 Apr 2016 18:29:45 +0200, I wrote:
> On Fri, 1 Apr 2016 10:55:49 +0200, I wrote:
> > On Thu, 24 Mar 2016 22:31:29 +0100, I wrote:
> > > On Wed, 23 Mar 2016 19:57:50 +0100, Bernd Schmidt <bschm...@redhat.com> 
> > > wrote:
> > > > Ok with [...].
> > > 
> > > Thanks for the review; committed in r234471:
> > 
> > > Also test -O0 for OpenACC C, C++ offloading test cases
> > 
> > Merged into gomp-4_0-branch in r234664:
> 
> > --- libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
> > +++ libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
> > @@ -1,5 +1,6 @@
> >  /* { dg-do run { target openacc_nvidia_accel_selected } } */
> >  /* { dg-additional-options "-lcuda -lcublas -lcudart" } */
> > +/* { dg-xfail-run-if "TODO" { *-*-* } { "-O0" } { "" } } */
> >  
> >  #include 
> >  #include 
> 
> Filed <https://gcc.gnu.org/PR70579>.
> 
> > --- libgomp/testsuite/libgomp.oacc-c-c++-common/if-1.c
> > +++ libgomp/testsuite/libgomp.oacc-c-c++-common/if-1.c
> > @@ -1,3 +1,5 @@
> > +/* { dg-xfail-run-if "TODO" { *-*-* } { "-O0" } { "" } } */
> > +
> >  #include 
> >  #include 
> >  #include 
> 
> Filed <https://gcc.gnu.org/PR70580>.
> 
> The both PASS on trunk.
> 
> Currently unclear if it's the same underlying problem or not.

Committed to gomp-4_0-branch in r234823:

commit 8a56a354bea62a280ec46db00a8956184403ff6e
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Apr 8 08:31:40 2016 +

[PR testsuite/70579, PR testsuite/70580] Fix test cases failing because of 
the compiler's "avoid offloading" decision

libgomp/
PR testsuite/70579
PR testsuite/70580
* testsuite/libgomp.oacc-c-c++-common/host_data-1.c: Initialize
the runtime for acc_device_nvidia.
* testsuite/libgomp.oacc-c-c++-common/if-1.c: Cope with
"avoid offloading" situation.
* libgomp.texi (Enabling OpenACC): Elaborate on interactions of
"avoid offloading".

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@234823 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp |  11 +
 libgomp/libgomp.texi   |   9 +
 .../libgomp.oacc-c-c++-common/host_data-1.c|   4 +-
 libgomp/testsuite/libgomp.oacc-c-c++-common/if-1.c | 316 +++--
 4 files changed, 184 insertions(+), 156 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index f54de33..1c99026 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,3 +1,14 @@
+2016-04-08  Thomas Schwinge  <tho...@codesourcery.com>
+
+   PR testsuite/70579
+   PR testsuite/70580
+   * testsuite/libgomp.oacc-c-c++-common/host_data-1.c: Initialize
+   the runtime for acc_device_nvidia.
+   * testsuite/libgomp.oacc-c-c++-common/if-1.c: Cope with
+   "avoid offloading" situation.
+   * libgomp.texi (Enabling OpenACC): Elaborate on interactions of
+   "avoid offloading".
+
 2016-04-04  Thomas Schwinge  <tho...@codesourcery.com>
 
* testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Don't XFAIL.
diff --git libgomp/libgomp.texi libgomp/libgomp.texi
index 350fb82..7cb677c 100644
--- libgomp/libgomp.texi
+++ libgomp/libgomp.texi
@@ -1824,6 +1824,15 @@ the option @option{-foffload-force} to force offloading 
in such cases.
 Alternatively, offloading is also enabled if a specific device type is
 requested, in a call to @code{acc_init} or by setting the
 @env{ACC_DEVICE_TYPE} environment variable, for example.
+If you expect code to be offloaded no matter the overhead, for
+example, when preparing data on a non-shared memory offloading device
+for later use in an OpenACC @code{host_data} construct, be sure to
+force offloading, to get the device memory initialized.
+For example, if calling into the cuBLAS library (@ref{OpenACC Library
+Interoperability}) from an OpenACC @code{host_data} construct, this
+program is portable only to @code{acc_device_nvidia} devices, so it's
+good practice then to initialize the runtime with an explicit
+@code{acc_init (acc_device_nvidia)} call.
 
 A complete description of all OpenACC directives accepted may be found in 
 the @uref{http://www.openacc.org/, OpenACC} Application Programming
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c 
libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
index b97d877..d19aa20 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
@@ -1,6 +1,5 @@
 /* { dg-do run { target openacc_nvidia_accel_select

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

2016-04-07 Thread Thomas Schwinge
Hi!

On Fri, 1 Apr 2016 10:55:49 +0200, I wrote:
> On Thu, 24 Mar 2016 22:31:29 +0100, I wrote:
> > On Wed, 23 Mar 2016 19:57:50 +0100, Bernd Schmidt <bschm...@redhat.com> 
> > wrote:
> > > Ok with [...].
> > 
> > Thanks for the review; committed in r234471:
> 
> >     Also test -O0 for OpenACC C, C++ offloading test cases
> 
> Merged into gomp-4_0-branch in r234664:

> --- libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
> +++ libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
> @@ -1,5 +1,6 @@
>  /* { dg-do run { target openacc_nvidia_accel_selected } } */
>  /* { dg-additional-options "-lcuda -lcublas -lcudart" } */
> +/* { dg-xfail-run-if "TODO" { *-*-* } { "-O0" } { "" } } */
>  
>  #include 
>  #include 

Filed <https://gcc.gnu.org/PR70579>.

> --- libgomp/testsuite/libgomp.oacc-c-c++-common/if-1.c
> +++ libgomp/testsuite/libgomp.oacc-c-c++-common/if-1.c
> @@ -1,3 +1,5 @@
> +/* { dg-xfail-run-if "TODO" { *-*-* } { "-O0" } { "" } } */
> +
>  #include 
>  #include 
>  #include 

Filed <https://gcc.gnu.org/PR70580>.

The both PASS on trunk.

Currently unclear if it's the same underlying problem or not.


Grüße
 Thomas


signature.asc
Description: PGP signature


[gomp4] Also test -O0 for OpenACC C, C++ offloading test cases

2016-04-01 Thread Thomas Schwinge
Hi!

On Thu, 24 Mar 2016 22:31:29 +0100, I wrote:
> On Wed, 23 Mar 2016 19:57:50 +0100, Bernd Schmidt <bschm...@redhat.com> wrote:
> > Ok with [...].
> 
> Thanks for the review; committed in r234471:

> Also test -O0 for OpenACC C, C++ offloading test cases

Merged into gomp-4_0-branch in r234664:

commit 9973610b0d5cb41f380fa18eabacb5f967fe4d0e
Merge: e252cf1 0266264
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Apr 1 08:41:44 2016 +

svn merge -r 234469:234471 svn+ssh://gcc.gnu.org/svn/gcc/trunk


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@234664 
138bc75d-0d04-0410-961f-82ee72b054a4

 libgomp/ChangeLog  | 36 ++
 libgomp/testsuite/libgomp.oacc-c++/c++.exp | 55 +-
 .../libgomp.oacc-c-c++-common/acc-on-device-2.c|  5 +-
 .../libgomp.oacc-c-c++-common/acc-on-device.c  |  3 +-
 .../libgomp.oacc-c-c++-common/avoid-offloading-1.c |  3 ++
 .../libgomp.oacc-c-c++-common/avoid-offloading-2.c |  3 ++
 .../libgomp.oacc-c-c++-common/gang-static-2.c  |  4 +-
 .../libgomp.oacc-c-c++-common/host_data-1.c|  1 +
 libgomp/testsuite/libgomp.oacc-c-c++-common/if-1.c |  2 +
 .../libgomp.oacc-c-c++-common/loop-auto-1.c|  6 ++-
 .../loop-default-compile.c |  6 ++-
 .../loop-default-runtime.c |  6 ++-
 .../testsuite/libgomp.oacc-c-c++-common/loop-g-1.c |  6 ++-
 .../testsuite/libgomp.oacc-c-c++-common/loop-g-2.c |  6 ++-
 .../libgomp.oacc-c-c++-common/loop-gwv-1.c |  5 +-
 .../libgomp.oacc-c-c++-common/loop-red-g-1.c   |  6 ++-
 .../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   |  6 ++-
 .../libgomp.oacc-c-c++-common/loop-red-w-2.c   |  6 ++-
 .../libgomp.oacc-c-c++-common/loop-red-wv-1.c  |  5 +-
 .../testsuite/libgomp.oacc-c-c++-common/loop-v-1.c |  5 +-
 .../testsuite/libgomp.oacc-c-c++-common/loop-w-1.c |  6 ++-
 .../libgomp.oacc-c-c++-common/loop-wv-1.c  |  5 +-
 .../libgomp.oacc-c-c++-common/routine-3.c  |  8 ++--
 .../libgomp.oacc-c-c++-common/routine-g-1.c|  6 ++-
 .../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-vec-1.c  |  5 +-
 .../libgomp.oacc-c-c++-common/routine-w-1.c|  6 ++-
 .../libgomp.oacc-c-c++-common/routine-work-1.c |  6 ++-
 .../libgomp.oacc-c-c++-common/routine-wv-1.c   |  5 +-
 .../libgomp.oacc-c-c++-common/routine-wv-2.c   |  5 +-
 .../libgomp.oacc-c-c++-common/worker-partn-8.c |  2 -
 libgomp/testsuite/libgomp.oacc-c/c.exp | 54 +
 36 files changed, 187 insertions(+), 121 deletions(-)

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

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


check-target-libgomp wall time, without vs. with offloading (was: Also test -O0 for OpenACC C, C++ offloading test cases)

2016-03-24 Thread Thomas Schwinge
Hi!

On Wed, 23 Mar 2016 20:02:01 +0100, Jakub Jelinek <ja...@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).  I used the following patch to gather the
following numbers:

Baseline, without offloading:

TIME 1458823399 START [...]/libgomp.c/c.exp
TIME 1458823544 (145) END [...]/libgomp.c/c.exp
TIME 1458823544 START [...]/libgomp.c++/c++.exp
TIME 1458823672 (128) END [...]/libgomp.c++/c++.exp
TIME 1458823672 START [...]/libgomp.fortran/fortran.exp
TIME 1458824080 (408) END [...]/libgomp.fortran/fortran.exp
TIME 1458824080 START [...]/libgomp.graphite/graphite.exp
TIME 1458824083 (3) END [...]/libgomp.graphite/graphite.exp
TIME 1458824083 START [...]/libgomp.hsa.c/c.exp
TIME 1458824083 (0) END [...]/libgomp.hsa.c/c.exp
TIME 1458824084 START [...]/libgomp.oacc-c/c.exp
TIME 1458824109 (25) END [...]/libgomp.oacc-c/c.exp
TIME 1458824109 START [...]/libgomp.oacc-c++/c++.exp
TIME 1458824141 (32) END [...]/libgomp.oacc-c++/c++.exp
TIME 1458824141 START [...]/libgomp.oacc-fortran/fortran.exp
TIME 1458824215 (74) END [...]/libgomp.oacc-fortran/fortran.exp

Total: 680 s (OpenMP) + 130 s (OpenACC) = 810 s.

With OpenMP IntelMIC (emulated) and OpenACC nvptx offloading:

TIME 1458824215 START [...]/libgomp.c/c.exp
TIME 1458824461 (246) END [...]/libgomp.c/c.exp
TIME 1458824461 START [...]/libgomp.c++/c++.exp
TIME 1458824664 (203) END [...]/libgomp.c++/c++.exp
TIME 1458824664 START [...]/libgomp.fortran/fortran.exp
TIME 1458825269 (605) END [...]/libgomp.fortran/fortran.exp
TIME 1458825269 START [...]/libgomp.graphite/graphite.exp
TIME 1458825272 (3) END [...]/libgomp.graphite/graphite.exp
TIME 1458825273 START [...]/libgomp.hsa.c/c.exp
TIME 1458825273 (0) END [...]/libgomp.hsa.c/c.exp
TIME 1458825273 START [...]/libgomp.oacc-c/c.exp
TIME 1458825533 (260) END [...]/libgomp.oacc-c/c.exp
TIME 1458825533 START [...]/libgomp.oacc-c++/c++.exp
TIME 1458825860 (327) END [...]/libgomp.oacc-c++/c++.exp
TIME 1458825860 START [...]/libgomp.oacc-fortran/fortran.exp
TIME 1458826459 (599) END [...]/libgomp.oacc-fortran/fortran.exp

Total: 1050 s (OpenMP; + 54 %) + 1190 s (OpenACC; + 815 %) = 2240 s (+ 177 %).

Patched with "Also test -O0 for OpenACC C, C++ offloading test cases",
that results in the following changes (with offloading only):

TIME 1458834409 START [...]/libgomp.oacc-c/c.exp
TIME 1458834814 (405) END [...]/libgomp.oacc-c/c.exp
TIME 1458834814 START [...]/libgomp.oacc-c++/c++.exp
TIME 1458835338 (524) END [...]/libgomp.oacc-c++/c++.exp

Total: 1050 s (OpenMP) + 1530 s (OpenACC; + 29 %) = 2580 s (+ 15 %).

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


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 <bschm...@redhat.com> wrote:
> Ok with [...].

Thanks for the review; committed in r234471:

commit 02662647911b3296b07d7f4e3e3ed0200619da48
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
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  <tho...@codesourcery.com>
+
+   * 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-

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



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

2016-03-22 Thread Thomas Schwinge
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 <tho...@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.