After a global device pointer is set through `c_f_pointer`, we need to sync the double descriptor so the version on the device is also up to date.
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
|
|
|
|
! Test lowering of CUDA pointers.
|
|
|
|
module mod1
|
|
|
|
integer, device, pointer :: x(:)
|
|
|
|
contains
|
|
|
|
subroutine allocate_pointer
|
|
real, device, pointer :: pr(:)
|
|
allocate(pr(10))
|
|
end
|
|
|
|
! CHECK-LABEL: func.func @_QMmod1Pallocate_pointer()
|
|
! CHECK-COUNT-2: fir.embox %{{.*}} {allocator_idx = 2 : i32} : (!fir.ptr<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
|
|
|
|
subroutine c_f_pointer_sync
|
|
use iso_c_binding
|
|
use, intrinsic :: __fortran_builtins, only: c_devptr => __builtin_c_devptr
|
|
type(c_devptr) :: cd1
|
|
integer, parameter :: N = 2000
|
|
call c_f_pointer(cd1, x, (/ 2000 /))
|
|
end
|
|
|
|
! CHECK-LABEL: func.func @_QMmod1Pc_f_pointer_sync()
|
|
! CHECK: %[[ADDR_X:.*]] = fir.address_of(@_QMmod1Ex) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
|
|
! CHECK: %[[CONV:.*]] = fir.convert %[[ADDR_X]] : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> !fir.llvm_ptr<i8>
|
|
! CHECK: fir.call @_FortranACUFSyncGlobalDescriptor(%[[CONV]], %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.llvm_ptr<i8>, !fir.ref<i8>, i32) -> ()
|
|
|
|
end module
|