A1.1.3 · Computer hardware and operation
CPU versus GPU
By the end you can
Explain how CPUs and GPUs differ in design, instructions, processing power, memory access and power efficiency, and how they divide tasks, share data and coordinate their work.
The CPU and the GPU are both processors: both fetch, decode and execute instructions on cores made of ALUs and registers. They differ because they are designed for opposite kinds of work. A CPU is built for low : finishing one task, full of decisions, as quickly as possible. A GPU is built for high : getting through an enormous amount of simple, similar work, even if each piece takes a little longer.
Each pixel is worked out on its own, so all the cores can work at once.
GPU wins, about 14× faster. Thousands of slower cores beat a few fast ones when the work splits into independent pieces. The cost of copying the data to the GPU is worth paying.
A simplified model: one operation per core per clock tick, with round figures. Real speeds depend on much more, but the pattern holds.
Design and core architecture#
A CPU spends its chip area on a few big cores, each able to run any kind of code fast. To avoid waiting, each core uses branch prediction (guessing which way an IF will go and starting early) and out-of-order execution (running instructions whose inputs are ready, rather than strictly in order), and keeps large caches close by. Its instruction set, the list of operations it understands, is broad: arithmetic, many kinds of jumps and comparisons, and instructions for managing the system.
A GPU spends the same area on thousands of small cores grouped so that many of them run the same instruction at once, each on different data. This is (single instruction, multiple data). Its instruction set is built around arithmetic and moving large blocks of data, plus special operations for graphics such as sampling textures. Branch-heavy code suits it badly: when cores in a group need to go different ways at an IF, some have to wait.
Processing power
How much work a processor gets through depends on three things: how many cores it has, its (ticks per second, in GHz), and how much each core does per tick. A CPU core runs at a high clock speed (often 4 to 5 GHz) and does a lot per tick, so it races through one sequence of instructions. A GPU core runs slower (around 2 GHz) and does less, but there are thousands of them, so on parallel work the total is many times the CPU's. Neither is simply “more powerful”: each is more powerful at its own kind of job.
Memory access
A CPU needs small amounts of data quickly and unpredictably, so it relies on a hierarchy of caches (A1.1.4) to keep latency low. With several cores sharing data, it also keeps their caches consistent. A GPU streams huge, regular blocks of data (images, textures, matrices) to thousands of cores, so what matters is bandwidth: dedicated moves many times more data per second than system RAM, even though each access takes longer.
Power efficiency
A large GPU under full load can draw several times the power of a CPU, which is why gaming graphics cards need big fans. But total power is not the same as efficiency. The useful measure is : work done for each unit of power. On parallel work a GPU does far more calculations per watt than a CPU, because its simple cores do not spend energy on prediction and reordering. On sequential work it is the other way round. Both save power when not busy by lowering their clock speed and voltage, and switching off idle cores.
| CPU | GPU | |
|---|---|---|
| Design aim | Low latency: finish one task, full of decisions, quickly | High throughput: get through a huge amount of similar work |
| Cores | Few (often 4–16 in a PC), each powerful and flexible | Hundreds to thousands, each simple |
| Instructions | Broad instruction set; complex branching and system control | Arithmetic on many data items at once (SIMD); graphics operations |
| Clever extras | Branch prediction, out-of-order execution, large caches | Massive parallelism, very high memory bandwidth |
| Memory | Caches (L1–L3) and system RAM: low latency | Dedicated VRAM, or shared RAM: high bandwidth |
| Power | Lower total draw; less efficient on parallel work | High total draw at full load; more work per watt on parallel tasks |
| Typical jobs | Operating system, input, game logic, most applications | Rendering, video, machine learning, simulations |
Working together#
Almost every real task uses both processors. Three things have to be managed:
Task division
The CPU stays in charge. It runs the operating system, handles input and output, and does the sequential, decision-heavy parts of a program. It hands the parts that apply the same operation to lots of independent data (shading pixels, multiplying matrices, filtering frames) to the GPU.
Data sharing
The GPU can only work on data it can reach. With a dedicated GPU, the data starts in main memory and the CPU must copy it across the into VRAM, then copy the results back. That bus is much slower than VRAM itself, so programs try to send data once and do as much work on it as possible; for a tiny job, the copying can take longer than the calculation. With an integrated GPU, as in most laptops and phones, the CPU and GPU share , so no copy is needed, at the cost of less bandwidth than dedicated VRAM.
CPU wins, about 3.4× faster.
Most of the GPU’s time goes on copying data, not calculating. Too little work per byte to be worth the trip.
Speeds are round illustrative figures of the right size, not measurements of a particular chip.
Coordinating execution
The CPU starts work on the GPU by launching a , a small program run once for each data item, through a framework such as CUDA or OpenCL, or a graphics API for drawing. The launch does not wait: the CPU carries on with other work while the GPU runs. Before the CPU uses the results it must synchronise, waiting until the GPU signals that it has finished. Otherwise it would read results that are only half done.
Example: one frame of a game
Input (CPU)
The player presses a key. The CPU reads it from the input device.Game logic (CPU)
The CPU updates the game state: moves the character, applies physics and collisions, runs the other characters’ AI. Sequential, decision-heavy work.Hand-over
The CPU sends the updated positions to the GPU (the models and textures are already waiting in VRAM) and issues the commands to draw the frame.Render (GPU)
Thousands of GPU cores transform the 3D models, apply textures, lighting and shadows, and produce the frame’s pixels in VRAM.Display and repeat
The finished frame goes to the screen. Meanwhile the CPU is already working on the next frame’s logic, 60 or more times a second.
Check yourself
CPU versus GPU
Quick questions, made fresh every time and marked here. Do a few until they feel easy.
Exam practice
Paper 1-style questions
6 questions · 22 marks
Write your answer as you would in the exam, then show the mark points and tick each one your answer made. These are our own questions in the style of the exam, not past-paper questions.
1.Compare the core architecture of a CPU and a GPU.
[4]Compare: Similarities and differences, about both things, point by point.
2.Explain why a GPU is better suited than a CPU to rendering video.
[3]Explain: Give reasons: say what happens AND why, or how one thing causes another.
3.Explain how data is shared between the CPU and a dedicated GPU, and why this can limit performance.
[3]Explain: Give reasons: say what happens AND why, or how one thing causes another.
4.Describe how the CPU coordinates work that it gives to a GPU.
[3]Describe: A detailed account: say what happens, step by step if it is a process.
5.Describe how the CPU and GPU work together when a player presses a key to move a character in a video game.
[3]Describe: A detailed account: say what happens, step by step if it is a process.
6.A video app applies a colour filter to every frame of a 4K video. Evaluate using the GPU, rather than the CPU, for this task.
[6]Evaluate: Weigh the strengths against the weaknesses (or the benefits against the costs) and reach a judgement that you back up.
In a nutshell
- CPU: a few powerful, flexible cores, built to finish one thing quickly (low latency): the operating system, game logic, decisions.
- GPU: thousands of simple cores running the same instruction on many data items at once (SIMD), built for high throughput: pixels, video, matrices.
- Processing power depends on cores, clock speed and work per tick. A CPU wins on one stream of decisions; a GPU wins on volume of identical work.
- Memory: CPUs rely on caches for low latency; GPUs rely on very high-bandwidth VRAM.
- Power: a GPU draws more power at full load, but does parallel work with less energy per operation (better performance per watt). Both slow down when idle to save power.
- Working together: the CPU divides the task, copies the data to VRAM over the PCIe bus (or shares unified memory), launches kernels on the GPU and waits for the results.
