There are four classes of instructions, A, B, C, and D. The clock rate and CPI of each implementation are given in the following table.
Clock Rate | CPI Class A | CPI Class B | CPI Class C | CPI Class D | |
P1 | 2.5 GHz | 1 | 2 | 3 | 3 |
P2 | 3 GHz | 2 | 2 | 2 | 2 |
Given a program with 106 instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D, what CPU time is? What is the global CPI for each implementation? Find the clock cycles required in both cases.
Expert Answer
There are four classes of instructions, A, B, C, and D. The clock rate and CPI of each implementation are given in the following table.
Clock Rate | CPI Class A | CPI Class B | CPI Class C | CPI Class D | |
P 1 | 2.5 GHz | 1 | 2 | 3 | 3 |
P2 | 3 GHz | 2 | 2 | 2 | 2 |
Given that a program has 106 instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D
For processor P1:
The clock rate(R) = 2.5 GHz
Instruction count(I)=106
The clock per Instruction (CPI)=1*10/100+2*20/100+3*50/100+3*20/100=1*0.1 + 2*0.2 + 3*0.5 + 3*0.2=
0.1+0.4+1.5+0.6=2.6
So, execution time = (1/R)*I*CPI= =(1/2.5) * 10-9 * 106 * 2.6 sec = 0.4* 10-9 *106 * 2.6 sec.=110.24 * 10-9sec
CPU time is the execution time of the program. For processor P1 CPU time is 110.24*10-9 sec.
For processor P2:
The clock rate(R) = 3 GHz
Instruction count(I)=106
The clock per Instruction (CPI)=2*10/100+2*20/100+2*50/100+2*20/100=2*0.1 + 2*0.2 + 2*0.5 + 2*0.2=
0.2+0.4+1+0.4=2.0
So, execution time = (1/R)*I*CPI= =(1/3) * 10-9 * 106 * 2.0 sec = 0.3333* 10-9 *106 * 2.0 sec.=70.66 * 10-9sec
CPU time for processor P2 is 70.66*10-9 sec.
Global CPI for each implementation:
For processor P1:
Instruction count (I)=106
The total number of clock cycles required = (1*10/100+2*20/100+3*50/100+3*20/100)*106 = (0.1+0.4+1.5+0.6)*106 = 2.6*106
Global CPI = (2.6*106)/106 = 2.6
So, the Global CPI for first implementation (P1) is 2.6
For processor P2:
Instruction count (I)=106
The total number of clock cycles required = (2*10/100+2*20/100+2*50/100+2*20/100)*106 = (0.2+0.4+1.0+0.4)*106 = 2.0*106
Global CPI = (2.0*106)/106 = 2.0=2
So, the Global CPI for second implementation (P2) is 2
Total clock cycles for each implementations:
For processor P1:
Instruction count (I)=106
The total number of clock cycles required = (1*10/100+2*20/100+3*50/100+3*20/100)*106 = (0.1+0.4+1.5+0.6)*106 = 2.6*106=275.6
Total clock cycles required for first implementation (P1) = 275.6
For processor P2:
Instruction count (I)=106
The total number of clock cycles required = (2*10/100+2*20/100+2*50/100+2*20/100)*106 = (0.2+0.4+1.0+0.4)*106 = 2.0*106 =212
Total clock cycles required for second implementation (P2) = 212