depend-5.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include <stdlib.h>
  2. __attribute__((noinline, noclone)) void
  3. f1 (int ifval)
  4. {
  5. int x = 1, y = 2, z = 3;
  6. #pragma omp parallel
  7. #pragma omp single
  8. {
  9. #pragma omp task shared (x) depend(out: x)
  10. x = 2;
  11. #pragma omp task shared (x) depend(inout: x)
  12. {
  13. if (x != 2)
  14. abort ();
  15. x = 3;
  16. }
  17. #pragma omp task shared (x) depend(inout: x)
  18. {
  19. if (x != 3)
  20. abort ();
  21. x = 4;
  22. }
  23. #pragma omp task shared (z) depend(in: z)
  24. if (z != 3)
  25. abort ();
  26. #pragma omp task shared (z) depend(in: z)
  27. if (z != 3)
  28. abort ();
  29. #pragma omp task shared (z) depend(in: z)
  30. if (z != 3)
  31. abort ();
  32. #pragma omp task shared (z) depend(in: z)
  33. if (z != 3)
  34. abort ();
  35. #pragma omp task shared (z) depend(in: z)
  36. if (z != 3)
  37. abort ();
  38. #pragma omp task shared (z) depend(in: z)
  39. if (z != 3)
  40. abort ();
  41. #pragma omp task shared (y) depend(in: y)
  42. if (y != 2)
  43. abort ();
  44. #pragma omp task shared (y) depend(in: y)
  45. if (y != 2)
  46. abort ();
  47. #pragma omp task shared (y) depend(in: y)
  48. if (y != 2)
  49. abort ();
  50. #pragma omp task shared (y) depend(in: y)
  51. if (y != 2)
  52. abort ();
  53. #pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
  54. {
  55. if (x != 4 || y != 2)
  56. abort ();
  57. y = 3;
  58. }
  59. if (ifval == 0)
  60. {
  61. /* The above if (0) task should have waited till all
  62. the tasks with x and y dependencies finish. */
  63. if (x != 4 || y != 3)
  64. abort ();
  65. x = 5;
  66. y = 4;
  67. }
  68. #pragma omp task shared (z) depend(inout: z)
  69. {
  70. if (z != 3)
  71. abort ();
  72. z = 4;
  73. }
  74. #pragma omp task shared (z) depend(inout: z)
  75. {
  76. if (z != 4)
  77. abort ();
  78. z = 5;
  79. }
  80. #pragma omp taskwait
  81. if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4) || z != 5)
  82. abort ();
  83. #pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
  84. {
  85. if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4))
  86. abort ();
  87. }
  88. }
  89. }
  90. int
  91. main ()
  92. {
  93. f1 (0);
  94. f1 (1);
  95. return 0;
  96. }