cuda 3D array problem

Please help…
I want to add 3D array, i want to use for loop in global

global void add(int ***dev_a ,int ***dev_b,int ***dec_c)
{
for i=0;i<2;i++)
{
for j=0;j<2;j++)
{
for k=0;k<2;k++)
{

    dev_c[i][j][k]=dev_a[i][j][k]+dev_b[i][j][k];
      }
  }
}

}

How i can do this in cuda? please explain me with some code… thank you

Don’t use 3 dimensional arrays. All arrays are inherently 1d in memory, the 3d subscripts just store arrays of pointers to chunks of the 1d array. Use a 1d array and use pointer arithmetic to access it like a 3d array.

Example: dev_c[i][j][k] is the same as dev_c[k+NZ*(j+NY*i)]

Thank you for idea, its working for my cuda code. Thank you very much.