I am using visual Studio 2008 with MFC and in my program I have split up my CUDA source code into three functions, Initialise, PutData and ProcessData. The initialise function simply sets up the pointers and calls CudaMalloc to allocate memory space for all my working arrays. The PutData function is called to place in my input data array, this function does a cudamemcpy from the incoming data array to the cuda allocated memory array (making sure the correct hosttodevice or devicetodevice enum is used).
Then final ProcessData then is the C code to call the special Cuda Kernels. All these routines are compiled in the same .cu file.
The problem is that I always get a cudaError at memory location blah blah, when I call the PutData routine. If I move the cudamemcpy into the Initialise function, it works with no error. Why cant I split up my cuda program into different calls.
I could make my function a once through function call, but as the project develops this is going to become too large. I need to be able to split the cuda functions into different calls and possibly even different .cu files as well (that didnt work either, but thats another story).