2019-10-30 11:33:58 +01:00
|
|
|
! { dg-do run }
|
2019-10-02 12:33:42 +02:00
|
|
|
! Test whether use_device_ptr properly handles OPTIONAL arguments
|
|
|
|
! (Only case of present arguments is tested)
|
|
|
|
program test_it
|
|
|
|
implicit none
|
|
|
|
integer, target :: ixx
|
|
|
|
integer, pointer :: ptr_i, ptr_null
|
|
|
|
|
|
|
|
ptr_i => ixx
|
|
|
|
call foo(ptr_i)
|
|
|
|
|
|
|
|
ptr_null => null()
|
|
|
|
call bar(ptr_null)
|
2019-11-11 10:19:29 +01:00
|
|
|
|
|
|
|
call foo_absent()
|
|
|
|
call bar_absent()
|
2019-10-02 12:33:42 +02:00
|
|
|
contains
|
|
|
|
subroutine foo(ii)
|
|
|
|
integer, pointer, optional :: ii
|
|
|
|
|
2019-10-30 11:33:58 +01:00
|
|
|
if (.not.present(ii)) stop 1
|
|
|
|
if (.not.associated(ii, ixx)) stop 2
|
2019-10-02 12:33:42 +02:00
|
|
|
!$omp target data map(to:ixx) use_device_ptr(ii)
|
2019-10-30 11:33:58 +01:00
|
|
|
if (.not.present(ii)) stop 3
|
|
|
|
if (.not.associated(ii)) stop 4
|
2019-10-02 12:33:42 +02:00
|
|
|
!$omp end target data
|
|
|
|
end subroutine foo
|
|
|
|
|
|
|
|
! For bar, it is assumed that a NULL ptr on the host maps to NULL on the device
|
|
|
|
subroutine bar(jj)
|
|
|
|
integer, pointer, optional :: jj
|
|
|
|
|
2019-10-30 11:33:58 +01:00
|
|
|
if (.not.present(jj)) stop 5
|
|
|
|
if (associated(jj)) stop 6
|
2019-10-02 12:33:42 +02:00
|
|
|
!$omp target data map(to:ixx) use_device_ptr(jj)
|
2019-10-30 11:33:58 +01:00
|
|
|
if (.not.present(jj)) stop 7
|
|
|
|
if (associated(jj)) stop 8
|
2019-10-02 12:33:42 +02:00
|
|
|
!$omp end target data
|
|
|
|
end subroutine bar
|
2019-11-11 10:19:29 +01:00
|
|
|
|
|
|
|
subroutine foo_absent(ii)
|
|
|
|
integer, pointer, optional :: ii
|
|
|
|
|
|
|
|
if (present(ii)) STOP 31
|
|
|
|
!$omp target data map(to:ixx) use_device_ptr(ii)
|
|
|
|
if (present(ii)) STOP 32
|
|
|
|
!$omp end target data
|
|
|
|
end subroutine foo_absent
|
|
|
|
|
|
|
|
! For bar, it is assumed that a NULL ptr on the host maps to NULL on the device
|
|
|
|
subroutine bar_absent(jj)
|
|
|
|
integer, pointer, optional :: jj
|
|
|
|
|
|
|
|
if (present(jj)) STOP 41
|
|
|
|
!$omp target data map(to:ixx) use_device_ptr(jj)
|
|
|
|
if (present(jj)) STOP 42
|
|
|
|
!$omp end target data
|
|
|
|
end subroutine bar_absent
|
2019-10-02 12:33:42 +02:00
|
|
|
end program test_it
|