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] |
Hi! 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; > +} Given the interpretation of the OpenACC specification that the current implementation of OpenACC reductions in GCC is base upon (which we're currently re-visiting), it had been neccessary to add data clauses next to parallel constructs' reduction clauses -- but not for this test case. I now found why; it 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. In gomp-4_0-branch r234461, I have now committed the following: commit 8fff8ae7117c21d6b4a701a63cdd4634950418d1 Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu Mar 24 16:54:55 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. Add data clause next to parallel construct's reduction clause. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@234461 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog.gomp | 6 ++++++ .../testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index 53ae315..b10ae94 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,3 +1,9 @@ +2016-03-24 Thomas Schwinge <thomas@codesourcery.com> + + * testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c: + Make failure observable. Add data clause next to parallel + construct's reduction clause. + 2016-03-11 Cesar Philippidis <cesar@codesourcery.com> * testsuite/libgomp.oacc-c-c++-common/vprop.c: New test. 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..5e4590f 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 @@ -12,14 +12,14 @@ main (int argc, char *argv[]) arr[i] = i; #pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) \ - reduction(^:res) + reduction(^:res) copy(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]; + 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
Attachment:
signature.asc
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |