In the book - Computer Organization and Design: The Hardware/Software Interface [RISC-V Edition] by Patterson and Hennessy, CPI is defined like this:
The term clock cycles per instruction, which is the average number of clock cycles each instruction takes to execute, is often abbreviated as CPI. Since different instructions may take different amounts of time depending on what they do, CPI is an average of all the instructions executed in the program. CPI provides one way of comparing two different implementations of the identical instruction set architecture, since the number of instructions executed for a program will, of course, be the same.
I am solving question 1.7 from the Exercises section of chapter 1:
1.7 Compilers can have a profound impact on the performance of an application. Assume that for a program, compiler A results in a dynamic instruction count of 1.0E9($I_A)$ and has an execution time of 1.1 s($T_A$), while compiler B results in a dynamic instruction count of 1.2E9($I_B)$ and an execution time of 1.5 s($T_B$).
a. Find the average CPI(both $CPI_A$ and $CPI_B$) for each program given that the processor has a clock cycle time of 1 ns.
b. 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($P_A$) running compiler A’s code versus the clock of the processor($P_B$) running compiler B’s code?
c. A new compiler C is developed that uses only 6.0E8 instructions($I_C$) and has an average CPI($CPI_C$) of 1.1. What is the speedup of using this new compiler versus using compiler A or B on the original processor?
Attempted Solution:
a.
Using the formula $T = I * CPI * CC$
where $CC = $ clock cycle time, I calculated part a of the question
$CPI_A = \frac{T_A}{I_A * CC_A} = 1.1$
Similarly, $CPI_B = 1.25$
b.
Given, execution times on two different processors are same
Again using the formula, I calculated
$\frac{T_A}{T_B} = \frac{I_A * CPI_A * CC_A}{I_B * CPI_B * CC_B}$
My task is to find $\frac{CC_A}{CC_B}$, which I am unable to, since I don't know the value of $CPI_A$ and $CPI_B$.
c.
Again, using the formula, I calculated
$\frac{T_A}{T_C} = \frac{I_A * CPI_A * CC_A}{I_C * CPI_C * CC_C}$
My task is to find $\frac{T_A}{T_C}$, which I am unable to, since I don't know the value of $CPI_A$. Here I know that, $CC_A = CC_C$, since the processor remains same.
In part b and part c of the solution, will the value of $CPI$ be same as that calculated in part a. If so, please explain why? What are the metrics on which $CPI$ depends. Does it not change with processor, or execution time, or any other metric?