Exercises from Patterson and Hennessy

Exercise 2.18

a. CPI is calculated as the weighted average of the CPIs of all of the instructions.

CPIbase = 2 x .4 + 3 x .25 + 3 x .25 + 5 x .1 = 2.8

b.

CPIopt = 2 x .4 + 2 x .25 + 3 x .25 + 4 x .1 = 2.45

Exercise 2.19

            instructions
MIPS =  --------------------
        execution time x 106

execution time = instructions x CPI x cycle time

                    instructions
MIPS =  -------------------------------------
        instructions x CPI x cycle time x 106

                    instructions 1
     =  -------------------------------------
        instructions x CPI x cycle time x 106

                  1
cycle time = ----------
             clock rate

                  1
MIPS =  ----------------------
                   1
        CPI x ---------- x 106
              clock rate

        clock rate
      = ----------
        CPI x 106

           500 x 106
MIPSbase = ---------
           2.8 x 106

          600 x 106
MIPSopt = ----------
          2.45 x 106

Exercise 2.20

execution time = instructions x CPI x cycle time

          execution timebase
speedup = ------------------
          execution timeopt

          instructions x CPIbase x cycle timebase
        = --------------------------------------
          instructions x CPIopt x cycle timeopt

We have to assume the same number of instructions are executed by the two machines or we will not have enough information to answer the question.

          instructions x CPIbase x cycle timebase
        = --------------------------------------
          instructions x CPIopt x cycle timeopt

          CPIbase x cycle timebase
        = -----------------------
          CPIopt x cycle timeopt

                  1
cycle time = ----------
             clock rate

              CPIbase
          -------------
          clock ratebase
speedup = -------------
              CPIopt
          ------------
          clock rateopt

             2.8
          ---------
          500 x 106
        = ---------
            2.45
          ---------
          600 x 106

Exercise 2.21

      execution cycles
CPI = ----------------
        instructions

Let I be the total number of instructions executed by Mbase. The new numbers of classes of instructions are:

A: I x 40% x 90% = 0.36   x I
B: I x 25% x 90% = 0.225  x I
C: I x 25% x 85% = 0.2125 x I
D: I x 10% x 95% = 0.095  x I

New total number of instructions = 0.36 x I + 0.225 x I + 0.2125 x I + 0.095 x I

          2 x 0.36 x I + 3 x 0.225 x I + 3 x 0.2125 x I + 5 x 0.095 x I
CPIcomp = --------------------------------------------------------------
                  0.36 x I + 0.225 x I + 0.2125 x I + 0.095 x I

          (2 x 0.36 + 3 x 0.225 + 3 x 0.2125 + 5 x 0.095) x I
        = ---------------------------------------------------
                  (0.36 + 0.225 + 0.2125 + 0.095) x I

Exercise 2.22

          execution timebase
speedup = ------------------
          execution timecomp

          instructionsbase x CPIbase x cycle timebase
        = -----------------------------------------
          instructionscomp x CPIcomp x cycle timecomp

cycle timebase = cycle timecomp

                      I x 2.85 x cycle timebase
        = -------------------------------------------------------------
          (0.36 + 0.225 + 0.2125 + 0.095) x I x CPIcomp x cycle timecomp

Exercise 2.23

          (2 x 0.36 + 2 x 0.225 + 3 x 0.2125 + 4 x 0.095) x I
CPIcomp = ----------------------------------------------------
                (0.36 + 0.225 + 0.2125 + 0.095) x I

          execution timebase
speedup = ------------------
          execution timeboth

          instructionsbase x CPIbase x cycle timebase
        = -----------------------------------------
          instructionsboth x CPIboth x cycle timeboth

Exercise 2.24

The performance of a competitor's machine after n months is 1.034n times as fast as the original machine. The performance of the optimized machines must be at least as great as 1.034n.