cudamalloc2d issue- pitch too large!

Hello,

I’m having issues with cudamalloc2d. The pitch it returns seems much too large.
The following code:

unsigned int pitchA;

cudaMalloc2D((void**)&Gdevice.A ,&pitchA ,sizeof(float)*1024,1025);

printf("\n%u\n",pitchA);

prints out the unsigned integer:
343597836

I have absolutely no idea what is wrong, so if anyone has any insight whatsoever I would greatly appreciate it.

Thanks,
Joe

Are you checking the error status of the cudaMalloc2D call? It’s possible that the value you are seeing is just the value that pitchA was constructed with. Set it to 0 before the call and see what you get. If everything works you should get 4096 in pitchA as it is 16 byte aligned.

Thanks Downey, I ran the program again with your suggestions. I set pitchA to 0 before calling cudaMalloc2D and checked the error status. After running the program, I find that the error status is 10003, and that pitchA=0

int a=0;

a=cudamalloc(…);

printf("%i",a);

Does anyone know what error status 10003 means?

Thanks,

Joe

Look up cudaGetErrorString()

Thanks Mr Anderson,

I changed my code to this:

cudaError_t a;

a=cudamalloc2D(…);

printf(cudaGetErrorString(a));

Now my code works fine. I am no longer getting error 10003, and the pitch is now 4096 like it should be. I don’t know how this solved the problem, but I’m really happy that it did!!

Joe