When you're dealing with parallel computing, one of the main goals is to improve the performance of your system. The most common way to measure this improvement is by calculating speedup, and Amdahl's Law is a mathematical model that helps us understand the theoretical limits of speedup when using parallel systems.
Let’s dive into each concept:
Speedup is a measure of how much faster a parallel system can solve a problem compared to a single processor or a non-parallel system. It’s defined as the ratio of the time it would take to complete a task using a single processor (serial time) to the time it takes using multiple processors (parallel time).
Where:
Imagine a task that takes 10 hours on a single processor. Now, if we use 4 processors and the task takes 3 hours, the speedup is:
So, the task is 3.33 times faster with 4 processors.
Amdahl's Law helps us understand the theoretical maximum speedup we can achieve from parallelizing a task. It is especially useful in understanding the limitations of parallelism — in other words, even though you add more processors, you may not get a proportional increase in speed due to parts of the task that cannot be parallelized.
Where:
Suppose a task consists of two parts:
Now, let’s see the speedup when using different numbers of processors:
Using 1 processor:
The speedup is just 1 (no parallelism).
Using 4 processors:
With 4 processors, the speedup is 2.86.
Using 16 processors:
With 16 processors, the speedup is 7.14.
As you can see from the example, even though you add more processors, the speedup doesn't grow linearly. The 10% of the task that must remain serial limits the maximum speedup. No matter how many processors you use, the speedup will be constrained by that serial portion.
Amdahl’s Law is crucial in understanding the limits of parallelism. Here are some important takeaways:
The serial part is the bottleneck: If a significant portion of your task cannot be parallelized, it will limit the benefits of adding more processors. For instance, if only 50% of your task can be parallelized, you won’t see much speedup, no matter how many processors you use.
Diminishing returns: As you add more processors, the increase in speedup decreases. After a certain point, adding more processors may not provide significant benefits. This is why parallel computing is most effective for problems where the parallelizable portion is large, and the serial portion is small.
Balance between parallel and serial work: The more work you can make parallel, the better your performance will be. But if most of the work is serial, then parallelizing may not give you much of an improvement.
Let’s consider a real-world example to see how Amdahl's Law works. Suppose you're working on a scientific simulation, and you find that 95% of the code can be parallelized, while 5% of it is inherently serial (perhaps due to dependency on previous calculations or I/O operations).
Let’s calculate the speedup using Amdahl's Law for different numbers of processors:
For 10 processors:
For 100 processors:
As you can see, even with 100 processors, the speedup is only 16.67x due to the 5% of the task that cannot be parallelized. This demonstrates the law of diminishing returns—adding more processors yields progressively smaller improvements when a large part of the task is serial.
While Amdahl’s Law provides an important theoretical model, in real-world systems, other factors can also affect speedup:
By using Amdahl’s Law, you can assess whether it's worth investing in more processors for a given task, and how much improvement you can expect from parallelizing your code.
Open this section to load past papers