cpu-time

How to calculate global CPI with dynamic instruction counts and determine which computer is faster?


Did I do this problem right? My answer is that P2(0.667ms) is faster than P1 (1.04ms). Which number is the global CPI?

1.6 [20] <§1.6> Consider two different implementations of the same instruction set architecture. The instructions can be divided into four classes according to their CPI (class A, B, C, and D). P1 clock rate of 2.5 GHz and CPIs of 1 (10%), 2 (20%), 3(50%), and 3 (20%). P2 clock rate of 3 GHz and CPIs of 2 (10%), 2 (20%), 2 (50%), and 2 (20%).

Given a program with a dynamic instruction count of 1.0E6 (1.0 * 10^6) instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D, which implementation is faster?

a. What is the global CPI for each implementation? Which is faster: P1 or P2?

CPU Time = CPU clock cycle/clock rate
CPU Clock Cycles = Sum of CPI * instruction count
Sum of each row, (A, B, C, D multiplied by IC and CPI)

P1 Clock Cycles = 1.0 * 10^6 dynamic instruction count * 1 CPI * 10% class A
               +1.0 * 10^6 dynamic instruction count * 2 CPI * 20% class B
               +1.0 * 10^6 dynamic instruction count * 3 CPI * 50% class C
               +1.0 * 10^6 dynamic instruction count * 3 CPI * 20% class D

P1 Clock Cycles = (0.1 CPI * 106 instruction count) + (0.4 CPI * 106 instruction count) + (1.5 CPI * 106 instruction count) + (0.6 CPI * 106 instruction count) = 2.6 * 10^6 Clock Cycles

P2 Clock Cycles = 1.0 * 10^6 dynamic instruction count * 2 CPI * 10% class A
               +1.0 * 10^6 dynamic instruction count * 2 CPI * 20% class B
               +1.0 * 10^6 dynamic instruction count * 2 CPI * 50% class C
               +1.0 * 10^6 dynamic instruction count * 2 CPI * 20% class D

P2 Clock Cycles = (0.2 CPI * 10^6 instruction count) + (0.4 CPI * 10^6 instruction count) + (1.0 CPI * 10^6 instruction count) + (0.4 CPI * 10^6 instruction count) = 2 * 10^6 Clock Cycles

P1 CPU Time = (2.6 * 10^6 Clock Cycles) / 2.5 GHz = 1.04 (10^6/10^9) = 1.04 * 10^-3 = 1.04ms
P2 CPU Time = (2 * 10^6 Clock Cycles) / 3 GHz = 1.04 (10^6/10^9) = 0.667 * 10^-3 = 0.667ms

P2 is faster than P1.

Solution

  • The answer was correct, I originally found some incorrect solutions online and became concerned with my own answer. This answer includes clarification on what the global CPI's for each computer were and more complete units:

    P1 CPU Time = (2.6 * 106 Clock Cycles) / 2.5 GHz = 1.04 (106/109) = 1.04 * 10-3 = 1.04ms, Global CPI is 2.6 cycles per instruction
    
    P2 CPU Time = (2 * 106 Clock Cycles) / 3 GHz = 0.667 (106/109) = 0.667 * 10-3 = 0.667ms, Global CPI is 2 cycles per instruction
    
    P2 is faster than P1.