diff options
Diffstat (limited to 'libgomp/testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-1.c')
-rw-r--r-- | libgomp/testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-1.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-1.c new file mode 100644 index 00000000000..31e4366f88b --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-1.c @@ -0,0 +1,43 @@ +/* { dg-additional-options "-w" } */ + +#include <assert.h> + +/* Test of reduction on loop directive (vectors, private reduction + variable). */ + +int +main (int argc, char *argv[]) +{ + int i, j, arr[1024], out[32], res = 0, hres = 0; + + for (i = 0; i < 1024; i++) + arr[i] = i; + + #pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) \ + private(res) copyout(out) + { + #pragma acc loop gang + for (j = 0; j < 32; j++) + { + res = 0; + + #pragma acc loop vector reduction(+:res) + for (i = 0; i < 32; i++) + res += arr[j * 32 + i]; + + out[j] = res; + } + } + + for (j = 0; j < 32; j++) + { + hres = 0; + + for (i = 0; i < 32; i++) + hres += arr[j * 32 + i]; + + assert (out[j] == hres); + } + + return 0; +} |