Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prof. Sirer CS 316 Cornell University

Similar presentations


Presentation on theme: "Prof. Sirer CS 316 Cornell University"— Presentation transcript:

1 Prof. Sirer CS 316 Cornell University
Pipelining Hazards Prof. Sirer CS 316 Cornell University

2 Pipelining Recap Powerful technique for masking latencies
Logically, instructions execute one at a time Physically, instructions execute in parallel Decouples the processor model from the implementation Interface vs. implementation Dependencies between instructions complicate the implementation

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17 Hazards Data hazards Control hazards Structural hazards
A required operand is not ready Usually because a previous instruction in the pipeline has not committed it to the register file yet Control hazards The next instruction to fetch cannot be determined Usually because a jump or branch instruction has not determined the next PC yet Structural hazards Two instructions in the pipeline try to simultaneously access the same resource

18 Data Hazards Stall Data Forwarding
Keep track of all instructions in the pipeline, and all registers they may affect Detect that there will be a conflict Inject NOPs (“bubbles”) into the pipeline until the hazard is gone Data Forwarding Add additional circuitry and wires to route data from a later stage back to an earlier stage

19 Control Hazards Stall Delay Slots Speculative Execution
Inject NOPs into the pipeline when the next instruction is not known Pros: simple, clean; Cons: slow Delay Slots Tell the programmer that the N instructions after a jump will always be executed, no matter what the outcome of the branch Pros: The compiler may be able to fill the slots with useful instructions; Cons: breaks abstraction boundary Speculative Execution Insert instructions into the pipeline Replace instructions with NOPs if the branch comes out opposite of what the processor expected Pros: Clean model, fast; Cons: complex

20 Types of Hazards RAW – Read After Write WAR – Write After Read
WAW – Write After Write RAW indicates data dependence WAW and WAR hazards stem from register reuse Exercised by out-of-order execution Register renaming can eliminate them

21


Download ppt "Prof. Sirer CS 316 Cornell University"

Similar presentations


Ads by Google