I am trying to use same buffer several times, but get an error in cudamemcpy in the second attempt
I use a static variable:
unsigned char * g_ImgC = NULL;
and init it once:
if (g_ImgC == NULL)
and then copy the memory to the buffer:
checkCudaErrors(cudaMemcpy(g_ImgC, ImgC, size, cudaMemcpyHostToDevice));
I dont call the cudaFree at all.
I saw that it really depends when I call the second memecpy,
if for example I call it on the same function, even after the kernel run, it works well,
but when the cu code function returns to the CPP code it will always fail,
looks like that the device is resting itself and memory inst used any more.
will appreciate an example of how it can be done.