Amdhal's Law

download Amdhal's Law

of 3

description

MM..............

Transcript of Amdhal's Law

  • 40 Chapter 1 Fundamentals of Computer Design

    ative weightings explicit and will predict execution time of a workload with thatmix. The problem above of unspecied inputs is best solved by specifying the in-puts when comparing performance. If results must be normalized to a specicmachine, rst summarize performance with the proper weighted measure andthen do the normalizing.

    Lastly, we must remember that any summary measure necessarily loses infor-mation, especially when the measurements may vary widely. Thus, it is importantboth to ensure that the results of individual benchmarks, as well as the summarynumber, are available. Furthermore, the summary number should be used withcaution, since the summaryas opposed to a subset of the individual scoresmaybe the best indicator of performance for a customers applications.

    Now that we have seen how to dene, measure, and summarize performance, wecan explore some of the guidelines and principles that are useful in design andanalysis of computers. In particular, this section introduces some important ob-servations about designing for performance and cost/performance, as well as twoequations that we can use to evaluate design alternatives.

    Make the Common Case FastPerhaps the most important and pervasive principle of computer design is tomake the common case fast: In making a design trade-off, favor the frequent caseover the infrequent case. This principle also applies when determining how tospend resources, since the impact on making some occurrence faster is higher ifthe occurrence is frequent. Improving the frequent event, rather than the rareevent, will obviously help performance, too. In addition, the frequent case is of-ten simpler and can be done faster than the infrequent case. For example, whenadding two numbers in the CPU, we can expect overow to be a rare circum-stance and can therefore improve performance by optimizing the more commoncase of no overow. This may slow down the case when overow occurs, but ifthat is rare, then overall performance will be improved by optimizing for the nor-mal case.

    We will see many cases of this principle throughout this text. In applying thissimple principle, we have to decide what the frequent case is and how much per-formance can be improved by making that case faster. A fundamental law, calledAmdahls Law, can be used to quantify this principle.

    Amdahls LawThe performance gain that can be obtained by improving some portion of a com-puter can be calculated using Amdahls Law. Amdahls Law states that the per-formance improvement to be gained from using some faster mode of execution islimited by the fraction of the time the faster mode can be used.

    1.6 Quantitative Principles of Computer Design

  • 1.6 Quantitative Principles of Computer Design 41

    Amdahls Law denes the speedup that can be gained by using a particularfeature. What is speedup? Suppose that we can make an enhancement to a ma-chine that will improve performance when it is used. Speedup is the ratio

    Speedup =

    Alternatively,

    Speedup =

    Speedup tells us how much faster a task will run using the machine with the en-hancement as opposed to the original machine.

    Amdahls Law gives us a quick way to nd the speedup from some enhance-ment, which depends on two factors:

    1. The fraction of the computation time in the original machine that can beconverted to take advantage of the enhancementFor example, if 20seconds of the execution time of a program that takes 60 seconds in total canuse an enhancement, the fraction is 20/60. This value, which we will callFractionenhanced, is always less than or equal to 1.

    2. The improvement gained by the enhanced execution mode; that is, how muchfaster the task would run if the enhanced mode were used for the entire pro-gramThis value is the time of the original mode over the time of the en-hanced mode: If the enhanced mode takes 2 seconds for some portion of theprogram that can completely use the mode, while the original mode took 5 sec-onds for the same portion, the improvement is 5/2. We will call this value,which is always greater than 1, Speedupenhanced.

    The execution time using the original machine with the enhanced mode will bethe time spent using the unenhanced portion of the machine plus the time spentusing the enhancement:

    Execution timenew = Execution timeold

    The overall speedup is the ratio of the execution times:

    Speedupoverall = =

    E X A M P L E Suppose that we are considering an enhancement to the processor of a server system used for web serving. The new CPU is 10 times faster on computation in the web serving application than the original processor. Assuming that the original CPU is busy with computation 40% of the time

    Performance for entire task using the enhancement when possiblePerformance for entire task without using the enhancement

    Execution time for entire task without using the enhancementExecution time for entire task using the enhancement when possible

    1 Fractionenhanced( )FractionenhancedSpeedupenhanced----------------------------------------+

    Execution timeoldExecution timenew--------------------------------------------

    1

    1 Fractionenhanced( )FractionenhancedSpeedupenhanced--------------------------------------+

    ------------------------------------------------------------------------------------------------

  • 42 Chapter 1 Fundamentals of Computer Design

    and is waiting for I/O 60% of the time, what is the overall speedup gained by incorporating the enhancement?

    A N S W E R Fractionenhanced = 0.4

    Speedupenhanced = 10

    Speedupoverall = = 1.56

    n

    Amdahls Law expresses the law of diminishing returns: The incremental im-provement in speedup gained by an additional improvement in the performanceof just a portion of the computation diminishes as improvements are added. Animportant corollary of Amdahls Law is that if an enhancement is only usable fora fraction of a task, we cant speed up the task by more than the reciprocal of 1minus that fraction.

    A common mistake in applying Amdahls Law is to confuse fraction of timeconverted to use an enhancement and fraction of time after enhancement is inuse. If, instead of measuring the time that we could use the enhancement in acomputation, we measure the time after the enhancement is in use, the resultswill be incorrect! (Try Exercise 1.2 to see how wrong.)

    Amdahls Law can serve as a guide to how much an enhancement will im-prove performance and how to distribute resources to improve cost/performance.The goal, clearly, is to spend resources proportional to where time is spent. Am-dahls Law is particularly useful for comparing the overall system performanceof two alternatives, but it can also be applied to compare two CPU design alterna-tives, as the following Example shows.

    E X A M P L E A common transformation required in graphics engines is square root. Im-plementations of oating-point (FP) square root vary signicantly in per-formance, especially among processor designed for graphics. Suppose FP square root (FPSQR) is responsible for 20% of the execution time of a critical graphics benchmark. One proposal is to enhance the FPSQR hardware and speed up this operation by a factor of 10. The other alter-native is just to try to make all FP instructions in the graphics processor run faster by a factor of 1.6; FP instructions are responsible for a total of 50% of the execution time for the application. The design team believes that they can make all FP instructions run 1.6 times faster with the same effort as required for the fast square root. Compare these two design al-

    1

    0.6 0.410-------+---------------------

    10.64----------