cudaMemcpy to part way through an array

Is it possible to copy from host to device (and back again) by copying a smaller array into a larger one and offsetting the first lcoation to be copied to. E.g. assuming that smallarray and bigarray are pointers to arrays on the host and device respectively, would the following work?

[codebox]cudaMemcpy(bigarray[offset], smallarray, SizeofSmallArray, cudaMemcpyHostToDevice)[/codebox]

only on the buffer in the cpu …

You can do device pointer arithmetic on the host, but what you are trying to do wont work. Try this:

cudaMemcpy(bigarray+offset, smallarray, SizeofSmallArray, cudaMemcpyHostToDevice)

Thanks for the help, I’ll see how that works.

Just a quick update, this method works very nicely. Thanks for the help.