Using cudaMemcpy2D very strange

Hi.
I have 2 arrays.
first is 1D array: size = Width * sizeof(float) * Height;
cudaMalloc((void**)&array1D, Width * sizeof(float) * Height);
second is 2D array: size width * sizeof(float) * Height;
cudaMallocPitch((void**) &array2D, &pitch, Width * sizeof(float), Height);

copy data from array1D to array2D using cudaMemcpy2D();
cudaMemcpy2D(array2D, pitch, array1D, Width * sizeof(float), Width * sizeof(float), Height, cudaMemcpyDeviceToDevice);
the strange problem is occurs,
when width = 100 the cudaMemcpy2d() works not correctly,
and width = 101 cudaMemcpy2d() works correctly.
I checked the pitch value, pitch = 832.
thank.

Nothing stands out as wrong, although the pitch of 832 is greater than I would have expected. With a width of 100 floats, I would have expected the pitch to be a little more than 400, not 800. Is perhaps your Width variable getting overwritten unexpectedly?

It worked correctly.
I had a mistake, I used cudaMemcpy2D() functions before I setting up data for 1D array.
thank for reading.
:rolleyes: