# Average Cycles Per Instruction

We have two different computers with the same instruction set. There are three classes of instructions (A, B, and C) in the instruction set. Computer M1 has a clock rate of 80 MHz and Computer M2 has a clock rate of 100 MHz. The average number of cycles for each instruction class and their frequencies (for a typical program) are as follows:

Instruction Class Machine M1 Cycles/Instruction Class Machine M2 Cycles/Instruction Class Frequency

Class    M1 Cycles/Instrctn Class   M2 Cycles/Instrctn Class   Frequency
A               1                               2                   60%
B               2                               3                   30%
C               4                               4                   10%


Calculate the average CPI for each machine, M1 and M2.

My initial hunch would be to just do something like M1: .6*1+.3*2+.1*4 = 1.6/3=.53 average for M1 but that makes no sense.

## 2 Answers

You had it correct right up to the point where you divided. Since you've already multiplied the values by the weights, no further math needs to be performed and the final result is 1.6.

• But how do I account for the different clockrates in MHz? M1 is 80, M2 is 100 MHz Commented Sep 24, 2014 at 14:09
• The clock rate is irrelevant. The question is about CPI, not MIPS. Commented Sep 24, 2014 at 14:15

You can calulate Average Cycles Per Instruction as follows:

Average Cycles Per Instruction For computer M1: = (1*60 + 2*30 + 4*10)/100 = 1.6 cycles/instruction

Average Cycles Per Instruction For computer M2: = (2*60 + 3*30 + 4*10)/100 = 2.5 cycles/instruction

• Wouldn't M1 be /80 because it has 80 MHz? Commented Sep 24, 2014 at 14:02
• when you calculate average time per instruction then Clock frequency comes in picture. CPI does not depend on clock speed
– GOKU
Commented Sep 25, 2014 at 17:20