| 1 |
! { dg-do run } |
| 2 |
! { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } |
| 3 |
|
| 4 |
! Fortran version of libgomp.oacc-c-c++-common/lib-59.c |
| 5 |
|
| 6 |
program main |
| 7 |
use iso_c_binding |
| 8 |
use openacc |
| 9 |
implicit none (type, external) |
| 10 |
|
| 11 |
integer(c_size_t), parameter :: N = 256 |
| 12 |
character(c_char), allocatable, target :: h_data(:) |
| 13 |
type(c_ptr) :: dptr, dptr_t |
| 14 |
integer(c_intptr_t) :: iptr, i |
| 15 |
|
| 16 |
allocate(h_data(0:N)) |
| 17 |
dptr = acc_malloc (N+1) |
| 18 |
|
| 19 |
call acc_map_data (h_data, dptr, N+1) |
| 20 |
|
| 21 |
! The following assumes sizeof(void*) being the same on host and device: |
| 22 |
do i = 0, N |
| 23 |
dptr_t = transfer (transfer(dptr, iptr) + i, dptr_t) |
| 24 |
if (.not. c_associated (acc_hostptr (dptr_t), c_loc (h_data(i)))) & |
| 25 |
stop 1 |
| 26 |
if (.not. c_associated (dptr_t, acc_deviceptr (h_data(i)))) & |
| 27 |
stop 2 |
| 28 |
end do |
| 29 |
|
| 30 |
call acc_unmap_data (h_data) |
| 31 |
|
| 32 |
do i = 0, N |
| 33 |
dptr_t = transfer (transfer(dptr, iptr) + i, dptr_t) |
| 34 |
if (c_associated (acc_hostptr (dptr_t))) & |
| 35 |
stop 3 |
| 36 |
if (c_associated (acc_deviceptr (h_data(i)))) & |
| 37 |
stop 4 |
| 38 |
end do |
| 39 |
|
| 40 |
call acc_free (dptr) |
| 41 |
|
| 42 |
deallocate (h_data) |
| 43 |
end |