GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Derive pipeline performance from weighted stall costs

11 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Compute effective CPI as ideal throughput cost plus instruction-class frequency times stall cost, then combine CPI with clock period to obtain program time or a speedup ratio. 2006 derives a branch penalty and asks seconds;

2 marks · NAT
Report issue

Pipeline speedup with stalls and a slower clock

Pipelining & Hazards

Question 57, GATE 2026: A nonpipelined processor averages 5 cycles/instruction at 1.6 GHz. Its pipeline has ideal CPI 1 but runs at 1.2 GHz; 30% of instructions incur an additional 2-cycle stall. Compute long-program speedup to two decimals. The published accepted range is 2.30–2.40.
Tap to enlarge
Answer & solution

Official answer: 2.30 to 2.40

Our answer: 2.34375 (2.34 rounded)

Givens and goal

A nonpipelined processor averages 5 cycles/instruction at 1.6 GHz. Its pipeline has ideal CPI 1 but runs at 1.2 GHz; 30% of instructions incur an additional 2-cycle stall. Compute long-program speedup to two decimals. The published accepted range is 2.30–2.40.

Approach

Compare actual seconds per instruction, not CPI alone.

Step-by-step solution

1. The nonpipelined average instruction time is CPI/frequency=5/(1.6×10⁹) seconds=3.125 ns.
2. Each pipelined instruction contributes one base cycle on average. The expected added stall cost is 0.30×2=0.60 cycles per instruction, so effective CPI is 1.60.
3. The pipelined instruction time is 1.60/(1.2×10⁹) seconds=4/3 ns≈1.33333 ns. Its clock is slower, so a CPI reduction by itself would overstate the improvement.
4. Speedup is old time/new time=3.125/(4/3)=2.34375, which rounds to 2.34. Equivalently use (5/1.6)/(1.6/1.2).
5. The full official accepted interval 2.30–2.40 is preserved, rather than replaced with a single exact scoring value. The calculation assumes long-program throughput, negligible pipeline fill/drain cost, and additive two-cycle stalls as stated; a short program or overlapping penalties would need more details.

Original paper, page 39 · Answer key

2 marks · NAT
Report issue

Combine instruction and data cache stall costs

Cache Memory

Question 56, GATE 2024: A program has 25% load/store instructions. Ideal CPI is 2; instruction-cache miss rate is 2%; data-cache miss rate is 8%; every miss costs 100 cycles. Find the speedup with perfect instruction and data caches, rounded to two decimals.
Tap to enlarge
Answer & solution

Official answer: 3.00

Approach: Express every stall contribution per executed instruction so they can be added to the base CPI.
1. Every instruction requires an instruction fetch. Instruction-cache stalls therefore contribute 0.02 misses/instruction ×100 cycles/miss=2 cycles/instruction.
2. Only 25% of instructions access data memory. Data-cache stalls contribute 0.25 accesses/instruction ×0.08 misses/access ×100 cycles/miss=2 cycles/instruction.
3. With the stated additive, nonoverlapped miss-penalty model, actual CPI=ideal CPI+instruction stalls+data stalls=2+2+2=6.
4. Perfect caches remove both stall terms and restore CPI=2. With the same instruction count and clock rate, execution time is proportional to CPI, so speedup=old time/new time=6/2=3.
Answer: 3.00. Using 8% for every instruction would overcount data misses. The reciprocal 2/6 is the new-to-old time ratio, not the speedup factor.

Original paper, page 33 · Answer key

2 marks · NAT
Report issue

Compute speedup from effective CPI

Pipelining & Hazards

Question 58, GATE 2024: A nonpipelined 2 GHz unit averages 6 cycles/instruction. A 5-stage redesign at the same frequency ideally achieves 1 instruction/cycle. In program P, 20% of instructions incur 2 stall cycles for data hazards and 20% incur 3 stall cycles for control hazards. Find steady-state speedup to one decimal.
Tap to enlarge
Answer & solution

Official answer: 2.9 to 3.1

Our answer: 3.0

Approach: Add average stall cycles per instruction to ideal CPI and compare elapsed time at equal clock rate.

1. Derivation. The pipelined average CPI is 1+0.20×2+0.20×3=2. Both designs have the same 2GHz frequency, so their steady-state speedup is 6/2=3.0. The5-stage fill/drain overhead is ignored in this throughput model; instruction count is not supplied. Hazard penalties are treated as additive non-overlapped stalls.

2. Explanation and checks. For a conceptual batch of 100 instructions, ideal execution costs 100 cycles, data stalls add 20×2=40, and control stalls add 20×3=60, totaling 200. The old design costs 600 cycles, so the ratio is three. Pipeline depth alone is not the speedup: it affects overlap, while actual CPI includes stalls. No program length is supplied for computing fill/drain effects, and the conventional average calculation treats the stated penalties additively.

