Chapter 11

CPU vs. GPU

Chapter 10 ended with a problem: rendering millions of pixels, 60 times a second, is a massive and repetitive job. Two different kinds of chips can do it — but only one of them is actually built for that scale.

CPU: a few powerful workers

A CPU (Central Processing Unit) typically has somewhere between 4 and 16 cores. Each one is fast, flexible, and great at handling one complex task at a time — or jumping between very different tasks in sequence, the way you'd work through a to-do list one item at a time.

CPU — a handful of cores, taking turns

Watch the cores take turns — one task at a time, handled quickly.

GPU: thousands of simple workers

A GPU (Graphics Processing Unit) has thousands of much simpler cores. Individually, each one is weaker than a CPU core — but they can all run the same simple instruction on different pieces of data, all at once. "Set this pixel's color" is one instruction; a GPU can apply it to a million pixels simultaneously.

GPU — thousands of cores, all at once

Every core lights up together — same instruction, applied everywhere at once.

See the difference

Below is a 24×24 grid — 576 pixels, like a tiny corner of your screen from Chapter 10. Fill it in two different ways and compare.

Interactive — CPU vs. GPU Race
CPU:  ·  GPU:

Where each one shines

CPUGPU
Running your operating systemRendering 3D games and video
Loading a webpage, running app logicProcessing video effects and editing
Decision-heavy, branching tasksThe same simple math, repeated millions of times

That last row is why GPUs turned out to be surprisingly good at AI. Training a neural network is, underneath it all, the same kind of pattern — a huge number of simple calculations, all independent, all able to run at once. The chip built for pixels turned out to be built for that too.

Go Deeper