three dimensional indexing!

I am trying to set up three dimensional indexing using 2-D grid and 3-D blocks.

Following is indexing scheme used in my code:

LX=80; LY=80; LZ=32;

  TILE_I=8; TILE_J=8; TILE_K=4; 

dim3 grid = dim3(LX/TILE_I, LY/TILE_J);

  dim3 block = dim3(TILE_I, TILE_J, TILE_K );

int x = blockIdx.x*TILE_I + threadIdx.x;

  int y = blockIdx.y*TILE_J + threadIdx.y;

  int z = blockIdx.z*TILE_K + threadIdx.z;

  int idx= x+ y*LX+ z*LX*LY;

idx is global indexing for any thread.

It is important for me to know each thread in (x,y,z) co-ordinate.

This indexing scheming works ok for first 6400 (80x80) elements, for the 2-D indexing, but something

is wrong with indexing in Z direction.

Could you please help me debug this indexing problem.

Thanks

Grids are only two dimensional in CUDA at present.

I am using 2-D grid

dim3 grid = dim3(LX/TILE_I, LY/TILE_J);

Your code shows you are trying to index using blockIdx.z. That isn’t presently used.

I find using a big linear index and then striding it is easier. Heres how I do it:
http://forums.nvidia.com/index.php?showtopic=68489&view=findpost&p=393023