Skip to main content
Log in

Block index

In GPU programming, a block index uniquely identifies a subset of threads that execute a kernel function on the GPU. Threads are grouped into units called blocks, and multiple blocks together form a larger structure known as a grid.

Each block within the grid is assigned a unique block index, which can be represented across one, two, or three dimensions. This allows for flexible organization of threads to match the structure of the problem being solved. Within each block, individual threads have their own thread index, which, together with the block index, determines which part of the problem each thread should work on. This hierarchical structure of grids, blocks, and threads enables efficient workload distribution across the many processing cores of the GPU, maximizing parallel performance.

Because a programmer can arrange thread blocks within a grid across one, two, or three dimensions, a block index is a 3-element vector of x, y, and z coordinates. For 2-dimensional arrangements, the z coordinate of all block indices is 0, and for 1-dimensional arrangements, both the y and z coordinates of all block indices are 0.