OSDN Git Service

2010-04-13 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / libgomp / testsuite / libgomp.c / task-4.c
1 /* { dg-do run } */
2
3 #include <omp.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7 int e;
8
9 void __attribute__((noinline))
10 baz (int i, int *p, int j, int *q)
11 {
12   if (p[0] != 1 || p[i] != 3 || q[0] != 2 || q[j] != 4)
13     #pragma omp atomic
14       e++;
15 }
16
17 void __attribute__((noinline))
18 foo (int i, int j)
19 {
20   int p[i + 1];
21   int q[j + 1];
22   memset (p, 0, sizeof (p));
23   memset (q, 0, sizeof (q));
24   p[0] = 1;
25   p[i] = 3;
26   q[0] = 2;
27   q[j] = 4;
28   #pragma omp task firstprivate (p, q)
29     baz (i, p, j, q);
30 }
31
32 int
33 main (void)
34 {
35   #pragma omp parallel num_threads (4)
36     foo (5 + omp_get_thread_num (), 7 + omp_get_thread_num ());
37   if (e)
38     abort ();
39   return 0;
40 }