What Is SIMT? Understanding CUDA Warp Execution and Branch Divergence
SIMT describes work per thread while CUDA groups threads into warps. A 1D indexing example, a 32-thread warp, and divergent branches help check bounds, memory access, and block-order assumptions.
What Is SIMT? Understanding CUDA Warp Execution and Branch Divergence
SIMT (Single Instruction, Multiple Threads) is a parallel programming and execution model in which many threads run the same kernel code. Each thread has its own index and data and describes an independent piece of work; GPU hardware groups threads for execution. SIMT lets programmers express data-parallel work per thread without writing SIMD vector instructions directly.
Map one thread to one data element
A CUDA kernel runs many threads. For a one-dimensional array, each thread calculates a global index to choose its element. The C++ kernel shows the core of array addition; memory allocation and launch configuration are omitted, so it is not a complete program you can compile as written.
__global__ void add(const float* a, const float* b, float* c, int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
c[i] = a[i] + b[i];
}
}blockIdx.x is the current block number, blockDim.x the number of threads in it, and threadIdx.x a thread's number in that block. Together they give each thread a distinct array index, as in NVIDIA's A[i] + B[i] example. With 35 elements and two blocks of 32 threads, indices run 0–63 but only 0–34 pass i < n, so 35 results are written. This illustrates CUDA; it is not a tested program or verified run configuration.
NVIDIA CUDA warp example
In NVIDIA CUDA, threads in a thread block execute in groups called warps. The current CUDA Programming Guide describes a warp as 32 threads. Each thread has its own register state and control flow, but if threads in a warp choose different conditional branches, the paths may be handled separately and lanes not participating in a path may be masked. This is commonly called warp divergence.
For example, if only some of 32 threads pass an if condition, both paths may need to execute. The compute unit may then have fewer than 32 lanes doing useful work at a time. Grouping data so nearby threads tend to follow the same branch can help, but the actual impact depends on the code and GPU generation and should be measured.
SIMT and SIMD compared
| Aspect | SIMT | SIMD |
|---|---|---|
| Main programming unit | Individual threads | A vector or group of data elements |
| Control flow | Can express branches per thread | Usually centers on one instruction flow across a vector |
| Performance concern | Branch disagreement within a warp | Dependencies, alignment, or leftover elements that prevent vectorization |
This is a conceptual comparison. Implementations differ, and CUDA warp size must not be assumed for other GPU programming models.
Checks when writing a kernel
Map clearly which data index each thread handles.
Add bounds checks when block boundaries do not match the total data length.
Profile whether threads in the same warp often take different branches.
Check that neighboring threads access memory in a way that can be handled efficiently.
Follow the official programming model instead of relying on undocumented scheduling details of a specific device.
CUDA grid blocks may execute in any order. Do not make one block implicitly wait for another; use an explicit CUDA-supported synchronization mechanism for cross-block dependencies.
Sources
[NVIDIA CUDA Programming Guide: Programming Model](https://docs.nvidia.com/cuda/cuda-programming-guide/01-introduction/programming-model.html)
[NVIDIA CUDA Programming Guide: Writing SIMT Kernels](https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/writing-cuda-kernels.html)