Why only 2D Grid and Why only 3D Thread Block ? Why only upto 2-D Grids and why only Upto 3-D Thread

Hi all,

We all know that we can create upto 2-Dimensional Grids and Upto 3-Dimensional Thread Blocks.

But why is the dimensionality of Grids and Thread Blocks restricted?
Is there any hardware limitation ?
Is it a architectural decision ?
Or any other reason ?

Please give your comments on this.

For every interger ‘N’, there exists an integer ‘N+1’

Any further dimensions can be implemented through these basic building blocks…

The 2D grids are a hardware restriction (as is the 65535 size limit). The Fermi architecture actually supports 3D grids, but this isn’t exposed in CUDA yet.

As Sarnath says, you can easily compute your own n-D indices from blockIdx and threadIdx if you want to.

Thanks for the reply…

I am still confused can you please elaborate your answer.

Thanks in advance.

Thanks for the reply…

I am still confused can you please elaborate your answer.

Thanks in advance.

By “compute your own…” it means you can easily do this:

__global__ void Mykernel()

{

   int CurrentDimension = blockIdx.x % 5;

   .....

}

...

dim3 grid( xBlocks, yBlocks * 5 );

MyKernel<<< grid, 256 >>>();

...

Or by dividing the 256 (or any other number) of threads to groups as you’d like.

Just make sure you keep the coalescing rules correct.

eyal