gcc/
[official-gcc.git] / libgomp / testsuite / libgomp.c / task-2.c
blobed6a09c355781ac9af740e49af6d07a564a5e041
1 extern void abort (void);
3 int
4 f1 (void)
6 int a = 6, e = 0;
7 int nested (int x)
9 return x + a;
11 #pragma omp task
13 int n = nested (5);
14 if (n != 11)
15 #pragma omp atomic
16 e += 1;
18 #pragma omp taskwait
19 return e;
22 int
23 f2 (void)
25 int a = 6, e = 0;
26 int nested (int x)
28 return x + a;
30 a = nested (4);
31 #pragma omp task
33 if (a != 10)
34 #pragma omp atomic
35 e += 1;
37 #pragma omp taskwait
38 return e;
41 int
42 main (void)
44 int e = 0;
45 #pragma omp parallel num_threads(4) reduction(+:e)
47 e += f1 ();
48 e += f2 ();
50 if (e)
51 abort ();
52 return 0;