pipeling presentation

23
Pipelining By K. Santle Camilus Based on the Text Book “Computer Organization” by Carl Hamacher et al., Fifth Edition

Upload: bhavani-bs

Post on 27-Apr-2015

83 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: pipeling presentation

Pipelining

By K. Santle Camilus

Based on the Text Book “Computer Organization” by Carl Hamacher et al.,

Fifth Edition

Page 2: pipeling presentation

Introduction to Pipelining• Laundry Example

• Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold

• Washer takes 30 minutes

• Dryer takes 40 minutes

• “Folder” takes 20 minutes

A B C D

Page 3: pipeling presentation

Sequential Laundry

• Sequential laundry takes 6 hours for 4 loads

• If they learned pipelining, how long would laundry take?

A

B

C

D

30 40 20 30 40 20 30 40 20 30 40 20

6 PM 7 8 9 10 11 Midnight

Task

Order

Time

Page 4: pipeling presentation

Pipelined LaundryStart work ASAP

• Pipelined laundry takes 3.5 hours for 4 loads

• Speedup = 6/3.5 = 1.7

A

B

C

D

6 PM 7 8 9 10 11 Midnight

Task

Order

Time

30 40 40 40 40 20

Page 5: pipeling presentation

Pipelining Lessons• Pipelining doesn’t help

latency of single task, it helps throughput of entire workload

• Pipeline rate limited by slowest pipeline stage

• Multiple tasks operating simultaneously

• Potential speedup = Number pipe stages ???

• Unbalanced lengths of pipe stages reduces speedup

A

B

C

D

6 PM 7 8 9

Task

Order

Time

30 40 40 40 40 20

Page 6: pipeling presentation

Computer Pipelines

• Pipelining: An implementation technique that overlaps the execution of multiple instructions.

• Execute billions of instructions, so throughput is what matters

Page 7: pipeling presentation

Claim: (1) In pipelined two stage of execution, rate of instruction execution is twice than that achievable by sequential operation. In four stage, it is four times.

(2) Increase in performance is directly propositional to the number of pipeline stages

Page 8: pipeling presentation

Hardware Organization for Four Stage Pipelining

Page 9: pipeling presentation

Time for execution • If different stages require different amount of

time, the clock period must allow the longest stage to complete.

------ can we come up with a equation for this?????

------- using this, can we generalize the time taken for sequential and pipeline execution?????

• Pipelining does not result in individual instructions being executed faster; rather the throughput that increases

Page 10: pipeling presentation

No cache in a computer. What happens to pipelining?

• Perhaps it is related to time issue.

• Hamacher says:

Accessing a main memory is 10 times greater than the time to execute a basic operation inside a processor

If so, what happens to Pipelining ?

• Pipelining is more effective if different stage requires same amount of time.

• Now the role of cache?

Page 11: pipeling presentation

Hazards• Any condition that causes

the pipeline to stall (key term meaning delay) is called a Hazard.

Types:• Data Hazard• Control or instruction

Hazard• Structural Hazard

Identify all hazards that may cause the pipeline to stall and to find ways to minimize impact

Page 12: pipeling presentation

Structural Hazard

• This condition occurs when two instructions require the use of a given hardware at the same time.

• Two examples:

1.Two access to cache by two different instructions- one for fetch, another for write.

What is the solution?

Page 13: pipeling presentation

Structural Hazard [Example 2]What is the solution to this

problem?????

Page 14: pipeling presentation

Data Hazard

• Situation in which the pipeline is stalled because the data to be operated on are delayed for some reason.

Page 15: pipeling presentation

Data Hazard

• Results obtained when instruction are executed in a pipelined processor must be identical to when same instruction are executed sequentially.

Example: A = 3 + A

B = 4 * A

Assume A= 3,

result for sequential operation: B=24

Result for Pipelined operation: B= 12

( Oops!!! Answer is wrong)

What to do????????????

Page 16: pipeling presentation

Data Hazard Example 2

Mul R2, R3, R4

Add R5,R4,R6

Page 17: pipeling presentation

What is the solution to example 2 of data hazard

Solution 1:

• Solution for Example 2 of Data hazard- Operand Forwarding

• After decoding instruction, a decision is made to use data forwarding

• It is a hardware solution

Page 18: pipeling presentation

What is the solution to example 2 of data hazard

• Solution 2:

• Alternatively, we look for software solution, the work of detecting data dependency and dealing is left to the software, Complier

i1: Mul R2, R3, R4

NOP

NOP

i2: Add R5, R4, R6

In NOP, the complier may reorder the instruction and perform useful tasks.

Page 19: pipeling presentation

Side effects• In the previous cases, the data dependencies are

explicit because the register are named explicitly.

• In few cases, when a location other than one explicitly named in an instruction as a destination operand is affected, the instruction is said to have a Side Effect

• Example: Add R1, R3

AddWithCarry R2, R4

Operation performed: R4=[R2]+[R4]+ Carry

- it rise to multiple data dependencies

How to handle this situation??

Page 20: pipeling presentation

Instructional Hazard

Page 21: pipeling presentation

Solution to Cache misses(1/2)

Page 22: pipeling presentation

Solution to cache misses(2/2)

Page 23: pipeling presentation

Summary

Clarifications contact:[email protected]