depend-4.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <stdlib.h>
  2. #include <unistd.h>
  3. int
  4. main ()
  5. {
  6. #pragma omp parallel
  7. #pragma omp single
  8. {
  9. int x = 1, y = 2, z = 3;
  10. #pragma omp taskgroup
  11. {
  12. #pragma omp task shared (x, y, z) depend(inout: x, y) \
  13. depend (in: z) if (x > 10)
  14. {
  15. if (x != 1 || y != 2 || z != 3)
  16. abort ();
  17. x = 4;
  18. y = 5;
  19. }
  20. /* The above task has depend clauses, but no dependencies
  21. on earlier tasks, and is if (0), so must be scheduled
  22. immediately. */
  23. if (x != 4 || y != 5)
  24. abort ();
  25. }
  26. #pragma omp taskgroup
  27. {
  28. #pragma omp task shared (x, y) depend(in: x, y)
  29. {
  30. usleep (10000);
  31. if (x != 4 || y != 5 || z != 3)
  32. abort ();
  33. }
  34. #pragma omp task shared (x, y) depend(in: x, y)
  35. {
  36. usleep (10000);
  37. if (x != 4 || y != 5 || z != 3)
  38. abort ();
  39. }
  40. #pragma omp task shared (x, y, z) depend(inout: x, y) \
  41. depend (in: z) if (x > 10)
  42. {
  43. if (x != 4 || y != 5 || z != 3)
  44. abort ();
  45. x = 6;
  46. y = 7;
  47. }
  48. /* The above task has depend clauses, and may have dependencies
  49. on earlier tasks, while it is if (0), it can be deferred. */
  50. }
  51. if (x != 6 || y != 7)
  52. abort ();
  53. }
  54. return 0;
  55. }