# Performance speedup with Amdahl's law

Consider this question: A program has 1M instructions and 30% of them are SQRT with CPI=8. The CPI of the rest of the instructions are 3. If we reduce the CPI of SQRT to 2, how much speedup is obtained?

I have two solutions for that:

1- Using Amdahl's law, We have

              1
S= --------------------
(1-alpha) + alpha
-----
n


So, we have 1/(0.7+(0.3/4)) where 0.7 is the fraction that is not affected. and 4 is the speedup of reducing CPI of SQRT from 8 to 2. That speedup will be 1.29.

2- We can calculate

CPI_avg = sigma( I * CPI_class )


and we know SQRT instructions are 300K and the rest are 700K. So

CPI_old = (300000*8 + 700000*3) / 1000000 = 4.5
CPI_new = (300000*2 + 700000*3) / 1000000 = 2.7


So, the speedup will be 4.5/2.7 which is 1.66

The question is, which one is correct? 1.29 or 1.66?