Transferring multidimensional arrays to GPU

I have to transfer bidimensional and tridimensional arrays from the main memory of the CPU to the global memory of the GPU. I read the documentation about cudaMalloc3D(), cudaMalloc3DArray(), cudaMemcpy3D() and so on… but I found it quite confusing…
Could you help me using some example code?
Thank you

If you’re not using textures, you can use cudaMalloc just as you would use malloc() in C - allocate enough memory to contain the total size of your array (e.g. width*height), and then do the indexing in your code to get the correct elements.

cudaMallocArray is only necessary if you want use textures.