What is Warp divergence?
The splitting of threads within one warp onto different paths at a conditional branch. The paths execute one after another, lowering efficiency.
Japanese name: ワープダイバージェンス
The splitting of threads within one warp onto different paths at a conditional branch. The paths execute one after another, lowering efficiency.
Japanese name: ワープダイバージェンス
On NVIDIA GPUs, threads are executed in warps of 32. A warp executes one common instruction at a time. Efficiency is therefore highest when all its threads follow the same path. When the outcome of a conditional branch depends on each thread's data, threads in the same warp go different ways. This is warp divergence.
The warp executes each path that its threads have taken. While one path is being executed, the threads that are not on it are disabled. The computed results remain correct. Suppose the if side and the else side are both 10 instructions long and the 32 threads split 16 and 16. Counted simply, an undiverged warp needs the time of 10 instructions, while the diverged warp needs 10 + 10 = 20. During that time only 16 threads are doing work at any moment.
Divergence occurs only within a single warp. Different warps taking different paths do not affect one another. Besides if statements, it also arises from loops whose iteration count differs from thread to thread. The basic countermeasure is to make the threads of one warp follow the same path. For example, data or thread indices are arranged so that the condition switches on warp boundaries.
Answer: C. The if and else paths run one after the other, with non-participating threads idle each time, lowering efficiency
A warp's 32 threads execute the same instruction, so on divergence the if-path instructions run first with only the if threads active, and then the else path runs with the rest. Results are correct, but half the threads are idle each time, so the cost is the sum of both paths. Arranging data or threads so that branches agree within each warp improves efficiency.
No. Each thread ends up with the same result as if it had executed only the instructions on its own path. What drops is execution efficiency.
Not necessarily. If every thread in a warp goes the same way, the paths do not split. What costs time is a branch whose outcome varies within one warp.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.