target8.f90 634 B

12345678910111213141516171819202122232425262728293031323334
  1. ! { dg-do run }
  2. integer, parameter :: n = 1000
  3. integer, parameter :: c = 100
  4. integer :: i, j
  5. real :: a(n)
  6. do i = 1, n
  7. a(i) = i
  8. end do
  9. !$omp parallel
  10. !$omp single
  11. do i = 1, n, c
  12. !$omp task shared(a)
  13. !$omp target map(a(i:i+c-1))
  14. !$omp parallel do
  15. do j = i, i + c - 1
  16. a(j) = foo (a(j))
  17. end do
  18. !$omp end target
  19. !$omp end task
  20. end do
  21. !$omp end single
  22. !$omp end parallel
  23. do i = 1, n
  24. if (a(i) /= i + 1) call abort
  25. end do
  26. contains
  27. real function foo (x)
  28. !$omp declare target
  29. real, intent(in) :: x
  30. foo = x + 1
  31. end function foo
  32. end