Hi,
I’m a new member in this group. Currently I’m using CUDA programming for my video codec project. I’m stuck with a problem. Here is the description…
a.cpp
extern “c” funcAlloc(…);
extern “c” funcCalc(…);
extern “c” funcDealloc(…);
func_a1()
{
funcAlloc(…);
}
func_a2()
{
funcCalc(…);
}
function_a3()
{
funcDealloc(…);
}
b.cu
unsigned char *d_var;
extern “c” funcAlloc(…)
{
cudaMalloc((void**)&d_var,…);
}
extern “c” funcCalc(…)
{
// allocate host memory
// load host data to device
cudaMemcpy(d_var,h_var,…);
// launch kernel
}
extern “c” funcDealloc(…)
{
cudaFree(d_var);
}
I get " Invalid device pointer" error .
My idea of declaring the variable ‘d_var’ as global is right???
The reason I’m doing this is because I need to allocate only once and overwrite frame data each time instead of allocating memory for every frame and deallocating each time.
Should I maintain a header .h file to declare these variables and include the header file in .cu file? I tried doing this one too. But it gives the same error.
I suppose if I allocate once n reuse the memory for every video frame data without deallocating it each time, the overall processing time will be reduced.
Can nyone help me out with this problem? Can u suggest me sme ideas for reusing the memory? It would be very helpful.
Thanks
Saritha