39 views
Consider a machine with 5-stage pipeline with 1ns clock cycle. The second machine with 12-stage pipeline with a 0.6ns clock cycle. The 5-stage pipeline experiences a stall due to data hazard for every 5 instructions, whereas 12 stage pipeline experiences 3 stalls for every 8 instructions. Branch instructions constitute 20% of the total instructions , and misprediction rate for both machines is 5%.
If the branch mispredict penalty for the first machine is 2 cycles but the second machine is 5 cycles, what is the speed up of 12-stage pipeline over 5 stage pipeline--------------?
Is it 1.4385???

5 stage pipeline

Branch instructions = 20%

So for other 80% instructions Data Hazard may occur.

So number of stalls due to data hazard = 80% * 1/5 = 0.8*0.2 =0.16 cycles

Number of stalls due to branch instructions= 20% * Branch mis prediction ratio * branch penalty = 0.2*0.05*2 cycles= 0.02

Total stalls/instruction = 0.16+0.02=0.18 stalls.

Average Execution Time A = (1+#stalls)*cycle time = (1+0.18) * 1 ns = 1.18 ns

12 stage pipeline

Branch instructions = 20%

So for other 80% instructions Data Hazard may occur.

So number of stalls due to data hazard = 80% * 3/8 =0.3 cycles

Number of stalls due to branch instructions= 20% * Branch mis prediction ratio * branch penalty = 0.2*0.05*5 cycles= 0.05 cycles

Total stalls/instruction = 0.3+0.05=0.35 stalls.

Average Execution Time B = (1+#stalls)*cycle time = (1+0.35) * 0.6 ns = 0.81ns

SpeedUp of B(12) over A(5) = 1.18/0.81 = 1.456