Overview

1 Why Parallel programming?

The chapter opens by showing why parallel programming became necessary: for decades, software benefited from the “free lunch” of faster hardware, where the same code ran faster each year without changes. That era ended when CPU clock speeds hit a power and heat ceiling, forcing chip makers to stop relying on a single faster core and instead add more cores. As a result, the central challenge in modern computing is no longer just making one processor faster, but using many processing units effectively.

Parallel computing answers that challenge by spreading work across multiple processors, from CPU cores to the thousands of simple cores in a GPU. The chapter emphasizes that more hardware only helps when a problem can actually be divided into independent tasks, and it distinguishes data parallelism from task parallelism. Simple examples such as doubling an array show how GPUs can turn many separate operations into one coordinated burst of work, while problems like summation require more structured techniques, such as parallel reduction, to expose usable concurrency.

Not every problem benefits equally, because dependencies create sequential bottlenecks that limit speedup. The chapter explains this with Amdahl’s Law and Gustafson’s Law, which help estimate how much faster a program can become and when parallelization is worth the effort. It also motivates CUDA by explaining why GPUs, originally designed for graphics, are now ideal for large, repetitive, data-heavy workloads like AI, and why learning CUDA teaches broader parallel-thinking skills that transfer to other systems and frameworks.

Sequential processing: one core, one element at a time. A single CPU core works through a 1,000-element array step by step, doubling each value before moving on to the next. With only one core doing the work, the total number of steps equals the size of the data: 1,000 elements means 1,000 steps, and the time grows right along with it.
Sequential processing: one core, one element at a time. A single CPU core works through a 1,000-element array step by step, doubling each value before moving on to the next. With only one core doing the work, the total number of steps equals the size of the data: 1,000 elements means 1,000 steps, and the time grows right along with it.
Parallel processing: every element at once. A GPU assigns one thread per element, doubling all 1,000 values in parallel; the hardware schedules these thousands of threads onto its many CUDA cores.
Parallel processing: every element at once. A GPU assigns one thread per element, doubling all 1,000 values in parallel; the hardware schedules these thousands of threads onto its many CUDA cores.
Where the transistors go. A CPU devotes most of its silicon to control logic and cache, leaving room for only a few ALUs; a GPU gives a larger share of the same silicon to row upon row of small ALUs and connects to its DRAM through many more memory channels. The two designs are answers to opposite questions: finish one task fast? Or finish many tasks at once? The drawing is a schematic, not to scale; a real GPU still spends substantial silicon on control logic and cache, just a smaller share than a CPU does.
Where the transistors go. A CPU devotes most of its silicon to control logic and cache, leaving room for only a few ALUs; a GPU gives a larger share of the same silicon to row upon row of small ALUs and connects to its DRAM through many more memory channels. The two designs are answers to opposite questions: finish one task fast? Or finish many tasks at once? The drawing is a schematic, not to scale; a real GPU still spends substantial silicon on control logic and cache, just a smaller share than a CPU does.

Summary

  • Around 2005, heat killed the free lunch: single-core speed gains hit a physical ceiling.
  • Instead of one fast processor, use many working simultaneously. A modern laptop has 6–16 cores, high-end desktops well past 24; a GPU has thousands.
  • Parallel computing did not start with GPUs: MPI spreads work across separate machines, OpenMP across the cores of one CPU, and SIMD across values inside a single core. GPUs are the newest branch of that family, and they specialize in data parallelism: the same operation applied to many pieces of data at once.
  • Dependencies, not core count, decide how much of a problem can run at once. Before parallelizing anything, ask whether any task needs another task’s result before it can start.
  • Amdahl’s Law: the sequential parts of your code limit the overall speedup, no matter how many cores you throw at it. But Gustafson’s Law offers a brighter view: scale the problem size with the cores, and parallelism keeps paying off.
  • Thousands of simple processing units make GPUs well suited to massively parallel tasks like image processing, matrix math, and AI training.
  • CPUs and GPUs are partners: the CPU (the host) is built for low latency and runs your main program, while the GPU (the device) is built for high throughput and takes on the big parallel jobs.
  • A GPU pays off when a problem offers plenty of independent, identical work with regular memory access; small data, branch-heavy logic, and step-by-step dependencies favor the CPU. Match the tool to the task.
  • Learning CUDA teaches you parallel thinking that carries over to just about any parallel framework, including PyTorch.
  • swforces.com, a free online lab, lets you write real CUDA code and check that its logic is correct, no GPU of your own required.
  • Part 2 builds up the recurring parallel patterns (Map, Reduce, Scan, Histogram, and Stencil), and Part 3 turns to the performance techniques that make them run fast on real hardware.

