Question
Consider a pipelined processor with 5 stages, Instruction Fetch (IF), Instruction Decode (ID), Execute (EX), Memory Access (MEM), and Write Back (WB). Each stage of the pipeline, except the EX stage, takes one cycle. Assume that the ID stage merely decodes the instruction and the register read is performed in the EX stage. The EX stage takes one cycle for ADD instruction and two cycles for MUL instruction. Ignore pipeline register latencies.
Consider the following sequence of 8 instructions:
Assume that every MUL instruction is data-dependent on the ADD instruction just before it and every ADD instruction (except the first ADD) is data-dependent on the MUL instruction just before it. The Speedup is defined as follows:
The Speedup achieved in executing the given instruction sequence on the pipelined processor (rounded to 2 decimal places) is ______.
Official answer and solution
- Accepted answers
- 1.87 to 1.88
- From
- Official GATE 2021 answer key
Solution
Construct cycle-by-cycle pipeline reservation tables for the 8-instruction sequence both with and without operand forwarding.
Pipeline specifications:
- Stages: IF (1 cycle), ID (1 cycle), EX (1 cycle for ADD, 2 cycles for MUL), MEM (1 cycle), WB (1 cycle).
- ID merely decodes; operand register read takes place in the EX stage.
- Instruction sequence: .
Case 1: Without operand forwarding:
Since operands are read in the EX stage and results are written back in the WB stage, instruction can enter its EX stage only after instruction has completed its WB stage.
- (ADD): .
- (MUL): reads result in EX at cycle 6: .
- (ADD): reads result in EX at cycle 10: .
- (MUL): .
- (ADD): .
- (MUL): .
- (ADD): .
- (MUL): .
Total execution time without operand forwarding is .
Case 2: With operand forwarding:
With forwarding, results are forwarded immediately from the end of the execution stage to the beginning of the next instruction's execution stage:
- (ADD): ; forwards result at end of cycle 3.
- (MUL): enters at cycle 4: ; forwards result at end of cycle 5.
- (ADD): enters at cycle 6: ; forwards result at end of cycle 6.
- (MUL): enters at cycle 7: ; forwards at end of cycle 8.
- (ADD): enters at cycle 9: ; forwards at end of cycle 9.
- (MUL): enters at cycle 10: ; forwards at end of cycle 11.
- (ADD): enters at cycle 12: ; forwards at end of cycle 12.
- (MUL): enters at cycle 13: .
Total execution time with operand forwarding is .
Calculate the speedup:
Rounding to 2 decimal places yields (official key range: 1.87 to 1.88).
1.88
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2021 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 63 of 65, printed as CS Q.53
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.