Pipeline Hazards Part 2

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Pipeline Hazards Part 2 as PDF for free.

More details

  • Words: 449
  • Pages: 3
CS-421 Parallel Processing Handout_6.2

BE (CIS) Batch 2004-05

Pipeline Hazards (Part – II) The previous handout (Handout_6.1) described data hazards involving only R-type instructions. Now we examine data hazards involving loads/stores. Stores Case-I

Case-II

Remarks ƒ

Each MIPS instruction writes to at most one register. This makes the forwarding hardware easier to design, since there is only one destination register that ever needs to be forwarded.

ƒ

Forwarding is especially important with deep pipelines like the ones in all current PC processors.

Loads Consider the following sequence of instructions:

ƒ

The data to be loaded doesn’t come from memory until the end of cycle 4.

ƒ

But the and needs that value at the beginning of the same cycle! Page - 1 - of 3

CS-421 Parallel Processing Handout_6.2

o

BE (CIS) Batch 2004-05

This is a “true” data hazard—the data is not and cannot be available when we need it.

ƒ

The easiest solution is to stall the pipeline.

ƒ

We could delay the and instruction by introducing a one-cycle delay into the pipeline, sometimes called a bubble.

ƒ

Notice that we’re still using forwarding in cycle 5, to get data from the MEM/WB pipeline register to the ALU.

ƒ

Clearly without forwarding, we’d have to stall for two cycles to wait for the lw instruction’s write-back stage.

ƒ

In general, you can always stall to avoid hazards—but dependencies are very common in real code, and stalling often can reduce performance by a significant amount.

ƒ

If we delay an instruction, we’ll have to delay the following one as well.

ƒ

One way to implement a stall is to force the two instructions after lw to pause and remain in their ID and IF stages for one extra cycle.

ƒ

This is easily accomplished. –

Don’t update the PC, so the current IF stage is repeated.



Don’t update the IF/ID register, so the ID stage is also repeated. Page - 2 - of 3

CS-421 Parallel Processing Handout_6.2

ƒ

BE (CIS) Batch 2004-05

But what about the ALU during cycle 4, the DM in cycle 5, and the register file write in cycle 6?

ƒ

Those units aren’t used in those cycles because of the stall, so we can disable all the control signals to be used in the EX, MEM and WB stages.

Detecting Stalls ƒ

A load use hazard occurs between the current instruction in its ID stage and the previous instruction in the EX stage if o

The previous instruction was a lw

o

The lw destination is one of the current source registers. if (ID/EX.MemRead = 1 and (ID/EX.RegisterRt = IF/ID.RegisterRs or ID/EX.RegisterRt = IF/ID.RegisterRt)) then stall

Page - 3 - of 3

Related Documents

Pipeline
May 2020 70
Natural Hazards 2
May 2020 2
Everyday Hazards
May 2020 14
Volcanic Hazards
June 2020 8