What is a warp?
A block is divided into warps for execution. On NVIDIA GPUs, a warp contains 32 threads. Our 128-thread block therefore contains four warps.
See the connection
A warp lives inside a block
Same example as Session 6: 128 threads in block 2. Each numbered square below is one thread, not a core.
Where the hardware fits
4 warpsAnother block
If resources allow
When one warp takes two paths
Reference: NVIDIA CUDA execution model.
Same recipe with different numbers
The threads can run the same instruction on different data. Imagine applying a discount to 32 different prices.
If half need formula A and half need formula B, the warp takes different paths with the appropriate threads active. This is divergence. It can leave some execution lanes inactive while a path runs.
That is not automatically a bug or a prediction that the whole program becomes twice as slow.
What the SM does
The SM’s schedulers select ready warp instructions. While one warp waits, another may make progress.
More threads do not create unlimited capacity. Registers, shared memory, and hardware limits constrain how much work can reside there.
Do not assume threads can exchange data safely just because they share a warp. Use the synchronization the algorithm requires.
Try it yourself
For 64 items, compare alternating A/B formulas with 32 A items followed by 32 B items.
Check your answer
Alternating items mix paths in both warps. Grouping makes each warp follow one path in this example. Rearranging data also costs time, so measure before calling it an improvement.