-1
$\begingroup$

Please, help me to understand the mathematics behind the following formula of CPI. Why do we calculate CPI the way it's done on the pic?enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ What's CPI? Please make your question self-contained by defining the relevant terms, and please replace the image by text so your question is searchable and accessible to partially sighted people. $\endgroup$ Feb 7 '15 at 19:43
  • $\begingroup$ What self-study have you done? CPI is explained in many architecture textbooks. There is little point in us repeating that explanation here. We expect you to do a significant amount of self-study before asking, so you can ask a more informed question.... $\endgroup$
    – D.W.
    Feb 8 '15 at 2:13
  • $\begingroup$ It looks like it is just the average number of cycles per instruction. $\endgroup$ Jun 22 '15 at 12:46
3
$\begingroup$

CPI is the average number of cycles per instruction. The CPI is the expected value of $C(R)$, where $R$ is a random instruction, and for an instruction $r$, $C(r)$ is the number of clock cycles that $r$ takes. The table gives you the distribution of $R$ and the function $C$, from which you can calculate the expectation according to its definition (which matches the intuitive concept of average number of cycles per instruction), namely $$ \mathbb{E}[C(R)] = \sum_r C(r) \Pr[R = r]. $$ That's the computation detailed in the answer.

$\endgroup$
0
$\begingroup$

CPI is a statistical calculation used to determine how many cycles some algorithm (series of instructions) will take. It is not really CPU performance by itself. If you take the identical algorithm and calculate it's CPI on multiple CPUs then those values can be used to compare CPUs although it will not be a strong indication of a CPUs performance due to built in optimisations in CPUs which may skew the results and not really show the highest performing CPU.

CPI is better for comparing different algorithms used to work out similar values on the same CPU. Rather than looking directly at an algorithm's complexity one could calculate its CPI which can be useful when only a rough estimate is needed and the algorithms in question are very complex in nature and therefore their complexities and the amount of computational time they take to complete is very difficult to work out.

CPI is however a statistical result on experimental data which within computer science, is quite unreliable. An analytical approach would be much better in determining a much more reliable result although this may be too complex to figure out or take too much time. A way to make CPI more accurate would be to take multiple CPI values for the same algorithm and use different statistical calculations like the mean to work out a more accurate result.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.