https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96080

--- Comment #2 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
In contrast, see the same example with 'dimension(:)' removed, that is, scalar
data.  Here, we see the directives and the runtime library routines behave in
the same way for Fortran 'pointer'.

    program main
      use openacc
      implicit none
      integer, target :: data
      integer, pointer :: data_p

      call acc_create(data) ! h=0x7fffffffd79c, s=4
      ! NEW
      ! (gdb) print tgt
      ! $2 = (struct target_mem_desc *) 0xa7a690
      ! (gdb) print/x *tgt
      ! $3 = {refcount = 0x1, array = 0xb18570, tgt_start = 0x7fffcf000000,
tgt_end = 0x7fffcf000004, to_free = 0x7fffcf000000, prev = 0x0, list_count =
0x1, device_descr = 0x80aae0, list = 0xa7a6d0}
      ! (gdb) print/x tgt->list[0]
      ! $4 = {key = 0xb18570, copy_from = 0x0, always_copy_from = 0x0,
do_detach = 0x0, offset = 0x0, length = 0x4}

      data_p => data

      call acc_copyin(data_p) ! h=0x7fffffffd79c, s=4
      ! This is 'data'!
      ! (gdb) print n
      ! $5 = (splay_tree_prefix_splay_tree_key) 0xb18570
      !   OLD 'data'
      !     '++dynamic_refcount'
      ! That means, this does *not* create a new mapping, 'acc_copyin(data_p)'
*does* dereference 'data_p => data'.
      ! That means, we cannot use this to create a "pointer object 'data_p'" on
the device.

      print *, acc_is_present(data_p) ! h=0x7fffffffd79c, s=4
      ! This is 'data'!
      ! (gdb) print n
      ! $6 = (splay_tree_prefix_splay_tree_key) 0xb18570
      ! Mapped.

      !$acc enter data copyin(data_p)
      ! 0 ("to" '*data_p'), 1 ("pointer assign" 'data_p')
      !   (gdb) print n
      !   $8 = (splay_tree_prefix_splay_tree_key) 0xb18570
      !     OLD 'data'
      !       '++dynamic_refcount'

      print *, acc_is_present(data_p) ! h=0x7fffffffd79c, s=4
      ! Same as above; mapped.

      !$acc serial present(data_p)
      ! 0 ("force_present" '*data_p')
      !   (gdb) print n
      !   $10 = (splay_tree_prefix_splay_tree_key) 0xb18570
      !     OLD 'data' -- expected
      ! 1 ("pointer assign" 'data_p')
      !   [...]
      data_p = 55
      !$acc end serial
    end program main

In contrast to an 'integer, dimension(:), pointer :: data_p', we cannot use an
'integer, pointer :: data_p' to create a "pointer object 'data_p'" on the
device.  That's confusing (at least for me).  Plus the original confusion about
'acc_on_device' etc. behaving differently (non-sensical?).

Reply via email to