Log inStart free
LESSON 27.06 · 5 STAGES · 2 CONTROLS · 2 CHECKSPRO · PREVIEW

Pinned and unified memory

Watch 8 pages cross from host RAM to the GPU in four ways.


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

Go Pro · $8.25/mo
EXPLAINER · 27.06 · COPY BAY8 PAGES · 16 MB · PCIe 4.0 · 80 µs A PAGE
01
Stage 1 of 5 · Pageable pages
Host RAM holds a 16 MB tensor in 8 pageable memory pages. The OS can move any page to swap.
Explain it simply

You see host RAM, the CPU's memory, cut into 8 pages of 2 MB. The operating system may move a pageable page to disk at any time, like the arrow down to swap. The GPU's DMA engine reads fixed addresses, so it can't trust such a page. One page needs 80 microseconds on the link.

Host RAM holds 8 pageable pages of 2 MB. An arrow goes from page 8 to swap. GPU memory is empty. A PCIe 4.0 link at 25 GB/s joins them.

page, DMA copyCPU copy, link, pinnedpage faultCPU waitskernel, run timefree CPU, empty slot
host RAM · pageableGPU memoryswap (disk)0500100015002000 µsPCIe 4.0 · 25 GB/s1234567812345678pageable pageshost RAM · pageableGPU memoryswap (disk)0500100015002000 µsPCIe 4.0 · 25 GB/s1234567812345678pageable pages
Toy: 8 pages of 2 MB, a CPU copy at 10 GB/s, a 45 µs fault
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
td=SBlink,tc=SBcpu\sy{d}{data}{t_d} = \frac{S}{\sy{b}{param}{B_{\text{link}}}},\quad \sy{c}{param}{t_c} = \frac{S}{B_{\text{cpu}}}
td=2 MB25 GB/s=80 μs,tc=2 MB10 GB/s=200 μst_d = \frac{2\,\text{MB}}{25\,\text{GB/s}} = 80\,\mu\text{s},\quad t_c = \frac{2\,\text{MB}}{10\,\text{GB/s}} = 200\,\mu\text{s}

One page takes its size divided by the rate of each hop.

Common mix-ups

MYTHUnified memory makes the copy free.

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

Predict, then reveal
2 CHECKS · PRO
Q01If the kernel touches only 3 of 8 pages, which is faster: the pinned copy or unified memory?

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

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 2 live controls
  • 2 mix-up cards and 2 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.