FAQ

Why did the “free lunch” for programmers come to an end?It ended because single processors stopped getting much faster on their own. Around 2005, improvements in clock speed hit a physical limit: more speed meant more heat and power density than chips could safely handle. As a result, hardware could no longer deliver big performance gains automatically just by waiting for the next generation of CPUs.
What is the “power wall” in parallel programming?The power wall is the limit reached when increasing CPU clock speed creates too much heat for cooling systems to handle. Once transistors stopped becoming more power-efficient at the old pace, pushing one processor faster became impractical. That is why chip makers shifted toward multiple cores and parallel hardware instead of relying on one ever-faster core.
How did computing move from sequential to parallel processing?When single-core performance plateaued, the industry began using many processors at once instead of one faster processor. Modern CPUs now have multiple cores, and GPUs have thousands of smaller processing units. This shift made parallel programming essential for getting more work done in less time.
What is the difference between sequential and parallel thinking?Sequential thinking solves a problem one step at a time in order, while parallel thinking looks for work that can happen simultaneously. For example, doubling elements in an array is sequential on one core but parallel on a GPU. Parallel thinking asks how to split work so many tasks can run at once without depending on each other.
Why are GPUs so effective for parallel workloads?GPUs are built for high throughput, meaning they are designed to do many simple tasks at once. They contain thousands of small processing units and are optimized for problems with lots of independent, similar work. That makes them ideal for tasks like image processing, matrix math, and AI workloads.
What is the difference between CPU and GPU design goals?CPUs are optimized for low latency, so they aim to finish one task quickly and handle complex branching logic well. GPUs are optimized for high throughput, so they aim to finish many tasks at once, even if each individual task is slower. In short: CPUs are better for complex control flow, while GPUs are better for massive parallel data processing.
What kinds of problems are good candidates for parallelization?Problems with lots of independent work are the best candidates for parallelization. Examples include adding a value to every array element, converting pixels to grayscale, and many matrix operations. Problems with strong dependencies, like linked-list traversal or straightforward Fibonacci computation, are much harder to parallelize well.
What do Amdahl’s Law and Gustafson’s Law tell us about speedup?Amdahl’s Law says a fixed sequential portion limits the maximum speedup, no matter how many cores you add. Gustafson’s Law says if the problem size grows with the number of processors, speedup can keep increasing. Together, they help estimate whether parallelization is worth the effort before you write code.
Why did GPUs become important for more than graphics?GPUs were originally built to render graphics, which already requires huge amounts of independent computation, like calculating colors for millions of pixels. Researchers realized the same hardware could accelerate other workloads with similar structure, such as matrix multiplication and image processing. CUDA then made it practical to use GPUs for general-purpose computing.
Why should someone learn CUDA instead of only using high-level libraries?Learning CUDA teaches the underlying ideas of parallel programming, such as data parallelism, memory hierarchy, synchronization, and dependencies. That deeper understanding helps you diagnose performance problems and choose the right strategy when code is slow. Even if you later use higher-level frameworks, the skills transfer to many parallel systems.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Parallel Programming Grokking Parallel Programming ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Parallel Programming Grokking Parallel Programming ebook for free