comparison gcc/testsuite/c-c++-common/goacc/reduction-1.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-additional-options "-fdump-tree-gimple" } */
2 /* Integer reductions. */
3
4 #define n 1000
5
6 int
7 main(void)
8 {
9 int i;
10 int 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 /* 'max' reductions. */
26 #pragma acc parallel
27 #pragma acc loop gang worker vector reduction (max:result)
28 for (i = 0; i < n; i++)
29 result = result > array[i] ? result : array[i];
30
31 /* 'min' reductions. */
32 #pragma acc parallel
33 #pragma acc loop gang worker vector reduction (min:result)
34 for (i = 0; i < n; i++)
35 result = result < array[i] ? result : array[i];
36
37 /* '&' reductions. */
38 #pragma acc parallel
39 #pragma acc loop gang worker vector reduction (&:result)
40 for (i = 0; i < n; i++)
41 result &= array[i];
42
43 /* '|' reductions. */
44 #pragma acc parallel
45 #pragma acc loop gang worker vector reduction (|:result)
46 for (i = 0; i < n; i++)
47 result |= array[i];
48
49 /* '^' reductions. */
50 #pragma acc parallel
51 #pragma acc loop gang worker vector reduction (^:result)
52 for (i = 0; i < n; i++)
53 result ^= array[i];
54
55 /* '&&' reductions. */
56 #pragma acc parallel
57 #pragma acc loop gang worker vector reduction (&&:lresult)
58 for (i = 0; i < n; i++)
59 lresult = lresult && (result > array[i]);
60
61 /* '||' reductions. */
62 #pragma acc parallel
63 #pragma acc loop gang worker vector reduction (||:lresult)
64 for (i = 0; i < n; i++)
65 lresult = lresult || (result > array[i]);
66
67 return 0;
68 }
69
70 /* Check that default copy maps are generated for loop reductions. */
71 /* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 7 "gimple" } } */
72 /* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */