• Tidak ada hasil yang ditemukan

Pipelining is Natural!

N/A
N/A
Protected

Academic year: 2024

Membagikan "Pipelining is Natural!"

Copied!
7
0
0

Teks penuh

(1)

Computer System Architecture Pipelining Part I

Chalermek Intanagonwiwat

Slides courtesy of David Patterson

Pipelining is Natural!

• Laundry Example

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

• Washer takes 30 minutes

• Dryer takes 30 minutes

• “Folder” takes 30 minutes

• “Stasher” takes 30 minutes to put clothes into drawers

A B C D

Sequential Laundry

• Sequential laundry takes 8 hours for 4 loads

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

T 30 a s k O r d e r

B C D

A 30 30 3030 30Time30 30 30 30 3030 30 30 30 30

6 PM 7 8 9 10 11 12 1 2 AM

Pipelined Laundry: Start work ASAP

• Pipelined laundry takes 3.5 hours for 4 loads!

T a s k O r d e r

12 2 AM

6 PM 7 8 9 10 11 1

Time

B C D A

30 30 30 3030 30 30

(2)

Pipelining Lessons

• Pipelining doesn’t help latency of single task, it helps throughput of entire workload

• Multiple tasks operating

simultaneously using different resources

• Potential speedup = Number pipe stages

6 PM 7 8 9

Time

B C D A

30 30 30 3030 30 30 T

a s k O r d e r

Pipelining Lessons (cont.)

• Pipeline rate limited by slowest pipeline stage

• Unbalanced lengths of pipe stages reduces speedup

• Time to “fill”

pipeline and time to “drain” it reduces speedup

• Stall for Dependences

6 PM 7 8 9

Time

B C D A

30 30 30 3030 30 30 T

a s k O r d e r

The Five Stages of Load

• Ifetch: Instruction Fetch

– Fetch the instruction from the Instruction Memory

• Reg/Dec: Registers Fetch and Instruction Decode

• Exec: Calculate the memory address

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5

Ifetch Reg/Dec Exec Mem Wr

Load

The Five Stages of Load (cont.)

• Mem: Read the data from the Data Memory

• Wr: Write the data back to the register file

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5

Ifetch Reg/Dec Exec Mem Wr

Load

(3)

Conventional Pipelined Execution Representation

IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB

IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB

IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB Program Flow

Time

Single Cycle, Multiple Cycle, vs.

Pipeline

Clk Cycle 1

Multiple Cycle Implementation:

Ifetch Reg Exec Mem Wr

Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9 Cycle 10

Load Ifetch Reg Exec Mem Wr

Ifetch Reg Exec Mem

Load Store

Pipeline Implementation:

Ifetch Reg Exec Mem Wr Store

Clk

Single Cycle Implementation:

Load Store Waste

Ifetch R-type

Ifetch Reg Exec Mem Wr R-type

Cycle 1 Cycle 2

Why Pipeline?

• Suppose we execute 100 instructions

• Single Cycle Machine

– 45 ns/cycle x 1 CPI x 100 inst = 4500 ns

• Multicycle Machine

– 10 ns/cycle x 4.6 CPI (due to inst mix) x 100 inst = 4600 ns

• Ideal pipelined machine

– 10 ns/cycle x (1 CPI x 100 inst + 4 cycle drain) = 1040 ns

Why Pipeline? Because the resources are there!

I n s t r.

O r d e r

Time (clock cycles)

Inst 0 Inst 1 Inst 2

Inst 4 Inst 3

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

(4)

Can pipelining get us into trouble?

• Yes: Pipeline Hazards

– structural hazards: attempt to use the same resource two different ways at the same time

• E.g., combined washer/dryer would be a structural hazard or folder busy doing something else (watching TV)

Can pipelining get us into trouble? (cont.)

– data hazards: attempt to use item before it is ready

• E.g., one sock of pair in dryer and one in washer; can’t fold until get sock from washer through dryer

• instruction depends on result of prior instruction still in the pipeline

Can pipelining get us into trouble? (cont.)

– control hazards: attempt to make a decision before condition is evaluated

• E.g., washing football uniforms and need to get proper detergent level; need to see after dryer before next load in

• branch instructions

• Can always resolve hazards by waiting – pipeline control must detect the hazard – take action (or delay action) to resolve

hazards

Single Memory is a Structural Hazard

Mem I

n s t r.

O r d e r

Time (clock cycles)

Load Instr 1 Instr 2 Instr 3 Instr 4

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

ALU

Reg Mem Reg

ALU

Mem Reg Mem Reg

(5)

• Stall: wait until decision is clear

– Its possible to move up decision to 2nd stage by adding hardware to check registers as being read

• Impact: 2 clock cycles per branch instruction => slow

Control Hazard Solutions

I n s t r.

O r d e r

Time (clock cycles)

Add Beq Load

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

ALU

Reg Mem Reg

Mem

• Predict: guess one direction then back up if wrong

– Predict not taken

Control Hazard Solutions (cont.)

