Managed data type CUDA fortran example

I have a legacy code which has quite a few derived data types. I have learnt that CUDA 6 onwards, we can use derived data types in device subroutine by using “managed” attribute. I was trying to test a few codes before start modifying the original code. I have the following test code:

module test

! Point Data Type for Arbitrary Mesh
type :: point
integer :: id
double precision, dimension(3) :: coord
end type

contains

attributes(global) subroutine pointRotate(p,b)
implicit none
type(point), intent (inout) :: p(:)
integer :: i1,n1

  i1=threadIdx%x
  n1 = size ( p )
  if(i1<=n1) p(i1)%id = 1.0

end subroutine pointRotate

end module

program reentry

! Header Files
use cudafor
use mpi
use test

implicit none

type(point),managed,allocatable :: p(:)

integer :: ierr ! MPI error
integer :: rank ! Rank of my processor
integer :: commsize ! No of processors
integer :: world ! MPI environment

! GPU data
type (cudaDeviceProp) :: prop
integer :: nDevices=0,n=100,b=1

call MPI_INIT(ierr) ! Initialization of MPI
world = MPI_COMM_WORLD ! Using world instead of longer MPI_…
call MPI_COMM_RANK(world,rank,ierr) ! Who am I?
call MPI_COMM_SIZE(world,commsize,ierr) ! Who are others?

! GPU Device Initialization
ierr = cudaGetDeviceCount(nDevices)

allocate(p(n))

call increment <<<1,n>>> (p)

deallocate(p)
call MPI_FINALIZE(ierr) ! End of MPI and the Program

end program

I don’t get any error while compiling this code, but however, get a bus error when I run this. Why does this happen?

I have tried to search CUDA Fortran examples on how to implement managed variables but I haven’t found any. Any suggestion on where to get such examples will be appreciable.

Thanks!

There’s no “b” here

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.