0706.205.01 Computer Organization

Exercise Set A

Performance Algebra


Preparation

Patterson & Hennessy. Chapter 2

The key to handling word problems relating to performance is to remember a few definitions (CPI, clock rate vs. clock cycle, execution time vs. performance) and the following equation, as seen in The Big Picture on p.63 of the text:

CPU execution time  = 
Instructions

Program
x
Clock cycles

Instruction
x
Seconds

Clock cycle

The following questions can be recast as applications of this formula. However, how to do the recasting can be subtle.

Questions

  1. Suppose we have two implementations (A and B) of the same instruction set architecture. Machine A has a clock cycle time of 1ns and a CPI of 2.0 for a program. Machine B has a clock cycle time of 2ns and a CPI of 1.4 for a program. Which machine is faster for this program, and by how much?

    Drag the mouse over the space below to see the answer.

    Remember that CPI is defined as the average number of clock cycles expended per instruction for a particular program execution. It is not a general measure. But looking back at our equation above, we see that the second term is CPI. Further, the first term of the equation is the same for both executions (on Machine A and on Machine B). We are asked which machine is faster, that is, which has the shorter execution time.

    CPU timeA = InstructionsA x CPIA x 1ns
      = InstructionsA x 2.0 x 1ns
      = InstructionsA x 2.0 ns
        
    CPU timeB = InstructionsB x CPIB x 2ns
      = InstructionsB x 1.4 x 2ns
      = InstructionsB x 2.8 ns

    To determine how much slower Machine B is than Machine A, we divide the execution time of B by the execution time of A. Note that because both machines are running the same program, that the number of instructions in each execution is the same.

    Execution timeB

    Execution timeA
    =
    Instructions x 2.8 ns

    Instructions x 2.0 ns
    =
    2.8 ns

    2.0 ns
    = 1.4

    So Machine A runs this program 1.4 times faster than Machine B.

  2. Both Machine B and Machine C execute a certain program in the same amount of time. Machine B has a clock cycle time of 2ns and a CPI of 1.4 (for the program), while Machine C has a clock cycle time of 1ns and CPI of 1.8. How many more instructions does Machine C execute relative to Machine B?

    Drag the mouse over the space below to see the answer.

    CPU timeB = InstructionsB x CPIB x 2ns
      = InstructionsB x 1.4 x 2ns
      = InstructionsB x 2.8 ns
        
    CPU timeC = InstructionsC x CPIC x 1ns
      = InstructionsC x 1.8 x 1ns
      = InstructionsC x 1.8 ns

    But the question stated that the program runs in the same time on both machines. So, CPU timeB and CPU timeC are the same.

    InstructionsB x 2.8 ns = InstructionsC x 1.8 ns

    InstructionsC

    InstructionsB
    =
    2.8 ns

    1.8 ns
    = 1.55...

    So Machine C executes 1.55 times more instructions than Machine B to execute the same program in the same time.

  3. You have two machines running the same processor, differing only in clock rate. As an experiment you run the same compiled program on the two machines. On Machine D, the programs runs in 5 seconds; on Machine E, 4 seconds. Which machine has the faster clock rate, and how much faster.

    Drag the mouse over the space below to see the answer.

    First, you can assume that the Instruction count and the CPI (for the program) rae the same on both machines. Second, note that the third term of the equation (seconds / clock cycle) is the inverse of clock rate. That leaves us with the following equations:

    CPU timeD = Instructions x CPI x
    Seconds

    Clock cycleD
    5 sec = Instructions x CPI x
    1

    Clock rateD
                            
    CPU timeE = Instructions x CPI x
    Seconds

    Clock cycleE
    4 sec = Instructions x CPI x
    1

    Clock rateE

    Merging the two equations, we get:

    5 sec x Clock rateD = 4 sec x Clock rateE

    Thus,

    Clock rateE = 1.2 x Clock rateD

    That is, Machine E processor's clock rate is 1.2 times that of Machine D.