I n s t r.

O r d e r

Time (clock cycles)

Add Beq Load

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

Mem

ALU

Reg Mem Reg

• Impact: 1 clock cycles per branch instruction if right, 2 if wrong (right ­ 50% of time)

• More dynamic scheme: history of 1 branch (­ 90%)

Control Hazard Solutions (cont.)

I n s t r.

O r d e

Time (clock cycles)

Add Beq Load

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

Mem Reg ALU Mem Reg

• Redefine branch behavior (takes place after next instruction) “delayed branch”

Control Hazard Solutions (cont.)

I n s t r.

O r d e r

Time (clock cycles)

Add Beq

Misc

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

Mem

ALU

Reg Mem Reg

Load Mem Reg ALU Mem Reg

(6)

• Impact: 0 clock cycles per branch

instruction if can find instruction to put in “slot” (­ 50% of time)

• As launch more instruction per clock cycle, less useful

Control Hazard Solutions (cont.)

I n s t r.

O r d e r

Time (clock cycles)

Add Beq

Misc

ALU

Mem Reg Mem Reg

ALU

Mem Reg Mem Reg

Mem Reg ALU Mem Reg

Load Mem Reg ALU Mem Reg

Data Hazard on r1

add r1 ,r2,r3 sub r4, r1 ,r3 and r6, r1 ,r7 or r8, r1 ,r9 xor r10, r1 ,r11

Dependencies backwards in time are hazards

Data Hazard on r1: (cont.)

I n s t r.

O r d e r

Time (clock cycles)

add r1,r2,r3 sub r4,r1,r3 and r6,r1,r7 or r8,r1,r9 xor r10,r1,r11

IF ID/RF EXA MEM WB

LU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

Im

ALU

Reg Dm Reg

ALU

Im Reg Dm Reg

“Forward” result from one stage to another

“or” OK if define read/write properly

Data Hazard Solution:

I n s t r.

O r d e r

Time (clock cycles)

add r1,r2,r3 sub r4,r1,r3 and r6,r1,r7 or r8,r1,r9 xor r10,r1,r11

IF ID/RF EXA MEM WB

LU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

Im

ALU

Reg Dm Reg

ALU

Im Reg Dm Reg

(7)

Dependencies backwards in time are hazards

Can’t solve with forwarding:

Must delay/stall instruction dependent on loads

Forwarding (or Bypassing):

What about Loads

Time (clock cycles)

lw r1,0(r2) sub r4,r1,r3

IF ID/RF EX MEM WB

ALU

Im Reg Dm Reg

ALU

Im Reg Dm Reg

Referensi

Dokumen terkait

One-on-one meeting frequency. One-on-ones empower you to unearth issues before they become full-blown problems. Imagine these two scenarios: Scenario 1: In the first one, manager Mary meets with her direct reports once a week. She hears from one of her employees that there is some tension arising among the team and this helps Mary address it immediately before it becomes a major problem. Scenario 2: Manager Michael has never scheduled regular one-on-ones. After a couple of months, he realizes that there’s tension in the team, rumours about people, and some clashes between co-workers who aren’t working well together. No one was able to address this with Michael, mainly because he never sat down with each employee to ask about team dynamics and the challenges that he could help overcome as their manager. This is just one of many examples that show how one-on-ones empower you to proactively fix situations before they become big problems. From helping you solve team issues to allowing you to coach employees when they should be focusing on different priorities… one-on-one meetings can help you defuse workplace bombs before they explode. As Andy Grove argues: “The meeting should cover anything important that has happened since the last meeting: current hiring problems, people problems in general, and- very, very important- potential problems. Even when a problem isn’t tangible, even if it’s only an intuition that something’s wrong.” 4 Just like managers in the world’s most innovative companies, you can use one-on-ones as a powerful tool to stay updated about issues and provide your team with ongoing support. 4. One-on-ones provide the ideal environment to exchange feedback Imagine getting an email from your boss saying “we need to talk.” Unsurprisingly, receiving an email like that would cause many of us to freak out a little, and immediately think that we are in trouble (or the feeling of being sent to the principal’s office…). To try and prevent your team from these mini heart attacks, you can exchange feedback during your regularly scheduled one-on-ones. One-on-one meetings are the ideal scenario to ask for feedback about the company, the team, and your management style. Similarly, they’re the perfect moment (a private, face-to-face conversation) to give your employees helpful feedback on their performance. We discuss specific ways to ask for feedback and provide constructive criticism in chapter 5. . . . To sum up, there are many benefits you’re missing out on if you still haven’t scheduled regular one-on-ones. A few of them include increased productivity, better relationships with your teammates, and the ability to address issues proactively and exchange ongoing feedback. If you’re feeling motivated and ready to start scheduling, we think you’ll enjoy reading the next chapter! 2.1 One-on-one meeting frequency: How often do great managers meet with their employees? Before communicating your decision to schedule regular meetings with your teammates, you should spend some time deciding if you want to do it weekly or