Cycles per instruction
|This article needs additional citations for verification. (December 2009) (Learn how and when to remove this template message)|
In computer architecture, cycles per instruction (aka clock cycles per instruction, clocks per instruction, or CPI) 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.
Cycles Per Instruction 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.
Let us assume a classic RISC pipeline, with the following 5 stages:
- Instruction fetch cycle (IF).
- Instruction decode/Register fetch cycle (ID).
- Execution/Effective address cycle (EX).
- Memory access (MEM).
- Write-back cycle (WB).
Each stage requires one clock cycle and an instruction passes through the stages sequentially. Without pipelining, 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 5 (CPI = 5 > 1). 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 5 instructions in the 5 pipeline stages at once (one instruction per stage), 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 (CPI = 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 (CPI < 1). 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 6 executions units, 6 new instructions are fetched in stage 1 only after the 6 previous instructions finish at stage 5, therefore on average the number of clock cycles it takes to execute an instruction is 5/6 (CPI = 5/6 < 1). To get better CPI values with pipelining, there must be at least 2 execution units. For example, with 2 executions units, 2 new instructions are fetched every clock cycle by exploiting instruction-level parallelism, therefore 2 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 (CPI = 1/2 < 1).
For the multi-cycle MIPS, there are 5 types of instructions:
If a program has:
- 50% load instructions
- 15% R-type instructions
- 25% store instructions
- 8% branch instructions
- 2% jump instructions
then, the CPI is:
|Instruction type||Instruction count||Clock cycle count|
Determine the effective CPI, MIPS rate, and execution time for this program.
- Total instruction count = 100000
- Instructions per cycle (IPC)
- Instructions per second (IPS)
- Cycle per second (Hz)
- Megahertz myth
- The benchmark article provides a useful introduction to computer performance measurement for those readers interested in the topic.
- Patterson, David A.; Hennessy, John L. Computer Organization and Design: The Hardware/Software Interface.
- Advanced Computer Architecture by Kai Hwang, Chapter 1, Exercise Problem 1.1