task-detach-1.c 625 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* { dg-do run } */
  2. #include <omp.h>
  3. #include <assert.h>
  4. /* Test chaining of detached tasks, with each task fulfilling the
  5. completion event of the previous one. */
  6. int main (void)
  7. {
  8. omp_event_handle_t detach_event1, detach_event2;
  9. int x = 0, y = 0, z = 0;
  10. #pragma omp parallel
  11. #pragma omp single
  12. {
  13. #pragma omp task detach (detach_event1)
  14. x++;
  15. #pragma omp task detach (detach_event2)
  16. {
  17. y++;
  18. omp_fulfill_event (detach_event1);
  19. }
  20. #pragma omp task
  21. {
  22. z++;
  23. omp_fulfill_event (detach_event2);
  24. }
  25. }
  26. assert (x == 1);
  27. assert (y == 1);
  28. assert (z == 1);
  29. }