data-4.f90 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ! { dg-do run }
  2. program asyncwait
  3. real, allocatable :: a(:), b(:), c(:), d(:), e(:)
  4. integer i, N
  5. N = 64
  6. allocate (a(N))
  7. allocate (b(N))
  8. allocate (c(N))
  9. allocate (d(N))
  10. allocate (e(N))
  11. a(:) = 3.0
  12. b(:) = 0.0
  13. !$acc enter data copyin (a(1:N)) copyin (b(1:N)) copyin (N) async
  14. !$acc parallel async wait
  15. !$acc loop
  16. do i = 1, N
  17. b(i) = a(i)
  18. end do
  19. !$acc end parallel
  20. !$acc update host (a(1:N), b(1:N)) async wait
  21. !$acc wait
  22. do i = 1, N
  23. if (a(i) .ne. 3.0) call abort
  24. if (b(i) .ne. 3.0) call abort
  25. end do
  26. a(:) = 2.0
  27. b(:) = 0.0
  28. !$acc update device (a(1:N), b(1:N)) async (1)
  29. !$acc parallel async (1) wait (1)
  30. !$acc loop
  31. do i = 1, N
  32. b(i) = a(i)
  33. end do
  34. !$acc end parallel
  35. !$acc update self (a(1:N), b(1:N)) async (1) wait (1)
  36. !$acc wait (1)
  37. do i = 1, N
  38. if (a(i) .ne. 2.0) call abort
  39. if (b(i) .ne. 2.0) call abort
  40. end do
  41. a(:) = 3.0
  42. b(:) = 0.0
  43. c(:) = 0.0
  44. d(:) = 0.0
  45. !$acc enter data copyin (c(1:N), d(1:N)) async (1)
  46. !$acc update device (a(1:N), b(1:N)) async (1)
  47. !$acc parallel async (1)
  48. do i = 1, N
  49. b(i) = (a(i) * a(i) * a(i)) / a(i)
  50. end do
  51. !$acc end parallel
  52. !$acc parallel async (1)
  53. do i = 1, N
  54. c(i) = (a(i) * 4) / a(i)
  55. end do
  56. !$acc end parallel
  57. !$acc parallel async (1)
  58. do i = 1, N
  59. d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
  60. end do
  61. !$acc end parallel
  62. !$acc update host (a(1:N), b(1:N), c(1:N), d(1:N)) async (1) wait (1)
  63. !$acc wait (1)
  64. do i = 1, N
  65. if (a(i) .ne. 3.0) call abort
  66. if (b(i) .ne. 9.0) call abort
  67. if (c(i) .ne. 4.0) call abort
  68. if (d(i) .ne. 1.0) call abort
  69. end do
  70. a(:) = 2.0
  71. b(:) = 0.0
  72. c(:) = 0.0
  73. d(:) = 0.0
  74. e(:) = 0.0
  75. !$acc enter data copyin (e(1:N)) async (1)
  76. !$acc update device (a(1:N), b(1:N), c(1:N), d(1:N)) async (1)
  77. !$acc parallel async (1)
  78. do i = 1, N
  79. b(i) = (a(i) * a(i) * a(i)) / a(i)
  80. end do
  81. !$acc end parallel
  82. !$acc parallel async (1)
  83. do i = 1, N
  84. c(i) = (a(i) * 4) / a(i)
  85. end do
  86. !$acc end parallel
  87. !$acc parallel async (1)
  88. do i = 1, N
  89. d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
  90. end do
  91. !$acc end parallel
  92. !$acc parallel wait (1) async (1)
  93. do i = 1, N
  94. e(i) = a(i) + b(i) + c(i) + d(i)
  95. end do
  96. !$acc end parallel
  97. !$acc update host (a(1:N), b(1:N), c(1:N), d(1:N), e(1:N)) async (1) wait (1)
  98. !$acc wait (1)
  99. !$acc exit data delete (N, a(1:N), b(1:N), c(1:N), d(1:N), e(1:N))
  100. do i = 1, N
  101. if (a(i) .ne. 2.0) call abort
  102. if (b(i) .ne. 4.0) call abort
  103. if (c(i) .ne. 4.0) call abort
  104. if (d(i) .ne. 1.0) call abort
  105. if (e(i) .ne. 11.0) call abort
  106. end do
  107. end program asyncwait