AVR: Assert minimal required bit width of section_common::flags.
[gcc.git] / libgomp / testsuite / libgomp.c / task-3.c
blob5657346bd15877f3e4351996b67f88721775f898
1 /* { dg-do run } */
3 #include <omp.h>
4 extern void abort ();
6 int l = 5;
8 int
9 foo (int i)
11 int j = 7;
12 const int k = 8;
13 #pragma omp task firstprivate (i) shared (j, l)
15 #pragma omp critical
17 j += i;
18 l += k;
21 i++;
22 #pragma omp task firstprivate (i) shared (j, l)
24 #pragma omp critical
26 j += i;
27 l += k;
30 i++;
31 #pragma omp task firstprivate (i) shared (j, l)
33 #pragma omp critical
35 j += i;
36 l += k;
39 i++;
40 #pragma omp task firstprivate (i) shared (j, l)
42 #pragma omp critical
44 j += i;
45 l += k;
48 i++;
49 #pragma omp taskwait
50 return (i != 8 * omp_get_thread_num () + 4
51 || j != 4 * i - 3
52 || k != 8);
55 int
56 main (void)
58 int r = 0;
59 #pragma omp parallel num_threads (4) reduction(+:r)
60 if (omp_get_num_threads () != 4)
62 #pragma omp master
63 l = 133;
65 else if (foo (8 * omp_get_thread_num ()))
66 r++;
67 if (r || l != 133)
68 abort ();
69 return 0;