Docsity

Improving System Performance - Pipelining - Lecture Slides | CSC 246, Study notes of Computer Science

Partial preview of the text

Download Improving System Performance - Pipelining - Lecture Slides | CSC 246 and more Study notes Computer Science in PDF only on Docsity!

Improving SystemImproving System

Performance: PipeliningPerformance: Pipelining

December 08December 08

CSC201 Section 002

Fall, 2000

Goals Goals

  • Speed up the rate at whichinstructions are executed
    • faster computers!
  • Does not speed up the time tocomplete one instruction

Basic Idea (cont) Basic Idea (cont)

  • Result: anproduce resultsn-stage pipeline mayn times faster
  • So... why not havepipelines? 1000-stage

Time Æ Input 1

Input 2 Input 3

Output 1 Output 2 Output 3

Stages of Instruction Execution Stages of Instruction Execution

  • IF = instruction fetch and PCincrement
  • D = instruction decode
  • OF = operand fetch
  • EX = operation execution
  • R = store results Stage IF Stage D Stage OF Stage EX Stage R

InstructionStart

InstructionFinish

Problem #1: Data Dependencies Problem #1: Data Dependencies

  • What if instruction i+1 uses thevalue produced by instruction i?
  • Example
  • The OF stage of instruction 2 needsthe value produced by the R stage

of instruction 1

Mov EAX, var add EAX, var

IF D OF EX R

IF D OF EX R

Problem #1: Data Dependencies Problem #1: Data Dependencies

  • Solution A: detect dependenciesand "stall" the pipeline
    • detection: by hardware, or by compiler
  • Solution B: rearrange instructions toeliminate stalls
    • again, by compiler, or in hardware. Ex.:

Mov EAX, var add EAX, var

IF D OF EX R

IF D OF EX R

Replace:mov ESI, 0 Movmov ECX, 0EAX, var add EAX, var

With:mov EAX, var movMov ESI, 0ECX, 0 add EAX, var

Control Dependency Example Control Dependency Example

  • Cannot start IF stage of instructioni+1 until EX stage of instruction i

has finished

Je loopout

add EAX, EBX-Or- Mov res, EAX

IF D OF EX R

IF D OF EX R

Fixing Control Dependencies Fixing Control Dependencies

1. Stall pipeline until conditional jumphas executed (as shown)

2. Predict which way branch will go,fetch instruction from predicted

location

  • And “undo” the instruction if theprediction turns out to be wrong

Cmp ECX, 10 Je loopout Add eax, ebx (1 st^ instr. After add) (2 nd^ instr. After add) Mov res, EAX