Hello, i’m getting problems with copying memory content. My program is combined c/c++ code and on start of a program i create my variables by cu file:
unsigned char* pbGlobalRGBData;
extern "C" void
cuAllocateHostMemory(unsigned char **pbDataRGB, int w, int h, bool fWithpbData)
{
cudaError_t result;
CUDA_SAFE_CALL(result = cudaMallocHost((void**)pbDataRGB, w*h*3));
CUDA_SAFE_CALL(result = cudaMalloc((void**)&pbGlobalRGBData, w*h*3*sizeof(unsigned char)));
}
After completing this variables initialization program returns to his tasks, and when i call the next function:
extern "C" void cuCopyRGBToGrayscale(unsigned char *pbData, unsigned char *pbRGBData, int w, int h)
{
cudaError_t result;
result = cudaMemcpy(pbGlobalRGBData, pbRGBData, w*h, cudaMemcpyHostToDevice);
/* rest is not important
dim3 dimBlock(BLOCK_SIZE);
dim3 dimGrid(h/BLOCK_SIZE);
RGBtoGrayscale<<<dimGrid, dimBlock>>>(pbGlobalData, pbGlobalRGBData, w, h);
cudaThreadSynchronize();
*/
}
after this cudaMemCopy i get the cudaErrorInvalidDevicePointer error. Maybe i don’t understand some basics of the CUDA programming, but why is it happening? I’ve also tried constant variables and copytosymbol, but nothing seem to work. Can anyone help?