# Performance Calculation Examples

Suppose that the cost of executing instructions by a particular non-pipelined CPU are given in the following table. Also included are their frequencies in a particular program.

Instruction Type CPI Frequency (%)
Stores 4 13
ALU 4 43
Branches 3 19
Jumps 3 2

What is the CPI for this CPU, for this particular application?

```      CPU clock cycles
CPI = -----------------
Instruction count

sum of (Counts for each instruction x Corresponding CPI)
= --------------------------------------------------------
Instruction count

Count for each instruction
= sum of ( -------------------------- x Corresponding CPI )
Instruction count

= sum of ( Instruction frequency x Corresponding CPI )

= 0.23 x 5 + 0.13 x 4 + 0.43 x 4 + 0.19 x 3 + 0.02 x 3

= 4.02
```

Suppose that we now pipeline the CPU. How many cycles does it take to execute any single instruction?

5 cycles, since the pipeline must accommodate the slowest instruction.

What is the effective CPI of the pipeline? How might it be different in practice and why?

A pipeline allows us to execute one instruction per clock cycle. The CPI is 1, although it is higher (i.e. worse) in practice because data and branch hazards cause pipeline stalls, resulting in less than peak pipeline performance.

Main Page  Section Notes Page