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

A CUDA kernel launch

Watch a vector add copy its data to the GPU, run, and come back.


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 · 27.04 · LAUNCH BAY16 VALUES · 64 B PER ARRAY
01
Stage 1 of 5 · Two memories
The host holds a and b in RAM, 16 values each. The GPU's device memory is still empty.
Explain it simply

On the left is the host, the CPU with its own memory. Arrays a and b live there, one cell per number. On the right is the GPU, the device. It has a separate memory, like a second desk, and that desk starts out empty.

Two boxes. The host box holds arrays a and b with 16 values each, and an empty array c. The device box holds three empty arrays and 2 SMs.

a and bthreadsc and the kernelempty or idle
host · CPU and RAMdevice · GPU and its memoryabcd_ad_bd_cSMshostlinkGPU024681012141618time in ticks →PCIe link4 per tickSM 0SM 188715929105687134000568383803709two memories16 values × 4 B = 64 B per arrayhost · CPU and RAMdevice · GPU and its memoryabcd_ad_bd_cSMshostlinkGPU024681012141618time in ticks →PCIe link4 per tickSM 0SM 188715929105687134000568383803709two memories16 values × 4 B = 64 B per array
Toy: a vector add on a toy GPU; ticks, not real times
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
bytes=N×4\text{bytes} = \sy{n}{data}{N} \times 4
16×4=64 B per array16 \times 4 = 64\ \text{B per array}

Each array takes 4 bytes per value.

Common mix-ups

MYTHA kernel can read the host's arrays directly.

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

Predict, then reveal
3 CHECKS · PRO
Q01With 16 values in blocks of 4, which part of the timeline gets shorter with 4 SMs?

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.