Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 72

Predicting Parallel Speedup: Amdahl's and Gustafson's Laws

Recommended resources

Hello! Welcome back to our final module on synthesis and exam preparation.

In the last lesson, we honed our quantitative analysis skills by calculating Average Memory Access Time (AMAT) for various cache configurations. We saw how to deconstruct a complex problem into manageable parts, a skill that is crucial for system performance analysis.

Today, we continue this focus on quantitative modeling but shift our attention from hardware performance to the theoretical limits of parallel software. We will address the learning outcome: Solve numerical problems applying Amdahl's Law and Gustafson's Law to predict parallel speedup. These two fundamental laws provide the upper and lower bounds on the performance gains you can expect from parallelization, making them essential tools for any systems engineer.

1. Speedup: The Ideal vs. The Reality

The primary goal of parallel computing is to solve a problem faster. We measure this improvement using speedup, defined as the ratio of the execution time on a single processor to the execution time on multiple processors:

Where is the sequential execution time and is the parallel execution time on processors.

Ideally, if we use processors, we might expect the program to run times faster, achieving linear speedup (). However, reality is more complex. Most programs contain portions that are inherently sequential—such as reading a file, initializing data structures, or parts of an algorithm that depend on previous steps. This unparallelizable part of the code becomes a bottleneck, a concept formalized by Amdahl's Law.

The following video provides an excellent introduction, starting with the ideal case and then explaining why the presence of serial code fundamentally limits potential speedup.

Amdahl's law and speedup in concurrent and parallel processing explained with example

To start, let's build an intuition for 'speedup' and why simply adding more processors doesn't always lead to a proportional performance increase.

Watch from 00:36 to 13:19. Focus on: The definition of ideal, linear speedup (00:36 - 04:58). The introduction of Amdahl's Law and the concepts of serial vs. parallel parts of a program (04:58 - 08:26). The derivation of the Amdahl's Law formula based on these parts (08:26 - 13:19).


2. Amdahl's Law: The Law of Diminishing Returns

As you just saw, Amdahl's Law provides a model for the speedup of a program with a fixed workload. It considers that a program is composed of a serial fraction () and a parallelizable fraction ().

The formula for Amdahl's Law is:

Here:

  • is the fraction of the program's original execution time that is sequential.
  • is the number of processors.

A crucial insight from Amdahl's Law comes from considering the limit as the number of processors becomes infinite (). The term goes to zero, leaving:

This means that if 20% of your program is serial (), the maximum possible speedup you can ever achieve is , no matter how many processors you throw at the problem. The serial part becomes the ultimate bottleneck.

This next video offers a concise, formal presentation of the law and visualizes this limiting behavior.

Computer Architecture Performance: Part 2: Amdahl's Law and Gustafson's Law

The previous video gave a great conceptual derivation. Now, let's watch a summary that formally presents Amdahl's law and its important limiting behavior.

Watch from 01:49 to 06:44. Pay attention to: The formal equation for Amdahl's Law (01:49 - 02:57). The explanation of the limit as the number of processors goes to infinity (02:57 - 04:36). The plots visualizing how speedup is limited by the serial fraction f (04:36 - 06:44).

Practice Problem: Applying Amdahl's Law

Let's work through a typical problem. Here, we'll use the law to determine the minimum number of processors in a machine given its performance.

Exam Preparation - Problem 2: Amdahl's Law

This exam preparation guide contains a problem where we must work backward from a known speedup to find the minimum number of processors required.

Read 'Problem 2: Amdahl's Law'. Pay close attention to the setup and the algebraic steps used to isolate the variable 'p' (processors).

Let's break down the solution:

  1. Identify Knowns:
    • Parallelizable work = 75%, so the non-parallelizable (serial) fraction .
    • Sequential runtime hours.
    • Parallel runtime hours.
  2. Calculate Actual Speedup:
    • The measured speedup is .
  3. Apply Amdahl's Law:
    • We know the actual speedup (2) must be less than or equal to the theoretical maximum predicted by the formula.
  4. Solve for p:
    • Your background in mathematics makes this kind of algebraic manipulation straightforward. We need to solve the inequality for .

    • The machine must have at least 3 processors.

3. Gustafson's Law: A Scaled Perspective

Amdahl's Law paints a somewhat pessimistic picture, suggesting that speedup is strictly limited. However, its assumption of a fixed problem size doesn't always hold. Often, with more processors, we want to solve a bigger problem (e.g., higher resolution simulation, larger dataset) in the same amount of time.

This is the premise of Gustafson's Law, which models scaled speedup. It assumes the parallel part of the workload scales with the number of processors, while the serial part remains fixed.

The formula is:

Here, has a slightly different meaning: it's the fraction of execution time spent in the serial part of the parallel execution. Under this model, speedup grows almost linearly with .

