Skip to main content
Log in

Thread index

In GPU programming, a thread index uniquely identifies the position of a thread within a particular thread block executing a kernel function on the GPU. A thread block is a subset of threads in a grid, which is the top-level organizational structure of the threads executing a kernel function. Each block within the grid is also assigned a unique block index, which identifies the block's position within the grid. The combination of block index and thread index uniquely identifies the thread's overall position within the grid, and is used to determine which part of the problem each thread should work on.

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