Imagine calculating the color of every pixel in a 1920×1080 frame. That is more than two million calculations, and most pixels do not need to wait for another pixel’s result. Doing many independent operations across a large dataset at once is massively parallel computation. section 1.6
GPUs are designed to run thousands of simple processing units for high throughput, so they suit work such as image processing, matrix math, and AI training. Before parallelizing, check dependencies: if one task needs another task’s result, it cannot start independently. Small datasets, branch-heavy logic, and step-by-step work often favor the CPU. section 1.6 section 1.10
Pixels in a frame
Pixel #500,000 generally does not need to wait for pixel #1: their colors can be calculated independently, making frame rendering a natural parallel workload. section 1.6
Table 1.2 Contrasting CPU and GPU design philosophies.
|
|
CPU (Master
Chef)
|
GPU
(Thousand Cooks)
|
|
Cores
|
6–24 on
typical desktops
|
Thousands
of simple processing units
|
|
Design Goal
|
Low Latency
(Finish each task fast)
|
High
Throughput (Finish many tasks at once)
|
|
Analogy
|
A chef
preparing a complex 7-course meal
|
1,000
workers rolling 1,000 burritos at once
|
|
Best For
|
OS, Web
Servers, Complex Logic, and any single-threaded task where one fast core wins
|
Matrix
Math, Image Processing, AI, and many more parallel patterns you’ll discover
in this book
|
Compare the CPU’s low-latency design with the GPU’s high-throughput design, and see which kinds of work each suits. section 1.6
