1 #include <omp.h>
2 extern "C" void *memset (void *, int, __SIZE_TYPE__);
3 extern "C" void abort (void);
4
5 int e;
6
7 void
baz(int i,int * p,int j,int * q)8 baz (int i, int *p, int j, int *q)
9 {
10 if (p[0] != 1 || p[i] != 3 || q[0] != 2 || q[j] != 4)
11 #pragma omp atomic
12 e++;
13 }
14
15 void
foo(int i,int j)16 foo (int i, int j)
17 {
18 int p[i + 1];
19 int q[j + 1];
20 memset (p, 0, sizeof (p));
21 memset (q, 0, sizeof (q));
22 p[0] = 1;
23 p[i] = 3;
24 q[0] = 2;
25 q[j] = 4;
26 #pragma omp task firstprivate (p, q)
27 baz (i, p, j, q);
28 }
29
30 int
main()31 main ()
32 {
33 #pragma omp parallel num_threads (4)
34 foo (5 + omp_get_thread_num (), 7 + omp_get_thread_num ());
35 if (e)
36 abort ();
37 }
38