SME
Computer Organization & Architecture · Problem type
CPI from an instruction mix
Use this for “Half the instructions take 1 cycle, 30% take 2 and 20% take 3. What is the average CPI?”
Chart
50% + 30% + 20% = 100% of the whole.
This is an example. Type your own values to start a new problem.
CPI
=
pA (%)
×
CPIA
+
pB (%)
×
CPIB
+
pC (%)
×
CPIC
Formulas
pC = 100 − pA − pB
20 = 100 − 50 − 30
CPI = (pA × CPIA + pB × CPIB + pC × CPIC) ÷ 100
1.7
=
50 × 1 + 30 × 2 + 20 × 3
100
Assumptions
•
Every instruction of the program is in one of the three classes A, B and C.
•
Class C is the rest: pC = 100% − pA − pB.
•
Each class always takes the same number of cycles, its CPI.
•
The average weights each class’s CPI by its share of the instructions run.
Step-by-step
WE KNOW
pA = 50%, pB = 30%, CPIA = 1, CPIB = 2, CPIC = 3
FIND
share of class C (pC), average CPI (CPI)
Step 1 · Find share of class C (pC)
Use pC = 100 − pA − pB
Every instruction is in one class, so class C is what A and B leave of 100%.
pC = 100 − 50 − 30
pC = 20%
Step 2 · Find average CPI (CPI)
Use CPI = (pA × CPIA + pB × CPIB + pC × CPIC) ÷ 100
Each class adds its share times its cycles; ÷ 100 turns the percents into fractions.
CPI
=
50 × 1 + 30 × 2 + 20 × 3
100
CPI
=
50 + 60 + 60
100
CPI
=
170
100
CPI = 1.7
Check
Put the numbers back in. Both sides should match.
20 = 100 − 50 − 30 ✓
1.7
=
50 × 1 + 30 × 2 + 20 × 3
100
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.