1 // { dg-do run }
2 // { dg-set-target-env-var OMP_CANCELLATION "true" }
3
4 #include <unistd.h>
5 #include <omp.h>
6 #include "cancel-test.h"
7
8 void
foo()9 foo ()
10 {
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 }
51 }
52
53 int
main()54 main ()
55 {
56 foo ();
57 S::verify ();
58 }
59