Original paper, page 38 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 61, GATE 2022: X1 runs at 2 GHz, base CPI 1, with 30% branches and two stall cycles per branch. X2 has the same frequency and base CPI, but predicts 80% of branches correctly, eliminating stalls for those; mispredictions keep the same two-cycle penalty. No other hazards occur. Find speedup rounded to two decimals.
Tap to enlarge
Answer & solution

Official answer: 1.42 to 1.45

Our answer: 1.43

Without prediction, CPI1=1+0.30*2=1.6. With 80 percent correct predictions, only 20 percent of branches still pay the two-cycle penalty, so CPI2=1+0.30*0.20*2=1.12. Both processors have the same frequency and execute the same program, giving speedup 1.6/1.12=10/7, or 1.43 to two decimal places. This uses the stated steady-state CPI model, without separately charging pipeline fill/drain.

Speedup is old execution time/new execution time, not new CPI/old CPI. For N instructions at frequency F, times are N·1.6/F and N·1.12/F, so N and F cancel. The branch predictor saves 0.30×0.80×2=0.48 cycles per instruction, reducing CPI from 1.60 to 1.12.

Original paper, page 39 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 43, GATE 2020: A nonpipelined 2.5 GHz processor takes 5 cycles/instruction. Its five-stage pipeline runs at 2 GHz. Program mix: 30% memory,60% ALU,10% branch. Of memory instructions,5% cause 50-cycle stalls. Of branches,50% cause 2-cycle stalls. ALU instructions cause none. Find steady-state speedup to two decimals.
Tap to enlarge
Answer & solution

Official answer: 2.15 to 2.18

Our answer: 2.16

Worked explanation

Use time per instruction, since the two designs have different clocks. For 1000 representative instructions, 300 are memory, of which 15 stall for 750 cycles total; 100 are branches, of which 50 stall for 100 cycles total. Add the ideal 1000 pipeline cycles to obtain 1850, or CPI=1.85. Nonpipelined cycle time is 1/2.5 GHz=0.4 ns, so an instruction takes 2 ns. Pipeline cycle time is 0.5 ns, making average time 0.925 ns. Speedup is old time/new time=2/0.925=2.162162…, rounded 2.16. Counting 5% of all instructions as cache misses would overstate the penalty because that rate is conditional on memory instructions.

Derivation and answer

The non-pipelined time per instruction is 5/(2.5GHz)=2 ns. The pipeline average CPI is 1+0.30*0.05*50+0.10*0.50*2=1.85. At2GHz its average time is 1.85*0.5=0.925 ns per instruction. Speedup=2/0.925=2.162162..., or 2.16, within the official 2.15–2.18 range. This is the long-program steady-state calculation; the fixed pipeline fill/drain cost is neglected because program length is not supplied.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 55, GATE 2015: A nonpipelined CPU runs at 2.5 GHz with average CPI=4. A five-stage pipelined version runs at 2 GHz due to pipeline delay, with no stalls. Find speedup.
Tap to enlarge
Answer & solution

Official answer: 3.2

Compare time per instruction, not stage count alone. Initially an instruction costs four 0.4-ns cycles, or 1.6 ns. A full stall-free pipeline produces one result per 0.5-ns cycle. Throughput speedup is 1.6/0.5=3.2. Five stages affect latency and initial fill; they do not make the improvement automatically fivefold. This is the steady-state limit for a sufficiently long stream.

Solution: Nonpipelined throughput is 2.5GHz/4=0.625 billion instructions/s. A stall-free full pipeline at 2GHz completes one instruction per cycle, giving 2 billion/s. The steady-state speedup is 2/0.625=3.2. This ignores fill/drain overhead for a finite short instruction sequence, whose length is not supplied.

Original paper, page 21 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 43, GATE 2014: A perfectly balanced six-stage instruction pipeline has no cycle-time overhead. While an application runs, 25% of its instructions incur two stall cycles each. Find the speedup relative to nonpipelined execution.
Tap to enlarge
Answer & solution

Official answer: 4

1. Method and setup. Measure time in units of one pipeline stage. Without pipelining an instruction consumes six such units; in steady state the pipeline completes one instruction per cycle plus stalls. Weight the stall penalty by the fraction of affected instructions rather than adding two cycles to every instruction.

2. Work through the result and its assumptions. The average cycles per instruction is 1+0.25·2=1.5. A nonpipelined instruction takes six balanced stage times, so steady-state speedup is 6/1.5=4. This ignores fill/drain effects; for a finite N-instruction run with exactly N/2 stall cycles, the usual timing is 6N/(1.5N+5), approaching4.

