optional-host_data.f90 767 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. ! Test the host_data construct with optional arguments.
  2. ! Based on host_data-1.f90.
  3. ! { dg-do run }
  4. ! { dg-additional-options "-cpp" }
  5. program test
  6. implicit none
  7. integer, target :: i
  8. integer, pointer :: ip, iph
  9. ! Assign the same targets
  10. ip => i
  11. iph => i
  12. call foo(iph)
  13. call foo(iph, ip)
  14. contains
  15. subroutine foo(iph, ip)
  16. integer, pointer :: iph
  17. integer, pointer, optional :: ip
  18. !$acc data copyin(i)
  19. !$acc host_data use_device(ip)
  20. ! Test how the pointers compare inside a host_data construct
  21. if (present(ip)) then
  22. #if ACC_MEM_SHARED
  23. if (.not. associated(ip, iph)) STOP 1
  24. #else
  25. if (associated(ip, iph)) STOP 2
  26. #endif
  27. end if
  28. !$acc end host_data
  29. !$acc end data
  30. end subroutine foo
  31. end program test