What is Cycles per instruction (CPI)?

The average number of clock cycles per instruction, one factor in execution time = instruction count × CPI × cycle time, and the reciprocal of IPC.

Field: Performance Analysis

Japanese name: CPI

The performance equation

CPU execution time equals instruction count × cycles per instruction (CPI) × cycle time, or instruction count × CPI ÷ clock frequency. Each factor has a different owner: instruction count depends mostly on the algorithm, compiler and instruction set architecture (ISA); CPI on the microarchitecture and memory system; and cycle time on circuit design and process technology. CPI is the reciprocal of instructions per clock (IPC). A program of 1 billion instructions at CPI 2 on a 2 GHz processor takes 2 billion cycles, or 1 second.

Average CPI from an instruction mix

Different instruction classes take different numbers of cycles, so average CPI is a weighted sum. With 50% ALU instructions at CPI 1, 30% loads and stores at CPI 2 and 20% branches at CPI 5, the average is 0.5 + 0.6 + 1.0 = 2.1. Breaking CPI down this way shows where time goes: branches are only a fifth of the instructions yet contribute nearly half the cycles. The same idea underlies CPI stacks in performance analysis, which attribute cycles to base execution, cache misses, branch mispredictions and other stalls.

How stalls inflate CPI

Stall cycles add directly to the ideal CPI. If a core with a perfect cache achieves CPI 1.0 but each instruction makes 1.3 memory accesses with a 2% miss rate and a 100-cycle miss penalty, memory stalls add 1.3 × 0.02 × 100 = 2.6 cycles, giving CPI 3.6. Branch mispredictions add frequency × miss rate × penalty in the same way. Superscalar, out-of-order cores push base CPI below 1: a 2 GHz processor averaging CPI 0.5 completes about 4 billion instructions per second.

Pitfalls when comparing

Optimizing one factor often worsens another, so only the product counts. Raising frequency 1.5× while CPI rises 1.2× gives a 1.25× speedup, not 1.5×, and deeper pipelines typically show exactly this pattern through larger misprediction penalties. A compiler change that removes 20% of instructions but raises CPI 10% still wins, at 0.88 of the original time. CPI is also not comparable across different ISAs, because the instructions do different amounts of work; for the same reason, raw instructions-per-second ratings can mislead.

Try it: questions about Cycles per instruction (CPI)

Approximately how many instructions per second can a processor with a 2 GHz clock and an average CPI (clocks per instruction) of 0.5 execute?

  1. A1 billion instructions
  2. B4 billion instructions
  3. C100 million instructions
Show answer and explanation

Answer: B. 4 billion instructions

There are 2×10⁹ clocks per second and each instruction averages 0.5 clocks, so2×1090.5=4×1092×10⁹ ÷ 0.5 = 4×10⁹—4 billion instructions. CPI below 1 reflects superscalar execution of multiple instructions per clock. Performance is execution time = instruction count × CPI ÷ frequency, so no single one of the three factors suffices for comparison.

A processor has an average CPI of 1.0 with a perfect cache. Each instruction makes 1.3 memory accesses on average, with a 2% miss rate and a 100-cycle miss penalty. What is the actual average CPI?

  1. A3.0
  2. B3.6
  3. C1.3
Show answer and explanation

Answer: B. 3.6

Memory stall cycles per instruction are 1.3 accesses × 0.02 × 100 cycles = 2.6 cycles. Adding them to the ideal CPI gives 1.0 + 2.6 = 3.6, so performance falls to 1/3.6 of ideal. 3.0 wrongly assumes one access per instruction (1.0 + 1 × 0.02 × 100). 1.3 is the number of accesses per instruction, not the CPI. Even a small miss rate badly hurts performance when the miss penalty is large.

FAQ

How do you calculate CPI?

Divide total clock cycles by the number of instructions executed, or compute a weighted average of each instruction class's cycle count by its share of the instruction mix.

What is the relationship between CPI and IPC?

They are reciprocals: IPC is instructions completed per clock cycle and CPI is cycles per instruction, so a CPI of 0.5 means an IPC of 2.

Does CPI mean something else in semiconductor packaging?

Yes. In packaging, CPI usually means chip-package interaction, the cracking or delamination of fragile low-k interconnect layers caused by packaging stresses, which is unrelated to cycles per instruction.

Questions that mention Cycles per instruction (CPI) (7)

Cycles per instruction (CPI) appears in 9 practice questions across 4 topics, including Performance Analysis, CPUs and architecture, Memory Hierarchy.

  1. A program executing 1 billion instructions runs on a CPU with average CPI 2 and clock frequency 2 GHz. What is the execution time?
  2. A CPU design change raises clock frequency 1.5× but also raises CPI 1.2× (instruction count unchanged). How many times faster is execution?
  3. A new compiler optimization reduces executed instructions by 20% but increases average CPI by 10% (frequency unchanged). What is its effect?
  4. A program's instruction mix is 50% integer ALU (CPI 1), 30% loads and stores (CPI 2) and 20% branches (CPI 5). What is the average CPI?
  5. In chips using mechanically weak low-k films, what is the problem called in which stress during packaging cracks or delaminates the films?
  6. Which metric indicates the number of instructions executed per clock?
  7. Which is the basic formula for a program's CPU execution time?

Books on Performance Analysis Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary