Allocate derived type array on device

Hi, all

I try to allocate derived type array on gpu device. However, I will get the compiling message “error S0155 : more than one device-resident object in assignment” while the statement is “allocate( g_cf(i)%a(0:j), g_cf(i)%b(0:j) )”.
And I got the runtime message “Process 0: Signalled ACCESS_VIOLATION at 0x40001c8e” while using the statement instead “allocate( g_cf(i)%a(j+1), g_cf(i)%b(j+1) )”.

I’ve tried it using PVF 10.9 on WIN 7 and 12.3 on Linux.
Did I do anything wrong?
Thank you.

      program prog
      use cudafor
      implicit none   
      ! Variables
      Type g_ch
        integer :: cst
        real*8,allocatable :: a(:)
        integer,allocatable :: b(:)
      End type
      Type(g_ch),allocatable,device :: g_cf(:)
      Type(g_ch),allocatable ::cf(:)
      Integer::num, i, j
      allocate( cf(num) )
      do i=1,num
	    allocate( cf(i)%a(0:cf(i)%cst), cf(i)%b(0:cf(i)%cst) )	    
      end do
      allocate( g_cf(num) )
      do i=1,num
	    allocate( g_cf(i)%a(0:j), g_cf(i)%b(0:j) )
	    !allocate( g_cf(i)%a(j+1), g_cf(i)%b(j+1) )
      end do

      end program prog


Hi, all:

Is my case same as this previous post?

…user defined types used as device types can only be composed of basic types, or fixed size arrays.

Thank you in advance.

Is my case same as this previous post?

Yes. Once NVIDIA supports dynamic allocation on the device (coming in CUDA 5 and Kepler2) this restriction may change, but for now, only fixed size types can have the device attribute.

  • Mat

Hi, Mat,

OK…Thank you very much.
And is there any schedule about PGI Fotran supporting CUDA 5 ?
Thank you in advance.


Hi Feng,

We usually include the next CUDA version about a month after NVIDIA officially releases it. Though, it may take us a bit to get all the new CUDA 5 features integrated into CUDA Fortran.

  • Mat