]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.c-c++-common/taskloop-reduction-3.c
* builtin-types.def (BT_FN_VOID_BOOL, BT_FN_VOID_SIZE_SIZE_PTR,
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.c-c++-common / taskloop-reduction-3.c
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 /* { dg-additional-options "-std=c99" { target c } } */
4 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
5 /* { dg-additional-options "-mavx" { target avx_runtime } } */
6
7 #define N 1024
8 long int u[N], m, n;
9
10 __attribute__((noipa)) void
11 foo (void)
12 {
13 int i;
14 #pragma omp taskloop simd reduction (+:m) grainsize (64)
15 for (i = 0; i < N; ++i)
16 m += u[i];
17 }
18
19 __attribute__((noipa)) void
20 bar (int x)
21 {
22 #pragma omp taskloop simd in_reduction (+:n) grainsize (64) nogroup
23 for (int i = (x & 1) * (N / 2); i < (x & 1) * (N / 2) + (N / 2); i++)
24 n += 2 * u[i];
25 }
26
27 int
28 main ()
29 {
30 int i;
31 for (i = 0; i < N; ++i)
32 u[i] = i;
33 #pragma omp parallel master
34 {
35 foo ();
36 #pragma omp taskgroup task_reduction (+:n)
37 {
38 bar (0);
39 bar (1);
40 }
41 }
42 if (m != (long)(N - 1) * (N / 2) || n != (long)(N - 1) * N)
43 __builtin_abort ();
44 return 0;
45 }