CUDA Fortran Derived Type with Device vs Managed Attribute

I am trying to understand in Cuda Fortran why a derived type containing only device allocatable arrays needs to have a managed attribute rather than allowing for a device attribute. Copy of sample test code follows. The derived type in question is extracted here:

type:: cs1
real,device,allocatable,dimension(:,:):: s
real,device,allocatable,dimension(:) :: cfl
end type cs1
type(cs1),managed,allocatable,dimension(:):: edge_stream ! This works ok
!!type(cs1),device,allocatable,dimension(:):: edge_stream ! This causes core dump

Thank you.

cuda_stream_module_f90.txt (5.1 KB)

This part:

        allocate(edge_stream(n)%s(m1,m2))
        allocate(edge_stream(n)%cfl(m2))

If “edge_stream” is a device array then it can’t be accessed on the host. Hence when you try to allocate the data members, the host seg faults given “edge_stream” needs to be accessed.

“managed” memory is accessible on both the host and device, and why it works.