Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Control Hazard

Chen
October 26, 2022

Control Hazard

Chen

October 26, 2022
Tweet

More Decks by Chen

Other Decks in Science

Transcript

  1. 51 Control Hazards • Control hazards • Must fetch post-branch

    insns before branch outcome is known • Since we don’t know whether or not we’re branching until the insn reaches the X stage (ALU) • Default: assume “branch not taken” (at fetch, can’t tell it’s a branch) PC Insn Mem Register File s1 s2 d + 4 << 2 F/D D/X X/M PC A B IR O B IR PC IR S X
  2. 52 Branch Recovery • Branch recovery: what to do when

    branch is taken • Flush insns currently in F/D and D/X (they’re wrong) • Replace with NOPs + Haven’t yet written to RegFile or DMem PC Insn Mem Register File s1 s2 d + 4 << 2 PC F/D D/X X/M nop nop PC A B IR O B IR PC IR S X
  3. 56 Fast Branch • Fast branch: can decide at D

    instead of X • Duplicate comparison logic only, not the whole ALU + New taken branch penalty is now 1 stall instead of 2 – Additional insns (slt) for more complex tests, must bypass to D too • 25% of branches have complex tests that require extra insn • CPI = 1 + 0.20*0.75*1(branch) + 0.20*0.25*1(extra insn) = 1.2 PC Insn Mem Register File s1 s2 d + 4 << 2 F/D D/X X/M S X <> 0 O B IR A B IR PC IR S X