Calculate cycles per instruction (CPI) from total clock cycles and instruction count, or find cycles, CPU execution time and MIPS from CPI and clock rate.

Average cycles per instruction for the entered workload.

Actual count or modeled instruction equivalents.

Optional settings

Calculator Functions

FunctionWhat it doesWhat it requires
Basic: cycles per instruction (CPI)Finds the average clock cycles per instructionRequires total clock cycles and instruction count
Basic: total clock cyclesFinds the clock cycles a program usesRequires instruction count and CPI
Basic: instruction countFinds the instruction count behind a cycle totalRequires total clock cycles and CPI
CPU: execution timeFinds CPU time for a programRequires instruction count, CPI and clock rate
CPU: clock rateFinds the clock rate that gives a CPU timeRequires instruction count, CPI and execution time
CPU: CPIFinds the CPI implied by a CPU timeRequires instruction count, clock rate and execution time
CPU: instruction countFinds the instruction count implied by a CPU timeRequires CPI, clock rate and execution time
MIPS: instruction rateFinds millions of instructions per secondRequires clock rate and CPI
MIPS: clock rateFinds the clock rate behind a MIPS ratingRequires MIPS and CPI
MIPS: CPIFinds the CPI behind a MIPS ratingRequires clock rate and MIPS
Instruction mix: weighted CPIFinds the average CPI of up to three instruction classesRequires the count and CPI of each class
Amdahl: overall speed factorFinds the overall speedup from improving part of a programRequires the enhanced fraction and its speed factor
Amdahl: enhanced fractionFinds the fraction that must be enhanced to reach a speedupRequires the enhanced-part speed factor and the overall speed factor
Amdahl: enhanced-part speed factorFinds how much faster the enhanced part must runRequires the enhanced fraction and the overall speed factor
Memory stalls: effective CPIAdds cache-miss stall cycles to a base CPIRequires base CPI, load/store fraction, both miss rates and the miss penalty

Clock rate is entered in Hz, kHz, MHz or GHz and time in s, ms, µs or ns. Every CPI result also shows instructions per clock (IPC), which is 1 ÷ CPI. The Amdahl functions accept an optional old or new execution time and derive the other.

Clock Cycles Per Instruction Formulas

CPI = C ÷ I [1]
CPIAverage clock cycles per instruction
CTotal CPU clock cycles for the program
IInstruction count of the program

Basic: cycles per instruction (CPI)

A program that takes 12,000,000,000 cycles to run 4,000,000,000 instructions has a CPI of 3 and an IPC of 0.3333.

Basic: total clock cycles

C = I × CPI

4,000,000,000 instructions at a CPI of 3 take 12,000,000,000 cycles.

Basic: instruction count

I = C ÷ CPI

12,000,000,000 cycles at a CPI of 3 correspond to 4,000,000,000 instructions.

CPU: execution time

T = I × CPI ÷ f [1]

T is CPU time in seconds and f is the clock rate in Hz. 4,000,000,000 instructions at a CPI of 3 on a 2 GHz clock take 4 × 10⁹ × 3 ÷ (2 × 10⁹) = 6 s.

CPU: clock rate

f = I × CPI ÷ T

Running 4,000,000,000 instructions at a CPI of 3 in 6 s needs a 2 GHz clock.

CPU: CPI

CPI = T × f ÷ I

A 6 s run of 4,000,000,000 instructions on a 2 GHz clock means a CPI of 3.

CPU: instruction count

I = T × f ÷ CPI

A 6 s run on a 2 GHz clock at a CPI of 3 executes 4,000,000,000 instructions.

MIPS: instruction rate

MIPS = f ÷ (CPI × 10⁶) [1]

A 4.2 GHz clock at a CPI of 1.0 gives 4,200 MIPS.

MIPS: clock rate

f = MIPS × CPI × 10⁶

4,200 MIPS at a CPI of 1 needs a 4.2 GHz clock.

MIPS: CPI

CPI = f ÷ (MIPS × 10⁶)

A 4 GHz clock delivering 3,636.36 MIPS has a CPI of 1.1.

Instruction mix: weighted CPI

CPI = Σ(Nᵢ × CPIᵢ) ÷ ΣNᵢ [1]

Nᵢ is the instruction count of a class and CPIᵢ is its cycles per instruction. A mix of 400 instructions at 1 cycle, 300 at 2 and 300 at 3 uses 1,900 cycles for 1,000 instructions, a CPI of 1.9. Classes 2 and 3 are optional.

Amdahl: overall speed factor

S = 1 ÷ ((1 − P) + P ÷ B) [1]

P is the fraction of the original execution time that is enhanced and B is how many times faster that part runs. Making 20% of the time 10 times faster gives 1 ÷ (0.8 + 0.02) = 1.2195. A 100 s run then takes 82 s.

Amdahl: enhanced fraction

P = B × (1 − S) ÷
(S × (1 − B))

An overall speed factor of 1.2195 from a part made 10 times faster means 0.2, or 20%, of the original time was enhanced.

Amdahl: enhanced-part speed factor

B = P ÷ ((1 ÷ S − 1) + P)

Reaching an overall speed factor of 1.4286 by improving 60% of the time needs that part to run 2 times faster. No finite factor reaches an overall speedup of 1 ÷ (1 − P) or more.

Memory stalls: effective CPI

CPI = CPI₀ + (mᵢ +
D × md) × p [2]

CPI₀ is the base CPI with no cache misses, mᵢ the instruction cache miss rate, D the fraction of instructions that are loads or stores, md the data cache miss rate and p the miss penalty in cycles. With a base CPI of 2, miss rates of 2% and 4%, 36% loads and stores and a 100-cycle penalty, the stalls add 2 + 1.44 cycles and the effective CPI is 5.44 [2].

Limits of This Estimate

  • CPI is an average for one program on one machine. CPU time for the same workload is the fair comparison. MIPS cannot compare computers with different instruction sets, changes from program to program, and can rise while performance falls [1].
  • The Amdahl functions assume a fixed workload, an unchanged remainder and no added overhead. The enhanced fraction is a share of the original execution time, not of the instruction count.
  • The memory-stall function assumes one instruction fetch per instruction, one data access per load or store, the same penalty for every miss and no overlapping misses. Real processors can overlap misses.

Sources