PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / par-reduction-1.c
bloba88b60f39f0344617c335d6dcc9d4ae3c8c68746
1 /* { dg-additional-options "-w" } */
3 #include <assert.h>
5 /* Test of reduction on parallel directive. */
7 #define ACTUAL_GANGS 256
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(res2, res1)
22 res1 += 5;
24 #pragma acc atomic
25 res2 += 5;
27 res = GANGS * 5;
29 assert (res == res1);
30 assert (res == res2);
31 #undef GANGS
33 res = res1 = res2 = 1;
35 #if defined(ACC_DEVICE_TYPE_host)
36 # define GANGS 1
37 #else
38 # define GANGS 8
39 #endif
40 #pragma acc parallel num_gangs(GANGS) num_workers(32) vector_length(32) \
41 reduction(*:res1) copy(res1, res2)
43 res1 *= 5;
45 #pragma acc atomic
46 res2 *= 5;
48 for (int i = 0; i < GANGS; ++i)
49 res *= 5;
51 assert (res == res1);
52 assert (res == res2);
53 #undef GANGS
55 return 0;