Hi,
I am new to CUDA and currently working on a project in which I need to copy large amount of constant 2D array data into device memory. I checked the Reference Manual and found the following functions:
cudaMemcpy2DArraytoArray
cudaMemcpy2DtoArray
My question is
1: what is the difference between these two functions?
2. Will they copy the 2D array from host to device without any change or they will reshape the 2D array to a 1D array in copying process?
3. What is the best way to copy a 2D array to device without changing or reshaping it?
remember that Array in cudaMemcpy2DArraytoArray() and cudaMemcpy2DtoArray() not has the normal structure. Z-curve structure.
1: what is the difference between these two functions?
cudaMemcpy2DArraytoArray(): In device memory, you already have allocated 2 Array (by using cudaMallocArray()), and copy data between these Array.
cudaMemcpy2DtoArray(). copy 2D array to cudaArray. 2D array is means that a matrix with 2 dimension with normal structure. In your case you can use this
functio to copy 2D array from host to device global memory.
2. Will they copy the 2D array from host to device without any change or they will reshape the 2D array to a 1D array in copying process?
I think that it copy 2D array from host to device without any change .
3. What is the best way to copy a 2D array to device without changing or reshaping it?
you have 2 functions to do it.
cudaMemcpy2D(): copy data from host to device memory (normal structure)
cudaMemcpy2DToArray(): copy data from host to cuda Array(not normal structure)