1
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Cycle per instruction. I put the definition in the title $\endgroup$ Commented Sep 30, 2016 at 18:13

2 Answers 2

1
$\begingroup$

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...

$\endgroup$
5
  • $\begingroup$ If "weighted average" is unclear, I can specify what that means (and why it is one) in greater detail. $\endgroup$
    – TravisJ
    Commented Sep 30, 2016 at 18:24
  • $\begingroup$ where is weighted average used in this exercise? $\endgroup$ Commented Sep 30, 2016 at 18:39
  • $\begingroup$ @TheMathNoob, If you assumed every operation occurred with the same frequency, then since there are 4 operations your CPI would be $\frac{1+5+1+2}{4}=2.25$ (a strict average). Here you compute $\frac{1}{2}\times 1 + \frac{1}{5}\times 5 + \frac{1}{10}\times 1 + \frac{1}{5}\times 2 = 2$. It is a weighted average because the frequencies sum to 1 (or %'s sum to 100). $\endgroup$
    – TravisJ
    Commented Sep 30, 2016 at 19:02
  • $\begingroup$ ohhhh right, or in the first case we can do it like $1/4*4+1/4*5+1/4*1+1/4*2$ $\endgroup$ Commented Sep 30, 2016 at 19:04
  • $\begingroup$ @TheMathNoob, yes exactly. Then the updated calculation keeps the proportions (weights) the same, but adjust their cycle counts. In principle you could also change the CPI by finding ways to adjust the proportion of time you use the operations (use cheap operations more often for example). That would cause you to change the weights for the weighted average. $\endgroup$
    – TravisJ
    Commented Sep 30, 2016 at 19:16
0
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .