libstdc++: AIX xfail for_overwrite.cc testcase
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / task-reduction-8.C
blob26737a32acbad88f485b124846e3f1a8a1edbc94
1 extern "C" void abort ();
3 int as;
4 int &a = as;
5 long int bs = 1;
6 long int &b = bs;
8 template <typename T, typename U>
9 void
10 foo (T &c, U &d)
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     }
24 template <typename T, typename U>
25 void
26 bar ()
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 reduction (task, +: a, c) reduction (task, *: b, d)
35     {
36       T i;
37       #pragma omp for
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     }
57 #define THREEP4 (3LL * 3LL * 3LL * 3LL)
58     if (d != (THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4 * THREEP4
59               * THREEP4))
60       abort ();
61   }
62   if (a != 28 * 7 || b != (1L << 28) || c != 28 * 9)
63     abort ();
66 int
67 main ()
69   bar<int, long long int> ();