device to device assignment

It says on p. 20 of the user guide:

An assignment statement with a device variable or device array or array section on both sides of the assignment statement will copy data between two device variables or arrays.

When I try this, however, I get the error:

more than one device-resident object in assignment

Example code:

      program dev2dev

      use cudafor

      integer, device :: d1
      integer, device :: d2
      integer         :: h

      h = 1

      d1 = h

      d2 = d1

      h = d2

      write (*,*) h

      end program dev2dev


Hi BeachHut,

Unfortunately, implementation is slightly behind the CUDA Fortran spec and this is one of the few features left. I’ll update this post once this is supported.


Hi BeachHut,

FYI, device to device copies will be supported in the 10.5 release.

  • Mat

This seems only partially fixed. If I use allocatables I still get an error.


program dev2dev

      use cudafor

      integer, allocatable, device, dimension(:) :: d1
      integer, allocatable, device, dimension(:) :: d2


      d1(5) = 10

      d2(5) = d1(5)

end program dev2dev

$ pgfortran dev2dev.cuf

PGF90-S-0155-more than one device-resident object in assignment  (dev2dev.cuf: 13)
  0 inform,   0 warnings,   1 severes, 0 fatal for dev2dev

This should work. I have duplicated the error and have filed a bug.