data-3.f90 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. do i = 1, N
  16. b(i) = a(i)
  17. end do
  18. !$acc end parallel
  19. !$acc wait
  20. !$acc exit data copyout (a(1:N)) copyout (b(1:N))
  21. do i = 1, N
  22. if (a(i) .ne. 3.0) call abort
  23. if (b(i) .ne. 3.0) call abort
  24. end do
  25. a(:) = 2.0
  26. b(:) = 0.0
  27. !$acc enter data copyin (a(1:N)) copyin (b(1:N)) async (1)
  28. !$acc parallel async (1) wait (1)
  29. do i = 1, N
  30. b(i) = a(i)
  31. end do
  32. !$acc end parallel
  33. !$acc wait (1)
  34. !$acc exit data copyout (a(1:N)) copyout (b(1:N))
  35. do i = 1, N
  36. if (a(i) .ne. 2.0) call abort
  37. if (b(i) .ne. 2.0) call abort
  38. end do
  39. a(:) = 3.0
  40. b(:) = 0.0
  41. c(:) = 0.0
  42. d(:) = 0.0
  43. !$acc enter data copyin (a(1:N)) create (b(1:N)) create (c(1:N)) create (d(1:N))
  44. !$acc parallel async (1)
  45. do i = 1, N
  46. b(i) = (a(i) * a(i) * a(i)) / a(i)
  47. end do
  48. !$acc end parallel
  49. !$acc parallel async (1)
  50. do i = 1, N
  51. c(i) = (a(i) * 4) / a(i)
  52. end do
  53. !$acc end parallel
  54. !$acc parallel async (1)
  55. do i = 1, N
  56. d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
  57. end do
  58. !$acc end parallel
  59. !$acc wait (1)
  60. !$acc exit data copyout (a(1:N)) copyout (b(1:N)) copyout (c(1:N)) copyout (d(1:N))
  61. do i = 1, N
  62. if (a(i) .ne. 3.0) call abort
  63. if (b(i) .ne. 9.0) call abort
  64. if (c(i) .ne. 4.0) call abort
  65. if (d(i) .ne. 1.0) call abort
  66. end do
  67. a(:) = 2.0
  68. b(:) = 0.0
  69. c(:) = 0.0
  70. d(:) = 0.0
  71. e(:) = 0.0
  72. !$acc enter data copyin (a(1:N)) create (b(1:N)) create (c(1:N)) create (d(1:N)) copyin (e(1:N))
  73. !$acc parallel async (1)
  74. do i = 1, N
  75. b(i) = (a(i) * a(i) * a(i)) / a(i)
  76. end do
  77. !$acc end parallel
  78. !$acc parallel async (1)
  79. do i = 1, N
  80. c(i) = (a(i) * 4) / a(i)
  81. end do
  82. !$acc end parallel
  83. !$acc parallel async (1)
  84. do i = 1, N
  85. d(i) = ((a(i) * a(i) + a(i)) / a(i)) - a(i)
  86. end do
  87. !$acc end parallel
  88. !$acc parallel wait (1) async (1)
  89. do i = 1, N
  90. e(i) = a(i) + b(i) + c(i) + d(i)
  91. end do
  92. !$acc end parallel
  93. !$acc wait (1)
  94. !$acc exit data copyout (a(1:N)) copyout (b(1:N)) copyout (c(1:N)) copyout (d(1:N)) copyout (e(1:N))
  95. !$acc exit data delete (N)
  96. do i = 1, N
  97. if (a(i) .ne. 2.0) call abort
  98. if (b(i) .ne. 4.0) call abort
  99. if (c(i) .ne. 4.0) call abort
  100. if (d(i) .ne. 1.0) call abort
  101. if (e(i) .ne. 11.0) call abort
  102. end do
  103. end program asyncwait