Computer Architecture Performance: Part 2: Amdahl's Law and Gustafson's Law

Gustafson's Law offers a different, often more optimistic, perspective by changing the core assumption about the problem size.

Watch from 09:11 to 11:51. This section introduces Gustafson's Law, explains its assumption of scaled problem size, and contrasts its formula and results with Amdahl's Law.

Practice Problem: Applying Gustafson's Law

Let's solve a problem using this new law. Notice the calculation is a direct equality.

Exam Preparation - Problem 1: Gustafson's Law

This problem demonstrates a straightforward application of Gustafson's Law.

Read 'Problem 1: Gustafson's Law' and follow the direct application of the formula to calculate the scaled speedup.

As the resource shows, with and :


  • The scaled speedup is 9.

4. Comparing the Laws and Solving More Problems

The key difference lies in the assumptions:

  • Amdahl's Law: Fixed workload. Answers: "How much faster will my program run?"
  • Gustafson's Law: Scaled workload (fixed time). Answers: "How much more work can my program do?"

This next resource provides a fantastic, formal explanation of this difference.

Task 2 – Amdahl’s and Gustafson’s Law

The difference between these two laws is crucial. This document from ETH Zurich provides a concise and formal explanation of their different underlying assumptions.

Read all of Task 2. First, compare the speedup results from parts (a) and (b) for the same serial fraction. Then, carefully read part (c) and the 'A more formal explanation' that follows. This directly contrasts the fixed-work assumption of Amdahl with the scaled-work assumption of Gustafson.

The following plot visually captures this fundamental difference. Amdahl's Law shows speedup flattening towards an asymptote, while Gustafson's Law shows a nearly linear increase.

Amdahl's Law vs Gustafson's Law Speedup Comparison
This plot compares the speedup predicted by Amdahl's Law (solid lines) and Gustafson's Law (dashed lines) for various serial fractions (f). Amdahl's curves plateau, limited by 1/f, while Gustafson's curves show that scaled speedup continues to grow with the number of processors.

Advanced Problem Solving

Let's tackle two more complex problems to solidify your understanding.

A. Finding the Serial Fraction

Sometimes you know the speedup and need to deduce the serial fraction.
Let's use the problem from Task 3b in the ETH Zurich PDF (LINK):

  • Question: A program shows a speedup of 3 on 4 cores. What is the serial fraction f according to Amdahl's Law?

  • Solution:

    1. Start with Amdahl's formula:
    2. Substitute known values: , .
    3. Solve for :

      To clear the fraction, multiply the terms in the parenthesis by 4:





      The serial fraction of the program is approximately 11.1%.

B. Combining Speedup with System Parameters

Real-world performance depends on more than just processor count. This next problem integrates CPU frequency, another key parameter.

Exam Preparation - Problem 5: Comparing Machines

Let's tackle a scenario that mirrors a realistic decision-making process. This problem requires you to use Amdahl's Law and also account for CPU clock frequency.

Read 'Problem 5: Comparing Machines (Amdahl + Frequency)'. Follow the logic of first calculating the parallel speedup for each machine and then factoring in the clock frequency to find the overall performance improvement.

Let's review the logic. To compare the two machines against the baseline (1 processor at 1 GHz), we need a total performance factor that combines parallel speedup and frequency improvement.

  • Serial Fraction:
  • Baseline: 1 processor, 1 GHz frequency.

Machine A (2 processors, 3 GHz):

  1. Parallel Speedup (Amdahl):
  2. Frequency Speedup:
  3. Overall Performance Factor:

Machine B (5 processors, 2 GHz):

  1. Parallel Speedup (Amdahl):
  2. Frequency Speedup:
  3. Overall Performance Factor:

Conclusion: Since , Machine A will run the program faster, even though it has fewer cores. Its higher clock frequency more than compensates for its lower parallel speedup.


Conclusion

In this lesson, we explored two fundamental models for predicting parallel performance. You learned how to apply their formulas to solve numerical problems, a key skill for analyzing scalable systems.

Key Takeaways:

  • Amdahl's Law models speedup for a fixed-size problem and shows that performance is ultimately limited by the serial fraction ().
  • Gustafson's Law models speedup for a problem that scales with processors (scaled speedup) and provides a more optimistic view of parallel performance ().
  • Choosing the correct law depends on the problem's context: are you trying to solve the same problem faster (Amdahl) or solve a bigger problem in the same amount of time (Gustafson)?
  • Real-world performance analysis often requires combining these models with other system parameters, like CPU frequency.

In our next lesson, we will move from these high-level theoretical models to the nitty-gritty of code. You will learn to analyze C++ code fragments to identify data dependencies, race conditions, and performance bottlenecks—the very issues that create the "serial fraction" we've been modeling today.