1 #include <assert.h>
2
3 /* Test of reduction on both parallel and loop directives (worker and
4 vector-partitioned loops individually in gang-partitioned mode, int
5 type). */
6
7 int
8 main (int argc, char *argv[])
9 {
10 int i, j, arr[32768], res = 0, hres = 0;
11
12 for (i = 0; i < 32768; i++)
13 arr[i] = i;
14
15 #pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) \
16 reduction(+:res) copy(res)
17 {
18 #pragma acc loop gang /* { dg-warning "nested loop in reduction needs reduction clause for 'res'" "TODO" } */
19 for (j = 0; j < 32; j++)
20 {
21 #pragma acc loop worker reduction(+:res)
22 for (i = 0; i < 1024; i++)
23 res += arr[j * 1024 + i];
24
25 #pragma acc loop vector reduction(+:res)
26 for (i = 1023; i >= 0; i--)
27 res += arr[j * 1024 + i];
28 }
29 }
30
31 for (j = 0; j < 32; j++)
32 for (i = 0; i < 1024; i++)
33 hres += arr[j * 1024 + i] * 2;
34
35 assert (res == hres);
36
37 return 0;
38 }