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


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

Improve libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c (was: [gomp4] Some additional OpenACC reduction tests)


Hi!

Cesar didn't pick up my gomp-4_0-branch change in his recent trunk
commit, so here goes:

On Thu, 24 Mar 2016 17:57:55 +0100, I wrote:
> On Wed, 29 Jul 2015 18:23:12 +0100, Julian Brown <julian@codesourcery.com> wrote:
> > This is a set of 19 new tests for OpenACC reductions, covering several
> > ways of performing reductions over the parallel and loop directives
> > using gang or worker/vector level parallelism.
> 
> > --- /dev/null
> > +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c
> > @@ -0,0 +1,40 @@
> > +#include <assert.h>
> > +
> > +/* Test of reduction on both parallel and loop directives (workers and vectors
> > +   in gang-partitioned mode, int type with XOR).  */
> > +
> > +int
> > +main (int argc, char *argv[])
> > +{
> > +  int i, j, arr[32768], res = 0, hres = 0;
> > +
> > +  for (i = 0; i < 32768; i++)
> > +    arr[i] = i;
> > +
> > +  #pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) \
> > +		       reduction(^:res)
> > +  {
> > +    #pragma acc loop gang
> > +    for (j = 0; j < 32; j++)
> > +      {
> > +	#pragma acc loop worker vector reduction(^:res)
> > +	for (i = 0; i < 1024; i++)
> > +	  res ^= arr[j * 1024 + i];
> > +
> > +	#pragma acc loop worker vector reduction(^:res)
> > +	for (i = 0; i < 1024; i++)
> > +	  res ^= arr[j * 1024 + (1023 - i)];
> > +      }
> > +  }
> > +
> > +  for (j = 0; j < 32; j++)
> > +    for (i = 0; i < 1024; i++)
> > +      {
> > +        hres ^= arr[j * 1024 + i];
> > +	hres ^= arr[j * 1024 + (1023 - i)];
> > +      }
> > +
> > +  assert (res == hres);
> > +
> > +  return 0;
> > +}
> 
> [...] this test case [...]
> just happend to ;-) always pass, because apparently
> the two XOR loops' iterations just cancelled their values, so in the end,
> we'd always get an "unremarkable" result of zero for both res and hres.

Committed in r234897:

commit f87ba9cde3958ccbb1f2c8b9efec997a458efc16
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Apr 12 10:40:22 2016 +0000

    Improve libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c
    
    	libgomp/
    	* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c:
    	Make failure observable.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234897 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog                                                    | 5 +++++
 .../testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c  | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index b53dc6b..6071b23 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-12  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c:
+	Make failure observable.
+
 2016-04-12  Jakub Jelinek  <jakub@redhat.com>
 
 	* libgomp.h (struct gomp_target_task): Remove firstprivate_copies
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c
index a7a75a9..a339f32 100644
--- libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c
@@ -19,7 +19,7 @@ main (int argc, char *argv[])
       {
 	#pragma acc loop worker vector reduction(^:res)
 	for (i = 0; i < 1024; i++)
-	  res ^= arr[j * 1024 + i];
+	  res ^= 3 * arr[j * 1024 + i];
 
 	#pragma acc loop worker vector reduction(^:res)
 	for (i = 0; i < 1024; i++)
@@ -30,7 +30,7 @@ main (int argc, char *argv[])
   for (j = 0; j < 32; j++)
     for (i = 0; i < 1024; i++)
       {
-        hres ^= arr[j * 1024 + i];
+	hres ^= 3 * arr[j * 1024 + i];
 	hres ^= arr[j * 1024 + (1023 - i)];
       }
 


GrÃÃe
 Thomas


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