================
@@ -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
----------------
ergawy wrote:
I think it makes sense to tighten the test before merging. I might be missing
something but I tried the following experiment:
```diff
! RUN: %libomptarget-compile-fortran-run-and-check-generic
program is_device_ptr_target
- use iso_c_binding, only : c_ptr, c_loc
+ use iso_c_binding, only : c_ptr, c_loc, c_intptr_t, C_NULL_PTR
implicit none
interface
@@ -22,19 +22,25 @@ program is_device_ptr_target
integer, parameter :: dev = 0
integer, target :: a(n)
type(c_ptr) :: dptr
+ type(c_ptr) :: dptr_cpy
integer :: flag
a = [2, 4, 6, 8]
flag = 0
+ dptr_cpy = C_NULL_PTR
!$omp target data map(tofrom: a, flag)
dptr = omp_get_mapped_ptr(c_loc(a), dev)
+ write(*, '(Z16)') dptr
+ write(*, '(Z16)') dptr_cpy
- !$omp target is_device_ptr(dptr) map(tofrom: flag)
+ !$omp target is_device_ptr(dptr) map(tofrom: flag, dptr_cpy)
flag = flag + 1
+ dptr_cpy = dptr
!$omp end target
!$omp end target data
+ write(*, '(Z16)') dptr_cpy
if (flag .eq. 1 .and. all(a == [2, 4, 6, 8])) then
print *, "PASS"
else
```
And this prints:
```
7C35B9220000
0
0
PASS
```
which might mean that the device pointer kernel argument is not properly passed
to the kernel. Let me know if I misinterpreted this.
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