Passing an array from host to the device?

Hello,

I am pretty new to using CUDA and I am having trouble passing an array from host to the device. I have a variable on the host called spikeStreams_1D_h that I populate with data. I am trying to get this to be passed into a device variable that is a 2D array called img_spks.

double spikeStreams_1D_h[p*q*M];
__device__ double img_spks[p*q][M];

..
..
int main(){
DVS2Spks <<< 1, 1 >> > (spikeStreams_1D_h);
..
}

Below is the method for DVS2Spks:

__global__ void DVS2Spks(double *spikeStream_1D_h)
{
	for (int i = 0; i < M; i++)
	{
		for (int j = 0; j < p*q; j++)
		{
			img_spks[j][i] = spikeStream_1D_h[j + ((p*q) * i)];
		}
	}

}

I thought that calling this method would make it so that img_spks has the data from spikeStream_1D_h. Instead, all of its values are zero. I am not sure if I am missing a step or not. Any advice is greatly appreciated!

You may want to study a sample code like vectorAdd, to learn the basics of moving data between the host and device. I could say this won’t work but you already know that. Your spikeStreams_1D_h is an ordinary host pointer. That is simply unusable, in any fashion, in CUDA device code. You need to use a CUDA API (library call) of some sort to move the data. The vectorAdd sample code will show one possibility.