Log inStart free
LESSON 26.C1 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

CPU vs GPU on the same workload

Watch one vector job race on a CPU and a GPU.


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.C1 · RACE BAY12 B · 1 OP AN ELEMENT · 2 PASSES
01
Stage 1 of 6 · One workload
Both machines add, then multiply, two vectors of 1,024 floats. Each element moves 12 bytes for 1 operation.
Explain it simply

You see two machines and one job. The job reads a and b and writes c, then reads them again and writes d. Each element needs one operation, but three trips to memory of 4 bytes each. The teal strips show a and b in the CPU's RAM only.

A CPU and a GPU, each with its memory levels. Vectors a and b sit in CPU RAM. Each element moves 12 bytes for 1 operation.

a, blanes, links, math timewaits: memory, copiesresults, pass timelaunch, unused, not written yet
PCIe 16 B/nsCPU · 3 GHzcaches 26.01cores 26.0324 B/nsL1 4 KBL2 16 KBL1 4 KBL2 16 KBL1 4 KBL2 16 KBL1 4 KBL2 16 KBL3 64 KB · sharedRAMcore 0core 1core 2core 3abcdGPU · 1.5 GHzSMs 26.04memory 26.0648 B/nsL1 8 KBL1 8 KBL2 16 KB · shared by the SMsHBMSM 0SM 1offoffabcdread a[i] 4 Bread b[i] 4 Bwrite c[i] 4 B1 opeach element of a pass: 12 B moved, 1 operationone job, two machines1 op ÷ (3 × 4 B) ≈ 0.083 op per bytePCIe 16 B/nsCPU · 3 GHzcaches 26.01cores 26.0324 B/nsL1 4 KBL2 16 KBL1 4 KBL2 16 KBL1 4 KBL2 16 KBL1 4 KBL2 16 KBL3 64 KB · sharedRAMcore 0core 1core 2core 3abcdGPU · 1.5 GHzSMs 26.04memory 26.0648 B/nsL1 8 KBL1 8 KBL2 16 KB · shared by the SMsHBMSM 0SM 1offoffabcdread a[i] 4 Bread b[i] 4 Bwrite c[i] 4 B1 opeach element of a pass: 12 B moved, 1 operationone job, two machines1 op ÷ (3 × 4 B) ≈ 0.083 op per byte
Toy: c = a + b, then d = a · b, 1,024 floats
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
I=1 op3×4 B\sy{I}{param}{I} = \dfrac{\sy{op}{out}{1\ \text{op}}}{\sy{by}{data}{3 \times 4\ \text{B}}}
I=112≈0.083 op per byteI = \dfrac{1}{12} \approx 0.083\ \text{op per byte}

Operations done for each byte moved.

Common mix-ups

MYTHA GPU with 8 times the lanes is 8 times faster.

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

Predict, then reveal
3 CHECKS · PRO
Q01With 1 CPU core instead of 32 lanes, is the add 32 times slower?

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.