CUDA Fortran : device variable in module

In section 3.2.1 of the CUDA Fortran Programming Guide, it says that device variables and arrays may appear in host and device modules. However, the following simple code always gives the error “copyin Symbol Memcpy FAILED: 13”. I’d appreciate any ideas anyone has.

Thanks!

module cudamod
	implicit none

	integer, device :: int_d(1)
end module cudamod

program fcuda
	use cudafor
	use cudamod
	implicit none

	integer :: int_h(1)

	int_h = 0

	int_d = int_h
end program fcuda

Hi,

This is a known problem. Currently, the registering of the structure containing module device data is triggered by the presence of device code in the module. We will address this in a near-term future release.

For now, the work-around is to add a global routine. It doesn’t have to do anything.

contains
attributes(global) subroutine foo
end subroutine
end module cudamod

Thanks for the reply. I just tried that, but I still get the same error. I’ve pasted the complete code below.

Thanks! - Todd

module cudamod
   implicit none

   integer, device :: int_d(1)

   contains
   attributes(global) subroutine foo
   end subroutine foo
end module cudamod

program fcuda
   use cudafor
   use cudamod
   implicit none

   integer :: int_h(1)

   int_h = 0

   int_d = int_h
end program fcuda

Sorry, I was running the wrong version of the compiler.

Setting device data in a module won’t be supported in the beta compilers. It will work in our November release.