ArticleslgStudy

computer science

Cycles per instruction

Cycles per instruction is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Cycles per instruction rather than just read about it. In short: 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.

Key takeaways

  • Cycles per instruction belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Cycles per instruction to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Cycles per instruction from memory before moving on to harder problems.

Reference excerpt

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.

Definition The average of Cycles Per Instruction in a given process (CPI) is defined by the following weighted average:

CPI:=Σi(ICi)(CCi)IC=Σi(ICi⋅CCi)Σi(ICi) Where ICi is the number of instructions for a given instruction type i, CCi is the clock-cycles for that instruction type and IC=Σi(ICi) 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:

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, 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 (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 five instructions in the five 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 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 (CPI = 5/6 < 1). 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 (CPI = 1/2 < 1).

Examples

Example 1 For the multi-cycle MIPS, there are five types of instructions:

Load (5 cycles) Store (4 cycles) R-type (4 cycles) Branch (3 cycles) Jump (3 cycles) If a program has:

50% load instructions 25% store instructions 15% R-type instructions 8% branch instructions 2% jump instructions then, the CPI is: CPI=5×50+4×25+4×15+3×8+3×2100=4.4

Example 2 Source: A 400MHz processor was used to execute a benchmark program with the following instruction mix and clock cycle count:

Determine the effective CPI, MIPS (Millions of instructions per second) rate, and execution time for this program. CPI=45000×1+32000×2+15000×2+8000×2100000=155000100000=1.55 400MHz=400,000,000Hz since: MIPS∝1/CPI and MIPS∝clock frequency Effective processor performance=MIPS=clock frequencyCPI×11 Million=400,000,0001.55×1000000=4001.55=258MIPS Therefore: Execution time(T)=CPI×Instruction count×clock time=CPI×Instruction Countfrequency=1.55×100000400×1000000=1.554000=0.0003875sec=0.3875ms

See also Cycle per second (Hz) Instructions per cycle (IPC) Instructions per second (IPS) Megahertz myth MIPS The benchmark article provides a useful introduction to computer performance measurement for those readers interested in the topic.

References

Worked examples

Example 1 — a first encounter with Cycles per instruction

Start with the simplest possible case. Write down what Cycles per instruction claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Cycles per instruction before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Cycles per instruction ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Cycles per instruction

In research
Cycles per instruction appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Cycles per instruction in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Cycles per instruction is common in secondary-school and first-year university syllabi. It links to neighbouring topics Clock signal, Computer performance, Instruction processing, so understanding it makes those chapters shorter.
In everyday life
Look for Cycles per instruction outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Cycles per instruction” →

How to study Cycles per instruction in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Cycles per instruction means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Cycles per instruction out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Cycles per instruction in simple terms?

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…

Why does Cycles per instruction matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Cycles per instruction?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Cycles per instruction.

Tags

  • Clock signal
  • Computer performance
  • Instruction processing
  • Rates

Keep exploring