In: Computer Science
Consider two different implementations, P1 and P2, of the same instruction set. There are five classes of instructions (A, B, C, D, and E) in the instruction set. The clock rate and CPI of each class is given below.
CLK Rate |
CPI for A |
CPI for B |
CPI for C |
CPI for D |
CPI for E |
|
P1 |
2 GHz |
1 |
1 |
3 |
3 |
2 |
P2 |
3 GHz |
1 |
2 |
3 |
4 |
3 |
The total number of instructions for Program X1 are A1, B1, C1, D1 and E1 while the total number of instruction s for X2 are A2, B2, C2, D2, and E2. Compute which program runs faster on each computers P1 and P2.values are A1=230,B1=370,C1=300,D1=140,E1=95 AND A2=330,B2=250,C2=400,D2=180,E2=185
For program X1:-
processor P1,
Total number of cycles =
(Number of Instruction of type)*CPI of type
=A1*CPI of A + B1*CPI B + C1*CPI C + D1*CPI D + E1*CPI E
= 230*1+370*1+300*3+140*3+95*2
= 230+370+900+420+190
2110 cycles
Execution Time = Number of cycles /Clock Frequency
= 2110/2*10^9 Hz = 1.055*10^-6 sec
.
.
processor P2,
Total number of cycles =
(Number of Instruction of type)*CPI of type
=A1*CPI of A + B1*CPI B + C1*CPI C + D1*CPI D + E1*CPI E
= 230*1+370*2+300*3+140*4+95*3
= 230+740+900+640+285
2795 cycles
Execution Time = Number of cycles /Clock Frequency
= 2795/3*10^9 Hz = 0.93167*10^-6 sec
For X1,
Execution time on P2 i.e 0.9316*10^-6 is less than that on P1 i.e 1.055*10^-6
.
.
.
For program X2:-
processor P1,
Total number of cycles = (Number of Instruction of type)*CPI of type
=A2*CPI of A + B2*CPI B + C2*CPI C + D2*CPI D + E2*CPI E
= 330*1+250*1+400*3+180*3+185*2
= 330+250+1200+540+370
2690 cycles
Execution Time = Number of cycles /Clock Frequency
= 2690/2*10^9 Hz = 1.345*10^-6 sec
.
.
processor P2,
Total number of cycles = (Number of Instruction of type)*CPI of type
=A2*CPI of A + B2*CPI B + C2*CPI C + D2*CPI D + E2*CPI E
= 330*1+250*2+400*3+180*4+185*3
= 330+500+1200+720+555
3305 cycles
Execution Time = Number of cycles /Clock Frequency
= 3305/3*10^9 Hz = 1.10167*10^-6 sec
For X2,
Execution time on P2 i.e 1.10167*10^-6 is less than that on P1 i.e 1.345*10^-6
.
Both X1,X2 runs faster on P2.
.
.
.
If any doubt ask in the comments.