================
@@ -0,0 +1,46 @@
+! Validate that a device pointer obtained via omp_get_mapped_ptr can be used
+! inside a TARGET region with the is_device_ptr clause.
+! REQUIRES: flang, amdgcn-amd-amdhsa
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+
+program is_device_ptr_target
+  use iso_c_binding, only : c_ptr, c_loc
+  implicit none
+
+  interface
+    function omp_get_mapped_ptr(host_ptr, device_num)                       &
+        bind(C, name="omp_get_mapped_ptr")
+      use iso_c_binding, only : c_ptr, c_int
+      type(c_ptr) :: omp_get_mapped_ptr
+      type(c_ptr), value :: host_ptr
+      integer(c_int), value :: device_num
+    end function omp_get_mapped_ptr
+  end interface
+
+  integer, parameter :: n = 4
+  integer, parameter :: dev = 0
+  integer, target :: a(n)
+  type(c_ptr) :: dptr
+  integer :: flag
+
+  a = [2, 4, 6, 8]
+  flag = 0
+
+  !$omp target data map(tofrom: a, flag)
+    dptr = omp_get_mapped_ptr(c_loc(a), dev)
+
+    !$omp target is_device_ptr(dptr) map(tofrom: flag)
+      flag = flag + 1
----------------
TIFitis wrote:

I tried adding the call to c_f_pointer inside the target region in the previous 
test. But it causes a runtime failure, and I'm not sure if the failure is 
directly related to the is_device_ptr implementation or some other mapping bug.

If you're happy with the current simpler test for this PR, then I can work on 
debugging a fix for that failure when I return from vacation in the new year. 
Otherwise, I'll put this PR on hold until I can come up with a working version 
of that test with a call to c_f_pointer inside the target region.

Let me know which you prefer, thanks.

https://github.com/llvm/llvm-project/pull/169367
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to