Debian Codegraph @

libgomp/testsuite/libgomp.c++/task-reduction-15.C

raw
1 extern "C" void abort ();
2
3 int as;
4 int &a = as;
5 long int bs = 1;
6 long int &b = bs;
7
8 template <typename T, typename U>
9 void
10 foo (T &c, U &d)
11 {
12 T i;
13 for (i = 0; i < 2; i++)
14 #pragma omp task in_reduction (*: d) in_reduction (+: c) \
15 in_reduction (+: a) in_reduction (*: b)
16 {
17 a += 7;
18 b *= 2;
19 c += 9;
20 d *= 3;
21 }
22 }
23
24 template <typename T, typename U>
25 void
26 bar ()
27 {
28 T cs = 0;
29 T &c = cs;
30 U ds = 1;
31 #pragma omp parallel if (0)
32 {
33 U &d = ds;
34 #pragma omp parallel
35 {
36 T i;
37 #pragma omp for reduction (task, +: a, c) reduction (task, *: b, d)
38 for (i = 0; i < 4; i++)
39 #pragma omp task in_reduction (+: a, c) in_reduction (*: b, d)
40 {
41 T j;
42 a += 7;
43 b *= 2;
44 for (j = 0; j < 2; j++)
45 #pragma omp task in_reduction (+: a, c) in_reduction (*: b, d)
46 {
47 a += 7;
48 b *= 2;
49 c += 9;
50 d *= 3;
51 foo (c, d);
52 }
53 c += 9;
54 d *= 3;
55 }
56 #define THREEP4 (3LL * 3LL * 3LL * 3LL)
57 if (d != (THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4
58 * THREEP4))
59 abort ();
60 if (a != 28 * 7 || b != (1L << 28) || c != 28 * 9)
61 abort ();
62 }
63 }
64 if (a != 28 * 7 || b != (1L << 28) || c != 28 * 9)
65 abort ();
66 if (ds != (THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4
67 * THREEP4))
68 abort ();
69 }
70
71 int
72 main ()
73 {
74 bar<int, long long int> ();
75 }