A 2D thread layout gives each thread two coordinates: x for the column and y for the row. That matches data such as images and matrices more naturally than a single index. A CUDA block gets this shape from a dim3 launch configuration. section 2.7 section 9.3
For a row-major array, convert coordinates to a memory position with row * width + column. When launching a grid, calculate its size for both dimensions; threads beyond the data edges must check their coordinates before accessing memory. section 9.3
Blurring an image
A 16×16 block assigns one thread to each pixel in its tile. Each thread can average the valid pixels in a surrounding 3×3 neighborhood, checking boundaries so edge pixels do not read outside the image. section 9.3
Figure 2.3 2D thread layout: two coordinates, one thread. In a 2D block, each thread is identified by a (threadIdx.y, threadIdx.x) pair (row, column), making it a natural fit for working with grids, images, or matrices. A block like this comes from a 2D launch, where you pass the block shape as a dim3 instead of the single number a 1D launch uses: here dim3 block(5, 4); kernel<<<1, block>>>(); for 5 columns (x) and 4 rows (y).

See how a 2D block identifies each thread by its row and column coordinates. section 2.7
