CSCI 370 Computer Architecture: Homework 1 Solutions

Due date: On or before Monday, February 12, 2024
Absolutely no copying others’ works
Name: _____Professor Hu_____

  1. Consider two different processors P1 and P2 executing the same instruction set with the clock rates and CPIs given in the following table:

    Processor Clock Rate CPI
    P1 2.5 GHz 2.0
    P2 2.0 GHz 1.5

    1. (15%) Which processor has the higher performance expressed in instructions per second?
      Ans>
           Clock rate ÷ CPI
        ⇒ (cycles/second) ÷ (cycles/instruction)
        =  instructions/second
        
           Clock rateP1 ÷ CPIP1 = ( 2.5×109 ) ÷ 2.0 = 1.25×109 instructions/second
           Clock rateP2 ÷ CPIP2 = ( 2.0×109 ) ÷ 1.5 = 1.33×109 instructions/second
        Therefore, P2 has the higher performance.

    2. (20%) If the processors each execute a program in 15 seconds, find the number of cycles and the number of instructions.
      Ans>
           Number of instructionsP1
         = 1.25×109 instructions/second × 15 seconds
         = 1.875 × 1010 instructions
        
           Number of instructionsP2
         = 1.33×109 instructions/second × 15 seconds
         = 1.995 × 1010 instructions
        
           Number of clock cyclesP1
         = Number of instructionsP1 × CPI
         = 1.875×1010 instructions × 2.0 cycles/instruction
         = 3.75×1010 cycles
        
           Number of clock cyclesP2
         = Number of instructionsP2 × CPI
         = 1.995×1010 instructions × 1.5 cycles/instruction
         = 2.9925×1010 cycles
    3. (20%) We are trying to reduce the execution time (15 seconds) by 15% but this leads to an increase of 10% in the CPI. What clock rate should we have to get this time reduction?
      Ans>
          Execution timenew = Execution timeold × 0.85 = 15 seconds × 0.85 = 12.75 seconds
      
          CPInew = CPIold × 1.10
      
          CPIP1 = 2.0 × 1.10 = 2.20
          CPIP2 = 1.5 × 1.10 = 1.65
      
          Clock rate = Number of instructions × CPI ÷ Execution time
      
          Clock rateP1
        = (1.875×1010 instructions) × (2.20 cycles/instruction) ÷ (12.75 seconds)
        = 3.24×109 cycles/second
        = 3.24 GHz
      
          Clock rateP2
        = (1.995×1010 instructions) × (1.65 cycles/instruction) ÷ (12.75 seconds)
        = 2.58×109 cycles/second
        = 2.58 GHz
  2. Compilers can have a profound impact on the performance of an application. Consider the following two compilers for a program:

    Compiler A Compiler B
    Instruction count Execution time Instruction count Execution time
    2.0×109 2.0 s 1.0×109 2.5 s

    1. (15%) Find the average CPI for each program given that the processor has a clock cycle time of 2 ns (or 2×10-9 s).
      Ans>
           Average CPIA
        = CPU timeA / (Instruction countA × Clock cycle timeA)
        = 2.0 s / (2.0×109 instructions × 2×10-9 s/cycle)
        = 0.50 cycles/instruction

           Average CPIB
        = CPU timeB / (Instruction countB × Clock cycle timeB)
        = 2.5 s / (1.0×109 instructions × 2×10-9 s/cycle)
        = 1.25 cycles/instruction

    2. (15%) Assume the compiled programs run on two different processors. If the execution times on the two processors are the same, how much faster is the clock of the processor running compiler A’s code versus the clock of the processor running compiler B’s code?
      Ans>
           Clock rateA / Clock rateB (or Clock cycle timeB / Clock cycle timeA)
        = [(CPIA × Instruction countA) / CPU time] / [(CPIB × Instruction countB) / CPU time]
        = (0.50 cycles/instruction × 2.0×109 instructions) /
           (1.25 cycles/instruction × 1.0×109 instructions)
        = 0.80

        Therefore, the processor A is 0.80 times faster than the processor B.

    3. (15%) A new compiler is developed that uses 4.5×108 instructions and has an average CPI of 3.0. What is the speedup of using this new compiler versus using Compiler A on the original processor?
      Hint: The speedup here is equal to TA/Tn where
      • TA: the execution time by using the A compiler and
      • Tn: the execution time by using the new compiler.
      Ans>
           TA/Tn
        = (Instruction countA × CPIA × Clock cycle timeA) /
           (Instruction countn × CPIn × Clock cycle timen)
        = (2.00×109 instructions × 0.5 cycles/instruction × 2×10-9 s/cycle) /
           (0.45×109 instructions × 3.0 cycles/instruction × 2×10-9 s/cycle)
        = 0.74