Files
clang-p2996/offload/test/offloading/fortran/target-use-dev-ptr.f90
agozillon f1178815d2 [Flang][OpenMP][MLIR] Implement close, present and ompx_hold modifiers for Flang maps (#129586)
This PR adds an initial implementation for the map modifiers close,
present and ompx_hold, primarily just required adding the appropriate
map type flags to the map type bits. In the case of ompx_hold it
required adding the map type to the OpenMP dialect. Close has a bit of a
problem when utilised with the ALWAYS map type on descriptors, so it is
likely we'll have to make sure close and always are not applied to the
descriptor simultaneously in the future when we apply always to the
descriptors to facilitate movement of descriptor information to device
for consistency, however, we may find an alternative to this with
further investigation. For the moment, it is a TODO/Note to keep track
of it.
2025-03-07 22:22:30 +01:00

38 lines
1.0 KiB
Fortran

! Basic test of use_device_ptr, checking if the appropriate
! addresses are maintained across target boundaries
! REQUIRES: clang, flang, amdgcn-amd-amdhsa
! RUN: %clang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
! RUN: %S/../../Inputs/target-use-dev-ptr.c -o target-use-dev-ptr_c.o
! RUN: %libomptarget-compile-fortran-generic target-use-dev-ptr_c.o
! RUN: %t | %fcheck-generic
program use_device_test
use iso_c_binding
interface
type(c_ptr) function get_ptr() BIND(C)
USE, intrinsic :: iso_c_binding
implicit none
end function get_ptr
integer(c_int) function check_result(host, dev) BIND(C)
USE, intrinsic :: iso_c_binding
implicit none
type(c_ptr), value, intent(in) :: host, dev
end function check_result
end interface
type(c_ptr) :: device_ptr, x
x = get_ptr()
device_ptr = x
!$omp target data map(tofrom: x) use_device_ptr(x)
device_ptr = x
!$omp end target data
print *, check_result(x, device_ptr)
end program use_device_test
! CHECK: SUCCESS