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.
- All Miscellaneous Calculators
- MIPS Calculator
- Queries Per Second Calculator
- Requests Per Second Calculator
Calculator Functions
| Function | What it does | What it requires |
|---|---|---|
| Basic: cycles per instruction (CPI) | Finds the average clock cycles per instruction | Requires total clock cycles and instruction count |
| Basic: total clock cycles | Finds the clock cycles a program uses | Requires instruction count and CPI |
| Basic: instruction count | Finds the instruction count behind a cycle total | Requires total clock cycles and CPI |
| CPU: execution time | Finds CPU time for a program | Requires instruction count, CPI and clock rate |
| CPU: clock rate | Finds the clock rate that gives a CPU time | Requires instruction count, CPI and execution time |
| CPU: CPI | Finds the CPI implied by a CPU time | Requires instruction count, clock rate and execution time |
| CPU: instruction count | Finds the instruction count implied by a CPU time | Requires CPI, clock rate and execution time |
| MIPS: instruction rate | Finds millions of instructions per second | Requires clock rate and CPI |
| MIPS: clock rate | Finds the clock rate behind a MIPS rating | Requires MIPS and CPI |
| MIPS: CPI | Finds the CPI behind a MIPS rating | Requires clock rate and MIPS |
| Instruction mix: weighted CPI | Finds the average CPI of up to three instruction classes | Requires the count and CPI of each class |
| Amdahl: overall speed factor | Finds the overall speedup from improving part of a program | Requires the enhanced fraction and its speed factor |
| Amdahl: enhanced fraction | Finds the fraction that must be enhanced to reach a speedup | Requires the enhanced-part speed factor and the overall speed factor |
| Amdahl: enhanced-part speed factor | Finds how much faster the enhanced part must run | Requires the enhanced fraction and the overall speed factor |
| Memory stalls: effective CPI | Adds cache-miss stall cycles to a base CPI | Requires 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 | Average clock cycles per instruction |
| C | Total CPU clock cycles for the program |
| I | Instruction 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
4,000,000,000 instructions at a CPI of 3 take 12,000,000,000 cycles.
Basic: instruction count
12,000,000,000 cycles at a CPI of 3 correspond to 4,000,000,000 instructions.
CPU: execution time
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
Running 4,000,000,000 instructions at a CPI of 3 in 6 s needs a 2 GHz clock.
CPU: CPI
A 6 s run of 4,000,000,000 instructions on a 2 GHz clock means a CPI of 3.
CPU: instruction count
A 6 s run on a 2 GHz clock at a CPI of 3 executes 4,000,000,000 instructions.
MIPS: instruction rate
A 4.2 GHz clock at a CPI of 1.0 gives 4,200 MIPS.
MIPS: clock rate
4,200 MIPS at a CPI of 1 needs a 4.2 GHz clock.
MIPS: CPI
A 4 GHz clock delivering 3,636.36 MIPS has a CPI of 1.1.
Instruction mix: weighted CPI
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
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
(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
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
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
- King Fahd University of Petroleum and Minerals, COE 501 Computer Architecture, Performance lecture: CPI, CPU time, weighted CPI, MIPS and Amdahl’s law
- University of California San Diego, CSE 141, Chapter 5 slides: Large and Fast, Exploiting Memory Hierarchy: cache-miss stall cycles and the 5.44 example
