Debian Codegraph @

gcc/testsuite/c-c++-common/goacc/reduction-4.c

raw
1 /* { dg-additional-options "-fdump-tree-gimple" } */
2 /* complex reductions. */
3
4 #define n 1000
5
6 int
7 main(void)
8 {
9 int i;
10 __complex__ double result, array[n];
11 int lresult;
12
13 /* '+' reductions. */
14 #pragma acc parallel
15 #pragma acc loop gang worker vector reduction (+:result)
16 for (i = 0; i < n; i++)
17 result += array[i];
18
19 /* '*' reductions. */
20 #pragma acc parallel
21 #pragma acc loop gang worker vector reduction (*:result)
22 for (i = 0; i < n; i++)
23 result *= array[i];
24
25 /* '&&' reductions. */
26 #pragma acc parallel
27 #pragma acc loop gang worker vector reduction (&&:lresult)
28 for (i = 0; i < n; i++)
29 lresult = lresult && (__real__(result) > __real__(array[i]));
30
31 /* '||' reductions. */
32 #pragma acc parallel
33 #pragma acc loop gang worker vector reduction (||:lresult)
34 for (i = 0; i < n; i++)
35 lresult = lresult || (__real__(result) > __real__(array[i]));
36
37 return 0;
38 }
39
40 /* Check that default copy maps are generated for loop reductions. */
41 /* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
42 /* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */