Question about CPI(Cycle/instruction)

791 Views Asked by At

I am trying to understand the attached slide. I don't understand what the percentages mean. The professor calculated the CPI in an intuitive way, but I don't understand the idea behind it. Can you explain what CPI is and how to calculate it in this case?. I know that this is a engineering question, but it's also related to math.enter image description here

2

There are 2 best solutions below

5
On BEST ANSWER

The first bullet gives you your frame of reference. At the moment it appears that 50% of you instructions are "Integer ALU" and each of those requires 1 cycle; "Load" accounts for 20% of your instructions and takes 5 cycles; "Store" is 10% of your instructions and requires 1 cycle; and "Branch" is 20% of your instructions each requiring 2 cycles.

To see what your current CPI is you compute the expected amount of cycles for an instruction (essentially a weighted average).

\begin{align*} .5\times 1 + .2\times 5 + .1\times 1 + .2\times 2 &= 2 \\ \sum_{\text{instructions}} (\text{% of this instruction})\times (\text{cycles for this instruction}) &= \text{average cycles per instruction.} \end{align*} What that means is that the "average" instruction requires 2 cycles (here average accounts for the relative frequency of the instruction).

For calculation A you assume that "Branch" takes 1 cycle instead of 2. This is a speed up for "Branch" which makes up 20% of all your instructions. For calculation B you assume that "Load" takes 3 cycles instead of 5 ("Load" also takes up 20% of your cycles). You repeat the calculation with the new values and see which has the lower CPI.

You can intuitively predict that B will be better because you save 2 cycles on 20% of your instructions versus saving 1 cycle on 20% in case A...

0
On

CPI is cycles per instruction. The total number of clock cycles a processor takes on average to process a instruction (Fetch ,Decode ,Execute ,Memory ,Register-Write stages together make one instruction cycle. However these stages may require different number of clock cycles to complete that is they vary from instruction to instruction.)

In this case CPI for a particular instruction is given with the frequency of that instruction. The average CPI is jut the weighted average over given instructions. Hope this helps. However these types of questions are more suitable for stack overflow if you require prompt replies.