Cycles per instruction


In computer architecture, cycles per instruction is one aspect of a processor's performance: the average number of clock cycles per instruction for a program or program fragment. It is the multiplicative inverse of instructions per cycle.

Definition

The average of Cycles Per Instruction in a given process is defined by the following:
Where is the number of instructions for a given instruction type, is the clock-cycles for that instruction type and is the total instruction count. The summation sums over all instruction types for a given benchmarking process.

Explanation

Let us assume a classic RISC pipeline, with the following five stages:
  1. Instruction fetch cycle.
  2. Instruction decode/Register fetch cycle.
  3. Execution/Effective address cycle.
  4. Memory access.
  5. Write-back cycle.
Each stage requires one clock cycle and an instruction passes through the stages sequentially. Without pipelining, in a multi-cycle processor, a new instruction is fetched in stage 1 only after the previous instruction finishes at stage 5, therefore the number of clock cycles it takes to execute an instruction is five. In this case, the processor is said to be subscalar. With pipelining, a new instruction is fetched every clock cycle by exploiting instruction-level parallelism, therefore, since one could theoretically have five instructions in the five pipeline stages at once, a different instruction would complete stage 5 in every clock cycle and on average the number of clock cycles it takes to execute an instruction is 1. In this case, the processor is said to be scalar.
With a single-execution-unit processor, the best CPI attainable is 1. However, with a multiple-execution-unit processor, one may achieve even better CPI values. In this case, the processor is said to be superscalar. To get better CPI values without pipelining, the number of execution units must be greater than the number of stages. For example, with six executions units, six new instructions are fetched in stage 1 only after the six previous instructions finish at stage 5, therefore on average the number of clock cycles it takes to execute an instruction is 5/6. To get better CPI values with pipelining, there must be at least two execution units. For example, with two executions units, two new instructions are fetched every clock cycle by exploiting instruction-level parallelism, therefore two different instructions would complete stage 5 in every clock cycle and on average the number of clock cycles it takes to execute an instruction is 1/2.

Examples

Example 1

For the multi-cycle MIPS, there are five types of instructions:
If a program has:
then, the CPI is:

Example 2

A 400MHz processor was used to execute a benchmark program with the following instruction mix and clock cycle count:
Instruction TYPEInstruction countClock cycle count
Integer Arithmetic450001
Data transfer320002
Floating point150002
Control transfer80002

Determine the effective CPI, MIPS rate, and execution time for this program.
since: and
Therefore: