CudaMallocPitch and CudaMemcpy

Hi,
I am allocating memory for image size 620*480 using CudaMallocPitch with Pitch 640.
Is this means it is allocating (640 * 480) size of memory in GPU ??

Thanks,
TUshar

When you use cudaMallocPitch, you don’t get to specify the pitch. The routine itself decides what the pitch will be and returns that in the pitch variable.

If it returned a value of 640, that would mean that the width of the actual allocation is 640 bytes ( and the total allocation size would be that width multiplied by whatever height you requested.)

Hi txbob,

Thanks for reply.
I realize my mistake of giving wrong pitch value for source data.
In GPU memory allocation was 640x480 but CPU memory allocation is 620x480 and I m trying to copy 640x480 amount of info from CPU to GPU.

Thanks,
Tushar