I am attempting to convert a CPU code to GPU. It is written in FORTRAN and uses alot of derived types (mostly nested) and pointers to the derived types.
When I try to copy the derived type’s pointer data to the Device using OpenACC directives, I get the following error.
-Compiler failed to translate accelerator region (see -Minfo messages): Unexpected Data Type in Deep Copy
I have reproduced a small toy program where I encounter the same error. I am new to GPU programming and maybe making a mistake. I read posts about pointer data transfer but couldn’t resolve the error.
The toy program has three modules which are given as follows:
Module # 01
module Ptr_HEADER
type :: t_mol_data
integer(8) :: id = 0
character(len=30) :: name = “”
logical :: has_mp = .false.
real(8) :: density = 0.0
integer(8) :: n_atoms = 0
real(8), allocatable :: density_atom_gram(:)
integer(8), allocatable :: atom_identifiers(:)
contains
procedure :: copy_from => copy_molecule_from
procedure :: alloc => allocate_molecule
end type t_mol_data
type :: t_compound_container
type(t_mol_data), allocatable :: constituent_material(:)
contains
procedure :: get => get_molecule
end type t_compound_container
contains
subroutine copy_molecule_from(this, m)
implicit none
class(t_mol_data) :: this
type(t_mol_data) :: m
integer :: i
this % has_mp = m % has_mp
this % name = m % name
this % n_atoms = m % n_atoms
call this % alloc()
this % density = m % density
do i = 1, 3
this % atom_identifiers(i) = m % atom_identifiers(i)
this % density_atom_gram(i) = m % density_atom_gram(i)
end do
end subroutine copy_molecule_from
subroutine get_molecule(this, id, m)
implicit none
class(t_compound_container), target :: this
integer :: id
type(t_mol_data), pointer :: m
m => this % constituent_material(id)
end subroutine get_molecule
subroutine allocate_molecule(this)
implicit none
class(t_mol_data) :: this
integer(8) :: s
integer(8) :: i
s = 3
allocate(this % atom_identifiers(1:s))
allocate(this % density_atom_gram(1:s))
do i = 1, s
this % atom_identifiers(i) = i
this % density_atom_gram(i) = 0.0
end do
end subroutine allocate_molecule
end module Ptr_HEADER
–
Module # 02
module Ptr_GLOBAL
use Ptr_HEADER
type(t_compound_container), target, save :: c_mat
end module Ptr_GLOBAL
–
Module # 03
Module Ptr_INITALIZE
use Ptr_HEADER
use Ptr_GLOBAL
contains
subroutine Initializer(SIZER)
implicit none
integer(8) :: i,j,k, SIZER
type(t_mol_data), pointer :: pm
allocate(c_mat%constituent_material(SIZER))
do i=1,SIZER
pm => c_mat % constituent_material(i)
pm%id = 1
pm%density = 6.6+ real(i)
pm%n_atoms = i
allocate(pm%density_atom_gram(3))
allocate(pm%atom_identifiers(3))
end do
print*, ‘All the initialization is successful’
End subroutine Initializer
end Module Ptr_INITALIZE
–
Program
Program Ptr_EXECUTOR
use Ptr_HEADER
use Ptr_GLOBAL
use Ptr_INITALIZE
use openacc
implicit none
integer(8) :: i, my_size = 6
real(8) :: temp
type(t_mol_data), pointer :: pm
call Initializer(my_size)
call c_mat % get(1, pm)
temp = 0.0
!$acc enter data create(pm)
!$acc data copy(pm%n_atoms)
!$acc parallel loop reduction(+: temp)
do i=1, my_size
temp = temp + pm % n_atoms
end do
!$acc end parallel loop
!$acc end data
!$acc exit data delete(pm)
print*, 'Normal Ending of the executor program ...'
End Program Ptr_EXECUTOR
The HPC SDK version is 22.1 and I am using the deepcopy option while compiling.
Any help would be appreciated.