14,756 views
Consider two processors $P_1$ and $P_2$ executing the same instruction set. Assume that under identical conditions, for the same input, a program running on $P_2$ takes $\text{25%}$ less time but incurs $\text{20%}$ more CPI (clock cycles per instruction) as compared to the program running on $P_1$. If the clock frequency of $P_1$ is $\text{1GHZ}$, then the clock frequency of $P_2$ (in GHz) is ______.

This is more of Aptitude question.

Here data are given in comparison with one another it means we should try to equate both processor values by using some equation. If we think closely there is nothing equal in both except no. of instructions to be executed. Then how can we find no. of instructions (given total time to compute, CPI, Cycle time)

$\frac{Total time}{CPI * Cycle time} = No. of Instructions$

$\frac{Total time.1}{CPI.1 * Cycle time.1} = \frac{Total time.2}{CPI.2 * Cycle time.2}$

$Performance \propto \dfrac{1}{execution\ time}$

$execution\ time=CPU\ time$

$CPU\ time= \#\ of\ seconds/program$

$or$

$CPU\ time= \#\ of\ inst/program\times \#\ of\ cycles/inst\times \#\ of\ sec/cycle$

$CPU\ time= inst\ count\times CPI\times cycle\ time$

$In\ the\ program\ different\ instruction\ takes\ different\ cycles\ to\ complete$

$\therefore\ CPU\ time=\Sigma (IC_{i}\times CPI_{i})\times cycle\ time$

$T_{1}=(IC\times x)\times\dfrac{1}{1GHz}.....(1)$

$0.75\ T_{1}=(IC\times 1.2x)\times\dfrac{1}{F_{2}}.....(2)$

$(2)\div(1)$

$F_{2}=1.6\ GHz$

this is nothing but a game of units as per me, here's how i approached...

Given data says, t2=75% of t1=0.75*t1..where ti: time taken by ith processor and CPI2=120%CPI1

thus CP12=1.2*CPI1.

Units of CPI are cycle per Inst and that of time are seconds.

So, (CPI2/t2)=(1.2/0.75)(CPI1/t1)                             (1)

frequncy is cycle per second hence CPI/t ~ frequency

Thus,  (1) becomes...

f2=1.6*f1=1.6 GHZ                                                  [ANS]
Lets say, $P_1$ have cycle time $t_1$, $P_2$ have cycle time $t_2$.

Assuming $CPI(cycles/instruction)= 100$ for $P_1$

Time to execute 1 instruction on $P_1 =$ cycles/instruction * 1 cycle time = $100t_1$

$CPI$ for $P_2=120$ (given)

Time to execute 1 instruction on $P_2 = 120t_2$

But, question says $120t_2$ is $25\%$ less than $100t_1$ which means $120t_2 = 75t_1$,

Question also says, $t_1=1ns (f=1GHz$ means cycle time $= 1ns)$,

So, $t_2 = 0.625 ns$ which is $1.6 GHz$

CPU TIME $(T) =$ No. of Instructions $( I ) \times$ No. of Cycles Per Instruction $(c) \times$ Cycle Time $(t)$

OR

CPU TIME $(T) = \dfrac{\text{No. of Instructions(I)$\times$No. of Cycles Per Instruction (c)}}{\text{Clock frequency (f)}}$

$\rightarrow T = I_{c} \times CPI \times F^{-1}$

$\rightarrow \dfrac{T \times F}{CPI} = I_{c}$

$P_1$ & $P_2$ executing same instruction set So,
No. of Instructions same for both $= I_1 = I_2 = I$

If $P_1$ takes $T_1$ time,

$\rightarrow T_2 = 0.75\times T_1 \rightarrow\dfrac{T_{2}}{ T_{1}}=0.75$

If $P_1$ incurs $C_1$ clock cycles per instruction,

$\rightarrow C_2 =1.2 \times C_1\rightarrow \dfrac{C_{2}}{C_{1}}=1.2$

Since $I$ is same for both,

$\rightarrow \dfrac{ ( f_{1} \times T_{1} )}{c1} = \dfrac{ ( f_{2} \times T_{2} )}{c2}$  and  $f_1 =1\ GHz$

$\rightarrow F_2 =(\dfrac{C_{2}}{C_{1}}) \times (\dfrac{T_{1}}{T_{2}}) \times F_{1}$

$= \dfrac{1.2 \times 1 GHz}{0.75}=1.6\ GHz$

Hence, the clock frequency of $P_2$  is $=1.6\ GHz$.

Elaborate 3 things what they mean

1. Same instruction set.
2. Assume that under identical conditions, what conditions are assumed identical?
3. for the same input, what does input here means a instruction or program input?
1. Same instruction set.
This is a standard and basic term from Computer Architecture and there is no explanation needed. Why this is used in this question is to show that the same program runs on the 2 processors and each processor instruction takes the same CPU cycles on both.
2. Assume that under identical conditions, what conditions are assumed identical?
“what” conditions? – Every condition that can affect the performance (execution time) of the program. Some of these can be the memory system including size, operating system, IO system etc.
3. for the same input, what does input here means a instruction or program input?
”for the same input, a program running on” – so it is clear that the input is to the program.

Thank you for explanation but I am clear with pt. 1 & 2  but still have doubt in pt. 3.

“for the same input, a program running on P2 takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as compared to the program running on P1”.

From the language of the question, it seems to me like Diff. prog is running on P1 and P2 but their inputs are same.

I saw a video of this question there they are taking input as programs, and this confused me.

Execution time (T) = CPI * #instructions * time for a clock
= CPI * #instructions / clock frequency (F)

Given $P_1$ and $P_2$ execute the same set of instructions and

• $T_2 = 0.75 T_1,$
• $\text{CPI}_2 = 1.2 \;\text{CPI}_1$ and
• $F_1 = 1\;\text{GHz}.$

So,

$\frac{T_1}{CPI_1} \times F_1 =\frac{T_2}{CPI_2} \times F_2$

$\frac{T_1}{CPI_1} \times 1 GHz = \frac{0.75 T_1} {1.2 CPI_1} \times F_2$

$\implies F_2 = \frac {1.2}{0.75} GHz$

$=1.6\;GHz$

by

I got it..
I believe yes he is equated the expression on the basis of "no. of instruction" since P1 and P2 are executing the same instruction set.
Nice Explanation Arjun Sir
This question can fit better in the aptitude section rather than the technical section.

Suppose both processors are executing 100 same instructions.

Assume that Clock cycles per instruction for P1 is 1. So, for 100 instructions, 100 Clock cycles are required. The clock frequency of P1 is 1GHz. Hence clock cycle time is 1ns. So for 100 clock cycles, 100* 1ns= 100ns time is required.

For P2,  CPI is 20% more than that of P1 that is 1.20 and time taken is 25% less that is 75ns. 100 instructions on P2 requires 100*1.2 cycles= 120 cycles.

So, 120 cycles takes 75ns on P2. hence 1cycle takes 0.625ns.

Hence clock frequency is 1/0.625 GHz = 1.6GHz.

### 1 comment

nice appproach!
For P1 clock period = 1ns

Let clock period for P2 be t.

Now consider following equation based on specification
7.5 ns = 12*t ns

We get t and inverse of t will be 1.6GHz

### 1 comment

Try to give answer for those , on which no answer selected as best. :)