I have a 13x2 matrix of type double at the moment. cudaMallocPitch generates a linear array capable of holding this data, with padding. (pitch returns as 512). cudaMemcpy2DToArray should fill this array from what I understand.
Is it okay for me to define my device array ( double *u_dev ) as I have? I have seen it done as type double, type cudaArray, and type float. I now get an error because the arguement (*u_dev) is not of type cudaArray. Is it required that I define it as type cudaArray?
Thanks for all the help.
Any idea why the cudaMemcpy2DToArray isnt working then? I have the code set to exit if i dont get returns of cudaSuccess. It exits at the cudaMemcpy2DToArray.
Sorry I didn’t look at your whole sample. cudaMallocPitch() returns a device pointer to a linear array, it does not allocate a cudaArray. And since it is on the device already, you can’t use cudaMemcpyHostToDevice in the cudaMemcpy2DToArray.
I think what you are looking for are cudaMallocArray() and cudaMemcpyToArray(…, cudaMemcpyHostToDevice). There is an example in the Programming GuideI believe, in the chapter about textures and surfaces.
I think that using cudaMemcpy2DToArray is okay here. I am filling the linear array created by mallocPitch with a my 2D array in u. Is that not correct?
It should copy my 2D array on the host side to a linear array on the device side. I’ve read that these functions provide the most efficient way to accomplish this memory transfer.
Thanks for the responses by the way I really appreciate it. The literature only gets me so far at the moment.
No. A cudaArray is not the same as a generic 2D array. I’m sure you don’t have a cudaArray on the host because its layout is opaque and not documented.