Assume that computer M1 has CPU clock rate 500MHz, and supports four classes of
ID: 674005 • Letter: A
Question
Assume that computer M1 has CPU clock rate 500MHz, and supports four classes of instructions: ALU, lw, sw, branch/jump. lw has CPI = 5, sw has CPI =4, ALU instruction has CPI = 4, and branch/jump has CPI = 3. The following program P is used in testing the computer performance: Loop: add $t0, $zero, $zero add $t0, $t1, $t1 or $t0, $t1, $t1 subu $t1, $t1, $s6 lw $t0, 0($t1) sll $s3, $s2, 3 bne $t0, $s5, Loop a. What is the average CPI for program P? b. Another computer M2 with clock rate of 1GHz has the same performance as computer M1 when it runs the program P. What is the average CPI of computer M2? c.how long does it take to execute this program if the number of iterations is 100?
Explanation / Answer
a)
Given code is:
Loop: add $t0, $zero, $zero
add $t0, 4t1, $t1
subu $t1, $t1, $s3
lw $t0, 0($t1)
sll $s3, $s2, 3
bne $0, $s5, Loop
The number of ALU instructions is: 4(add, subu, sll)
The number of lw/sw instruction is: 1(lw)
The number of branch/jump instruction is: 1(bne)
Here the number of times the loop is being executed is not provided hence, it is assumed to be for 20 times.
Thus, the loop is being executed for 20 times.
The number of instructions inside the loop is 6.
The total number of instructions executed in computer M1 is =
In other way:
From the given the CPI of ALU, lw/sw and bne instruction values, calculate the total number of cycles.
Thus, the average CPI for P in computer M1 is =
Therefore, the average CPI of computer M1 to execute P is 4.
b)
To find the average CPI of computer M2 to execute P is given with respect to the average CPI of computer M1 as
Since, the clock rate of computer M1 is 500MHz and average CPI of program P in 4.
The clock rate of computer M2 is 1GHz, need to find the average CPI of program P.
The average CPI of computer M2 is given as,
Therefore, the average CPI of computer M2 is 8 and it is double that to that of computer M1.
c)
If the loop is iterated for 100 times, then average CPI of computer M1 is calculated as follows:
The number of ALU instructions is: 4(add, subu, sll)
The number of lw/sw instruction is: 1(lw)
The number of branch/jump instruction is: 1(bne)
Here the number of times the loop is being executed is not provided hence, it is assumed to be for 100 times.
Thus, the loop is being executed for 100 times.
The number of instructions inside the loop is 6.
The total number of instructions executed in computer M1 is =
In other way:
From the given the CPI of ALU, lw/sw and bne instruction values, calculate the total number of cycles.
Thus, the average CPI for P in computer M1 is =
Therefore, the average CPI of computer M1 to execute P is 4.