target6.f90 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ! { dg-do run }
  2. module target6
  3. contains
  4. subroutine foo (p, v, w, n)
  5. double precision, pointer :: p(:), v(:), w(:)
  6. double precision :: q(n)
  7. integer :: i, n
  8. !$omp target data if (n > 256) map (to: v(1:n), w(:n)) map (from: p(1:n), q)
  9. !$omp target if (n > 256)
  10. !$omp parallel do simd
  11. do i = 1, n
  12. p(i) = v(i) * w(i)
  13. q(i) = p(i)
  14. end do
  15. !$omp end target
  16. !$omp target update if (n > 256) from (p)
  17. do i = 1, n
  18. if (p(i) /= i * iand (i, 63)) call abort
  19. v(i) = v(i) + 1
  20. end do
  21. !$omp target update if (n > 256) to (v(1:n))
  22. !$omp target if (n > 256)
  23. !$omp parallel do simd
  24. do i = 1, n
  25. p(i) = v(i) * w(i)
  26. end do
  27. !$omp end target
  28. !$omp end target data
  29. do i = 1, n
  30. if (q(i) /= (v(i) - 1) * w(i)) call abort
  31. if (p(i) /= q(i) + w(i)) call abort
  32. end do
  33. end subroutine
  34. end module target6
  35. use target6, only : foo
  36. integer :: n, i
  37. double precision, pointer :: p(:), v(:), w(:)
  38. n = 10000
  39. allocate (p(n), v(n), w(n))
  40. do i = 1, n
  41. v(i) = i
  42. w(i) = iand (i, 63)
  43. end do
  44. call foo (p, v, w, n)
  45. do i = 1, n
  46. if (p(i) /= (i + 1) * iand (i, 63)) call abort
  47. end do
  48. deallocate (p, v, w)
  49. end