Log inStart free
LESSON 26.09 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Warp divergence

Watch one warp run both sides of an if while some lanes wait.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 26.09 · GPU BAYWARP 0 · 21 PLAIN · 11 CLAMPED
01
Stage 1 of 6 · One instruction
A warp issues one instruction to its 32 lanes at a time. Setup takes 2 steps.
Explain it simply

A warp is a team of 32 threads that share one instruction stream. Each step, the warp reads one instruction, and every lane with a thread runs it. Here all 32 lanes work through the 2 setup steps together.

The map shows 9 warps. All 32 lanes of the traced warp run the 2 setup steps.

pixels, busy lanesblocksmasked lanes, idle threads, split warpsempty lanestraced warp, steps
one warp, step by stepthe launch: 3 × 3 blocks of 8 × 4 threadswarp 0 of block (0, 0): 32 lanesT = 2 steps, each for all 32 lanesx = 0·8 + tx, y = 0·4 + ty21 plain path11 clamped path0 past the image0 empty lanelanes of the traced warpsetup 2T = 2 warp steps02one warp, step by stepthe launch: 3 × 3 blocks of 8 × 4 threadswarp 0 of block (0, 0): 32 lanesT = 2 steps, each for all 32 lanesx = 0·8 + tx, y = 0·4 + ty21 plain path11 clamped path0 past the image0 empty lanelanes of the traced warpsetup 2T = 2 warp steps02
Toy: 26.C2 · a 20 × 12 image · 3 × 3 blur · toy step counts
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
T=2 steps, each for 32 lanes\sy{T}{out}{T} = 2\ \text{steps, each for}\ \sy{n}{data}{32}\ \text{lanes}
T=2T = 2

Each step runs one instruction on all 32 lanes.

Common mix-ups

MYTHA branch slows down only the threads that take it.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With the branch and 32 × 2 blocks, how many of the 12 warps split?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.