1. Gyanastra
  2. Computer Organisation and Architecture
  3. Pipeline Hazards
  4. Introduction to Hazards: Structural, Control and Data Dependencies
Free lesson, no account needed 4 min read 10 practice questions after it
Asked in past papers6 times
  • GATE CSE2018200320021992
  • ISRO20172008

Computer Organisation and Architecture · Pipeline Hazards

Introduction to Hazards: Structural, Control and Data Dependencies

Overview

Pipelining aims to complete one instruction every clock cycle on average, giving an ideal CPI of about 1.
In practice this ideal is not always achievable: situations called hazards, or dependencies, prevent the next instruction from proceeding in step with the previous one.
All such causes fall into exactly three classes — structural, control and data hazards — and each must be studied to understand the problem it creates and how it is handled.

Key concepts

  • Pipelining goal: the average number of clock cycles required to finish one instruction should be one, i.e. the pipeline should ideally retire one instruction every clock cycle.
  • Hazard (dependency): any situation in which the next instruction cannot proceed in step with the previous one, so the pipeline cannot sustain one instruction per clock.
  • Structural dependency (structural hazard): one of the three classes of hazards.
  • Control dependency (control hazard): one of the three classes of hazards.
  • Data dependency (data hazard): one of the three classes of hazards.

How it works

  1. Start from the design target: the pipeline is built so that, on average, one instruction completes per clock cycle (CPI ≈ 1).
  2. Check whether the target is met: ideally, every clock a new instruction is issued and one instruction finishes.
  3. When the target is not met, the cause is a situation in which the next instruction cannot proceed in step with the previous one; such a situation is a hazard, also called a dependency.
  4. Every such cause falls into one of three classes — structural, control or data hazards — and each is examined separately, with examples, to see the problem it creates and how it is handled.

Formulas

average clocks per instruction=1(ideal pipelining target)\text{average clocks per instruction} = 1 \quad \text{(ideal pipelining target)}

Comparison

Hazard classAlternative name
Structural dependencyStructural hazard
Control dependencyControl hazard
Data dependencyData hazard

Revision summary

  • The performance goal of pipelining is an average of one clock cycle per instruction (one instruction every clock).
  • Hazards are also called dependencies; the two terms are used interchangeably.
  • There are exactly three classes of hazards: structural, control and data.
  • Hazards are the reasons the pipeline cannot sustain one instruction per clock.
  • The ideal of one instruction per clock is not always achievable in practice.
  • Each hazard type must be studied separately to understand the problem it causes and how to deal with it.

Previous-year exam insights

  • Structural hazard: caused by hardware resource conflict, i.e. two instructions needing the same resource (e.g. a single ALU, or a single memory for both instruction fetch and data access) in the same clock cycle; resolved by duplicating resources (separate instruction/data memories, multiple ALUs) or by stalling.
    Asked inGATE 2003ISRO 2017GATE 2002ISRO 2008
  • Data hazard: caused when an instruction depends on the result of a preceding instruction (RAW dependence); handled by forwarding/bypassing, operand forwarding, or inserting stalls (bubbles).
    Asked inGATE 2003ISRO 2017GATE 2002ISRO 2008
  • Control hazard: caused by branch/jump/conditional-jump instructions, since the next instruction address is not known until the branch is resolved; handled by stalling, branch prediction, delayed branching or prefetching.
    Asked inGATE 2003ISRO 2017GATE 1992
  • Unequal stage delays also degrade pipeline performance: the clock period is set by the slowest stage, so faster stages sit idle; this is a pipeline-performance limitation (not one of the three hazard classes).
    Asked inGATE 2002ISRO 2008
  • Instruction prefetching into an instruction buffer speeds up processing because fetching the next instruction overlaps with execution of the current one, hiding instruction-fetch time (and reducing the penalty of control hazards).
    Asked inGATE 1992
  • Pipeline speedup is limited by hazards and by the pipeline fill/drain overhead: speedup = (time for non-pipelined execution)/(time for pipelined execution), and for k stages and n instructions the ideal speedup approaches k as n grows.
    Asked inGATE 2018
Pages 1–2 of 2