Add support for ARMv8-R architecture
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / par-reduction-2.c
blob5ab52e97009386d03a568fb8d3c8408ec5b3b8fd
1 /* Test of reduction on parallel directive (with async). */
2 /* See also Fortran variants in "../libgomp.oacc-fortran/par-reduction-2*". */
4 /* { dg-additional-options "-w" } */
6 #include <assert.h>
7 #include <openacc.h>
9 int
10 main (int argc, char *argv[])
12 int res, res1 = 0, res2 = 0;
14 #if defined(ACC_DEVICE_TYPE_host)
15 # define GANGS 1
16 #else
17 # define GANGS 256
18 #endif
19 #pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
20 reduction(+:res1) copy(res1, res2) async(1)
22 res1 += 5;
24 #pragma acc atomic
25 res2 += 5;
27 res = GANGS * 5;
29 acc_async_wait (1);
31 assert (res == res1);
32 assert (res == res2);
33 #undef GANGS
35 res = res1 = res2 = 1;
37 #if defined(ACC_DEVICE_TYPE_host)
38 # define GANGS 1
39 #else
40 # define GANGS 8
41 #endif
42 #pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
43 reduction(*:res1) copy(res1, res2) async(1)
45 res1 *= 5;
47 #pragma acc atomic
48 res2 *= 5;
50 for (int i = 0; i < GANGS; ++i)
51 res *= 5;
53 acc_async_wait_all ();
55 assert (res == res1);
56 assert (res == res2);
58 return 0;