block and grid

I am confusing to what’s the x and y in block and grid.
To block the x and y is shown as below,


Y 1

but to grid, is it same with block.
For example, to dim3 grid(3, 1), if the x and y in grid are same with that in block, it means that there a three columns in one row?


I don’t think I understand your question, but as an abstraction, a dim3 grid(3,1) contains 3 blocks arranged in 1 row.

You can divide your blocks and grids into dimensions of x, y, and z. Depending on your needs, you may only use x, or x & y or you may use all 3.

For example, in a matrix app, you might create a block with x and y dimensions that match your grid and then assign each thread in the block to a single cell of the matrix based on the thread’s X & Y indices.

If you’re working with an array, on the other hand, you might simply use the X dimension and assign each thread to a single array index.

Does that help?