Original paper, page 18 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 43, GATE 2014: An old pipeline has IF,ID/RF,EX,MEM,WB with delays 1,2.2,2,1,0.75 ns. A new eight-stage pipeline splits ID/RF into ID,RF1,RF2 of 2.2/3 ns each, and EX into EX1,EX2 of 1 ns each. Branches are 20% of instructions and resolve at the end of EX (old) or EX2 (new); after fetching a branch, IF stalls until its next PC is known. Other instructions have average CPI 1. For old/new program times P,Q, find P/Q.
Tap to enlarge
Answer & solution

Official answer: 1.50 to 1.60

Our answer: 1.54

Step 1: Ignoring latch overhead, the old period is max(1,2.2,2,1,0.75)=2.2 ns. The new longest stage is 1 ns. Step 2: In the old design, a branch fetched in cycle 1 resolves at the end of stage 3, so it blocks two following fetch slots. Average CPI is 1+0.2×2=1.4. Step 3: In the new design, EX2 is stage 6: IF,ID,RF1,RF2,EX1,EX2. A branch blocks five following fetch slots, yielding CPI 1+0.2×5=2. Step 4: In the steady-state model, time per instruction is CPI×period. Therefore P/Q=(1.4×2.2)/(2×1)=1.54. Pipeline fill/drain and register overhead are omitted; without program length an exact finite-program ratio is not specified.

Original paper, page 63 · Answer key

2 marks · MCQ
Report issue

Conditional-branch pipeline stalls

Pipelining & Hazards

Question 42, GATE 2006: A 1 GHz CPU has five pipeline stages; fetch is stage 1. Conditional branches compute their target and condition in stage 3. After fetching a branch, no further instruction is fetched until the outcome is known. A program has 10⁹ instructions, 20% conditional branches. With base CPI 1 before branch stalls, what approximate execution time results?
Options:
(A) 1.0 s
(B) 1.2 s
(C) 1.4 s
(D) 1.6 s
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. A branch fetched in stage 1 resolves at the end of stage 3, so two subsequent fetch slots are lost. The ideal CPI is 1 and branch frequency is 0.2, giving CPI=1+2(0.2)=1.4.

2. At 1 GHz, 109 instructions take approximately 1.4 seconds (C); constant pipeline fill/drain time is ignored as in the options. The statement that instructions take one cycle on average must mean the base CPI before these stalls.

3. Teaching check: The two idle fetch slots are the cycles while the branch passes stages 2 and 3. Since one fifth of instructions causes this penalty, average overhead is 0.4 cycles per instruction. The five-stage depth does not mean five cycles of throughput cost for every ordinary instruction.

Original paper, page 6

Descriptive
Report issue

Pipeline average with serialized branches

Pipelining & Hazards

Question 12(a), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead.

Task: Find average instruction execution time when every branch prevents overlap.
Question 12(a), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead.

Task: Find average instruction execution time when every branch prevents overlap.
Tap to enlarge
Shared context

An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead.

Answer & solution

Answer: 3.6 ns per instruction (CPI 1.8 at a 2 ns clock). (no official key was published)

1. Without branches, the pipeline accepts a new instruction every cycle, hence steady-state throughput time is 2 ns per instruction, not the individual instruction latency of 10 ns.

2. A branch fetched in cycle t completes at the end of t+4. The successor can be fetched in t+5, whereas normal overlap would fetch it in t+1. Thus each such branch adds four idle fetch cycles, or 8 ns.

3. The expected cycles per instruction are 1+0.20×4=1.8. Multiplying by 2 ns gives 3.6 ns per instruction.

4. Equivalently, 80% of inter-fetch intervals are 2 ns and 20% are 10 ns, so 0.8×2+0.2×10=3.6 ns. Finite programs have fill/drain effects; the question’s average uses the usual long-run idealization.

Original paper, page 8

Descriptive
Report issue

Pipeline average with conditional branches

Pipelining & Hazards

Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Tap to enlarge
Shared context

An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Answer & solution

Answer: 2.96 ns per instruction (CPI 1.48). (no official key was published)

1. Within the branch population, 20% are unconditional and always impose the no-overlap rule. Another 80%×50%=40% are taken conditional branches. Thus 60% of branches impose the four-cycle penalty.

2. As branches are 20% of all instructions, the fraction of all instructions causing the penalty is 0.20×0.60=0.12. The remaining 0.88 do not interrupt ideal overlap under the stated model.

3. Average CPI is 1+0.12×4=1.48, giving 1.48×2=2.96 ns. Equivalently 0.88×2+0.12×10=2.96 ns.

4. The 50% figure applies only to conditional branches, not to every branch. Ignoring the unconditional 20% of branches would incorrectly reduce the answer to 2.64 ns. No branch prediction or extra recovery penalty is introduced beyond the assumptions given.

Original paper, page 8