Skip to content
Official PYQ · 2021

GATE CS 2021 Set 2 Q53 — Instruction Pipelining

Explain with AI
Consider a pipelined processor with 55 stages, Instruction Fetch(IF)\text{Instruction Fetch} (\textsf{IF}), Instruction Decode(ID)\text{Instruction Decode} \textsf{(ID)}, Execute (EX)\text{Execute } \textsf{(EX)}, Memory Access (MEM)\text{Memory Access } \textsf{(MEM)}, and Write Back (WB)\text{Write Back } \textsf{(WB)}. Each stage of the pipeline, except the EX\textsf{EX} stage, takes one cycle. Assume that the ID\textsf{ID} stage merely decodes the instruction and the register read is performed in the EX\textsf{EX} stage. The EX\textsf{EX} stage takes one cycle for ADD\textsf{ADD} instruction and two cycles for MUL\textsf{MUL} instruction. Ignore pipeline register latencies.

Consider the following sequence of 88 instructions:
ADD, MUL, ADD, MUL, ADD, MUL, ADD, MUL\textsf{ADD, MUL, ADD, MUL, ADD, MUL, ADD, MUL} Assume that every MUL\textsf{MUL} instruction is data-dependent on the ADD\textsf{ADD} instruction just before it and every ADD\textsf{ADD} instruction (except the first ADD\textsf{ADD}) is data-dependent on the MUL\textsf{MUL} instruction just before it. The speedup\textit{speedup} defined as follows.
Speedup=Execution time without operand forwardingExecution time with operand forearding\textit{Speedup} = \dfrac{\text{Execution time without operand forwarding}}{\text{Execution time with operand forearding}} The Speedup\textit{Speedup} achieved in executing the given instruction sequence on the pipelined processor (rounded to 22 decimal places) is _____________
View worked solution

Answer: 1.87 : 1.88

To find the speedup, we calculate the total execution cycles for both cases: without operand forwarding and with operand forwarding.

1. Without Operand Forwarding

Since the register read is performed in the EX\textsf{EX} stage and register write is in the WB\textsf{WB} stage, a dependent instruction can only enter its EX\textsf{EX} stage after the preceding instruction completes its WB\textsf{WB} stage.

  • I1I_1 (ADD): EX\textsf{EX} in cycle 3, WB\textsf{WB} in cycle 5.
  • I2I_2 (MUL): EX\textsf{EX} starts in cycle 6 (after I1I_1 completes WB\textsf{WB} in cycle 5). EX\textsf{EX} takes 2 cycles (6, 7), WB\textsf{WB} in cycle 9.
  • I3I_3 (ADD): EX\textsf{EX} starts in cycle 10, WB\textsf{WB} in cycle 12.
  • I4I_4 (MUL): EX\textsf{EX} in cycles 13–14, WB\textsf{WB} in cycle 16.
  • I5I_5 (ADD): EX\textsf{EX} in cycle 17, WB\textsf{WB} in cycle 19.
  • I6I_6 (MUL): EX\textsf{EX} in cycles 20–21, WB\textsf{WB} in cycle 23.
  • I7I_7 (ADD): EX\textsf{EX} in cycle 24, WB\textsf{WB} in cycle 26.
  • I8I_8 (MUL): EX\textsf{EX} in cycles 27–28, MEM\textsf{MEM} in cycle 29, WB\textsf{WB} in cycle 30.

Total execution time without forwarding = 30 cycles.

2. With Operand Forwarding

With forwarding, the result computed at the end of the EX\textsf{EX} stage of an instruction is directly forwarded to the start of the EX\textsf{EX} stage of the next dependent instruction.

  • I1I_1 (ADD): EX\textsf{EX} in cycle 3. Result forwarded at the end of cycle 3.
  • I2I_2 (MUL): EX\textsf{EX} in cycles 4–5. Result forwarded at the end of cycle 5.
  • I3I_3 (ADD): EX\textsf{EX} in cycle 6. Result forwarded at the end of cycle 6.
  • I4I_4 (MUL): EX\textsf{EX} in cycles 7–8. Result forwarded at the end of cycle 8.
  • I5I_5 (ADD): EX\textsf{EX} in cycle 9. Result forwarded at the end of cycle 9.
  • I6I_6 (MUL): EX\textsf{EX} in cycles 10–11. Result forwarded at the end of cycle 11.
  • I7I_7 (ADD): EX\textsf{EX} in cycle 12. Result forwarded at the end of cycle 12.
  • I8I_8 (MUL): EX\textsf{EX} in cycles 13–14, MEM\textsf{MEM} in cycle 15, WB\textsf{WB} in cycle 16.

Total execution time with forwarding = 16 cycles.

3. Speedup Calculation

Speedup=Execution time without forwardingExecution time with forwarding=3016=1.875\text{Speedup} = \frac{\text{Execution time without forwarding}}{\text{Execution time with forwarding}} = \frac{30}{16} = 1.875

Rounding to two decimal places, we get 1.88 (or 1.87 depending on the rounding method).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Instruction Pipelining questions