2018-01-22 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / cancel-taskgroup-3.C
blobc897265ef8b47e7a467b9ec31db003f09a4aa031
1 // { dg-do run }
2 // { dg-set-target-env-var OMP_CANCELLATION "true" }
4 #include <unistd.h>
5 #include <omp.h>
6 #include "cancel-test.h"
8 void
9 foo ()
11   S a, b, c, d, e, f;
12   #pragma omp parallel private (c, d) firstprivate (e, f)
13   #pragma omp taskgroup
14   {
15     c.bump ();
16     e.bump ();
17     #pragma omp task firstprivate (b, f) private (d)
18     {
19       S h;
20       b.bump ();
21       d.bump ();
22       f.bump ();
23       #pragma omp cancel taskgroup
24       if (omp_get_cancellation ())
25         abort ();
26     }
27   }
28   #pragma omp parallel private (c, d) firstprivate (e, f)
29   {
30     #pragma omp barrier
31     #pragma omp single
32     #pragma omp taskgroup
33     {
34       int i;
35       c.bump ();
36       e.bump ();
37       for (i = 0; i < 50; i++)
38         #pragma omp task firstprivate (b, f) private (d)
39         {
40           S h;
41           b.bump ();
42           d.bump ();
43           f.bump ();
44           #pragma omp cancellation point taskgroup
45           usleep (30);
46           #pragma omp cancel taskgroup if (i > 5)
47         }
48     }
49     usleep (10);
50   }
53 int
54 main ()
56   foo ();
57   S::verify ();