map-1.f90 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. program map
  2. integer, parameter :: n = 20, c = 10
  3. integer :: i, a(n), b(n)
  4. a(:) = 0
  5. b(:) = 0
  6. ! COPY
  7. !$acc parallel copy (a)
  8. !$acc loop
  9. do i = 1, n
  10. a(i) = i
  11. end do
  12. !$acc end parallel
  13. do i = 1, n
  14. b(i) = i
  15. end do
  16. call check (a, b, n)
  17. ! COPYOUT
  18. a(:) = 0
  19. !$acc parallel copyout (a)
  20. !$acc loop
  21. do i = 1, n
  22. a(i) = i
  23. end do
  24. !$acc end parallel
  25. do i = 1, n
  26. if (a(i) .ne. b(i)) call abort
  27. end do
  28. call check (a, b, n)
  29. ! COPYIN
  30. a(:) = 0
  31. !$acc parallel copyout (a) copyin (b)
  32. !$acc loop
  33. do i = 1, n
  34. a(i) = i
  35. end do
  36. !$acc end parallel
  37. call check (a, b, n)
  38. ! PRESENT_OR_COPY
  39. !$acc parallel pcopy (a)
  40. !$acc loop
  41. do i = 1, n
  42. a(i) = i
  43. end do
  44. !$acc end parallel
  45. call check (a, b, n)
  46. ! PRESENT_OR_COPYOUT
  47. a(:) = 0
  48. !$acc parallel pcopyout (a)
  49. !$acc loop
  50. do i = 1, n
  51. a(i) = i
  52. end do
  53. !$acc end parallel
  54. call check (a, b, n)
  55. ! PRESENT_OR_COPYIN
  56. a(:) = 0
  57. !$acc parallel pcopyout (a) pcopyin (b)
  58. !$acc loop
  59. do i = 1, n
  60. a(i) = i
  61. end do
  62. !$acc end parallel
  63. call check (a, b, n)
  64. end program map
  65. subroutine check (a, b, n)
  66. integer :: n, a(n), b(n)
  67. integer :: i
  68. do i = 1, n
  69. if (a(i) .ne. b(i)) call abort
  70. end do
  71. end subroutine check