cancel-taskgroup-4.c 597 B

1234567891011121314151617181920212223242526272829303132
  1. /* { dg-do run } */
  2. /* { dg-set-target-env-var OMP_CANCELLATION "true" } */
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <omp.h>
  6. int
  7. main ()
  8. {
  9. int i;
  10. #pragma omp parallel
  11. {
  12. int c = 0;
  13. #pragma omp barrier
  14. #pragma omp master taskloop num_tasks (25) firstprivate (c)
  15. for (i = 0; i < 50; i++)
  16. {
  17. if (c && omp_get_cancellation ())
  18. abort ();
  19. #pragma omp cancellation point taskgroup
  20. usleep (30);
  21. if (i > 10)
  22. c = 1;
  23. #pragma omp cancel taskgroup if (i > 10)
  24. if (i > 10 && omp_get_cancellation ())
  25. abort ();
  26. }
  27. usleep (10);
  28. }
  29. return 0;
  30. }