Log inStart free
LESSON 26.07 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Memory coalescing

Watch one warp's 32 loads join into a few 32-byte memory sectors.


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

Go Pro · $8.25/mo
EXPLAINER · 26.07 · GPU BAYPIXEL (9, 6) · BYTE 516 · ROW 80 B
01
Stage 1 of 5 · Row-major memory
Memory keeps the image in row-major order, one row after the next. Pixel (9, 6) is at byte 516.
Explain it simply

On the left is the image, and next to it is the same image laid out in memory. Memory is one long line of bytes, so row 0 comes first, then row 1, and so on. Each pixel is a 4-byte float, so a row of 20 pixels takes 80 bytes. The traced pixel sits at byte 516.

A 20 by 12 image and the same pixels in memory, 960 bytes in rows of 128 bytes. Pixel 9, 6 is at byte 516.

pixels, floats asked forsectors movedwaste: bytes not used, idle threadsthe traced warpempty lane
048121602468100128256384512640768896byteimageglobal memory, row-majora = 4·(y·W + x) = 4·(6·20 + 9) = 516sector = ⌊516 / 32⌋ = 16one row = 20·4 = 80 B048121602468100128256384512640768896byteimageglobal memory, row-majora = 4·(y·W + x) = 4·(6·20 + 9) = 516sector = ⌊516 / 32⌋ = 16one row = 20·4 = 80 B
Toy: 26.C2 · a 20 × 12 image of 4-byte floats · 32-byte sectors
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
a=4⋅(y⋅W+x)\sy{a}{data}{a} = 4 \cdot (\sy{y}{data}{y} \cdot W + \sy{x}{data}{x})
a=4⋅(6⋅20+9)=516a = 4 \cdot (6 \cdot 20 + 9) = 516

The byte address of a pixel is four times its place in the rows.

Common mix-ups

MYTHLanes must read their addresses in lane order to coalesce.

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

Predict, then reveal
3 CHECKS · PRO
Q01With 8 × 4 blocks along a row, does a 16-pixel-wide image need fewer sectors than a 20-pixel-wide one?

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

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 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.