We have a program of 103 instructions in the format of lw ad
We have a program of 10^3 instructions in the format of “lw, add, lw, add, …”. The add instruction depends (and only depends) on the lw instruction right before it. The lw instruction also depends (and only depends) on the add instruction right before it. If the program is executed on the pipelined datapath: (a) What would be the actual CPI? (b) Without forwarding, what would be the actual CPI?
Solution
a)
With forwarding, only 1 bubble will be there between LW and ADD. and no bubble between ADD and LW.
So finally we have 3 cycles ==> 1 to complete LW + 1 bubble + 1 ADD
So 3 cycles to complete two instructions.
So actual CPI = 3/2 = 1.5
b)
without forwarding, the value in register can only be read so that there have 2 cycles bubbles
which are between LW and other dependent ADD. Similarly we have another two bubbles between ADD and dependent
LW.
So we have total 6 cycles ==> 1 ADD + 2 bubbles + 1 ADD + 2 bubbles
So it takes 6 cyvles for completing two instructions.
So, Actual CPI = 6/2 ===> 3
