How to read RGB image data into GPU global and shared memories 3D array based question

Hi,

I read an RGB of width 320 and height 320 into an array of length 3203203

This is how I read it

for(i=0;i<320;i++)

{

  for(j=0;j<3*320;j=j+3)

  {

	arr[i*320+j]=r;

	arr[i*320+j+1]=g;

	arr[i*320+j+2]=b;

  }

}

Now, I want to copy this into GPU with a 3-D block size i.e., having threads in x-,y- and z-directions. Since a block cannot contain more than 512 threads, my dimensions would be (16,8,3) in x,y,z directions resp. I want to know how to index this.