sdmello
sdmello

Reputation: 429

CUDA Fortran: Cannot copy array of arrays(or array of pointers to arrays) using cudaMemCpy

I am trying to compile a basic memory transfer code using PGI's fortran compiler(Workstation/PGI Visual Fortran). The compiler throws an error on the line where I have a cudamemcpy call. The exact error message is "Could not resolve generic procedure cudamemcpy" for the line

istat=cudaMemcpy(arr(1),arr(2),800,cudaMemcpyDevicetoDevice)

I am also using the cuda fortran module--"use cudafor". What's the solution to this compiler error? Thanks!

Upvotes: 1

Views: 468

Answers (1)

sdmello
sdmello

Reputation: 429

The arrays arr(1) and arr(2) are of type

type subgrid
   integer, device, dimension(:,:,:), allocatable :: field
end type subgrid

The problem was resolved by not using the 4th argument and by specifying the actual field data that needed to be transferred. 800 is the number of integers I needed to be transferred from one slice to the other.

istat=cudaMemcpy(arr(1)%field(:,:,:), arr(2)%field(:,:,:), 800)

Also, the cudaMemcpyDevicetoDevice doesn't affect the function call. It works fine with/without it.

Upvotes: 1

Related Questions