Modern GPUs are celebrated for running thousands of threads at once. A high-end GPU may launch a million threads for a single kernel — yet hiding behind that number is a strict organizational rule that shapes everything about how fast your code runs.
Threads on a GPU do not run independently. They are grouped into warps of exactly 32 threads (on NVIDIA hardware; AMD calls them wavefronts of 64). Every thread in a warp shares one instruction pointer and executes the same instruction at the same clock cycle — a model called SIMT (Single Instruction, Multiple Threads). Think of a warp as a row of 32 swimmers who must all stroke in unison: no one can stop while the others keep going.
This lockstep design makes GPUs extraordinarily efficient when all 32 threads take the same path. But the moment a branch — an if, a while, any conditional — causes some threads to go left and others to go right, the warp cannot split. Instead it must serialize: first disable the threads on the right and run the left path; then disable the left threads and run the right path. Parallelism collapses.
That collapse is called warp divergence, and it is one of the most important performance concepts in GPU programming.
Comments
Loading comments...