cudaMemcpy problem

typedef struct {
	int M;
	int N;
	int records[NMAX][SZM];
	int times[NMAX];
	bool prime[NMAX];

typedef int ITEMSET[SZM];

__device__ DATASET d_db;


int main(void)

	cudaMemcpy(&d_db, &db, sizeof(DATASET), cudaMemcpyHostToDevice);

I have a device variable d_db a variable db on the host. After I load same value on my db variable, I want to copy this variable on device. Compiling there are no errors, but when I execute the code there are some wornings about cache and sometimes the pc is restarted. What I’m doing wrong?

Please use proper cuda error checking before asking for help here. Even if you don’t understand the results of it (or even if the results are no error), it will be useful for others who are trying to help you. If you don’t know what “proper cuda error checking” is, please google “proper cuda error checking” and take the first hit.

We don’t use cudaMemcpy to copy to a device variable. We use cudaMemcpyToSymbol. This is covered in the documentation:

We also don’t take the address of the device variable. You use its symbol name directly:

cudaMemcpyToSymbol(d_db, &db, sizeof(DATASET));