CS184b: Computer Architecture [Single Threaded Architecture: - - PDF document

cs184b computer architecture single threaded architecture
SMART_READER_LITE
LIVE PREVIEW

CS184b: Computer Architecture [Single Threaded Architecture: - - PDF document

CS184b: Computer Architecture [Single Threaded Architecture: abstractions, quantification, and optimizations] Day6: January 23, 2000 Control Hazards (Pipelined ISA) Caltech CS184b Winter2001 -- DeHon 1 Today Control Hazards


slide-1
SLIDE 1

1

Caltech CS184b Winter2001 -- DeHon 1

CS184b: Computer Architecture [Single Threaded Architecture: abstractions, quantification, and

  • ptimizations]

Day6: January 23, 2000 Control Hazards (Pipelined ISA)

Caltech CS184b Winter2001 -- DeHon 2

Today

  • Control Hazards
  • Techniques to reduce impact
  • Exception

– what – why – challenges

slide-2
SLIDE 2

2

Caltech CS184b Winter2001 -- DeHon 3

Last Time

  • Pipelining
  • Cycles in flow graph
  • Avoiding
  • or accommodating dynamically

Caltech CS184b Winter2001 -- DeHon 4

Hazards

  • Structural (resource bound)
  • Data (value timing)
  • Control (knowing where to go next)
slide-3
SLIDE 3

3

Caltech CS184b Winter2001 -- DeHon 5

Pipeline DLX

DLX pipelined datapath from H&P (Fig. 3.4)

Caltech CS184b Winter2001 -- DeHon 6

Data Hazards

  • Didn’t effect IF or ID
  • Worst-case, one cycle stall
slide-4
SLIDE 4

4

Caltech CS184b Winter2001 -- DeHon 7

Pipeline DLX

DLX pipelined datapath from H&P (Fig. 3.4)

Caltech CS184b Winter2001 -- DeHon 8

Control Hazard

IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB

slide-5
SLIDE 5

5

Caltech CS184b Winter2001 -- DeHon 9

Control Hazard

IF ID EX MEM WB IF ID EX MEM WB

Caltech CS184b Winter2001 -- DeHon 10

What can we do?

slide-6
SLIDE 6

6

Caltech CS184b Winter2001 -- DeHon 11

What can we do?

  • Move earlier

– tighten cycle

  • “Guess” direction

– predict (and squash)

  • Accepted delayed transfer as part of arch.

– Branch delay slot

Caltech CS184b Winter2001 -- DeHon 12

Revised Pipeline

DLX repipelined datapath from H&P (Fig. 3.22)

slide-7
SLIDE 7

7

Caltech CS184b Winter2001 -- DeHon 13

Consequence?

IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB

Caltech CS184b Winter2001 -- DeHon 14

Consequence

  • Smaller cycle
  • Longer ID stage delay
  • Need separate Adder
  • Not branch to reg.?
slide-8
SLIDE 8

8

Caltech CS184b Winter2001 -- DeHon 15

Pipeline

IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB IF ID EX MEM WB

Caltech CS184b Winter2001 -- DeHon 16

Avoiding Lost Cycles

  • Do know where to go in not-taken case

– just keep incrementing PC

  • “Guess” taken
  • Begin Executing
  • Squash if Wrong
slide-9
SLIDE 9

9

Caltech CS184b Winter2001 -- DeHon 17

Predict Branch Taken

Branch: IF ID EX MEM WB Branch+1: IF ID EX MEM WB Branch+2: IF ID EX MEM WB IF ID EX MEM WB

Caltech CS184b Winter2001 -- DeHon 18

Predict Branch Taken (not)

Branch: IF ID EX MEM WB Branch+1: IF ID -- -- -- Branch+2: IF ID EX MEM WB IF ID EX MEM WB Squash ok: no state change, no effect of exec op

slide-10
SLIDE 10

10

Caltech CS184b Winter2001 -- DeHon 19

Avoiding Lost Cycle (2)

  • Solve like load latency

– separate load request – from load use

  • Separate branch instruction (computation)
  • From branch effect
  • Architecturally specify

– branch not take effect until X cycles later

Caltech CS184b Winter2001 -- DeHon 20

Branch Delay Slot

  • SUB R1,R2,R3
  • BEQZ R1,exit
  • ADD R4,R5,R6 // always executed
  • SUB R1,R4,R3
  • exit:
  • SW R3,4(R11)
slide-11
SLIDE 11

11

Caltech CS184b Winter2001 -- DeHon 21

Branch Taken

Branch: IF ID EX MEM WB B-Delay: IF ID EX MEM WB Target : IF ID EX MEM WB IF ID EX MEM WB

Caltech CS184b Winter2001 -- DeHon 22

Branch Not Taken

Branch: IF ID EX MEM WB B-Delay: IF ID EX MEM WB Branch+2: IF ID EX MEM WB IF ID EX MEM WB

slide-12
SLIDE 12

12

Caltech CS184b Winter2001 -- DeHon 23

More Control Fun to Come...

  • Knowing what to run next can be big limit

to exploiting parallelism (deep pipelining)

  • ILP need more branch prediction

Caltech CS184b Winter2001 -- DeHon 24

Exceptions

slide-13
SLIDE 13

13

Caltech CS184b Winter2001 -- DeHon 25

What?

  • Control transfer away from “normal”

execution

  • Every instruction

– a conditional, multiway branch? – (branch and link)

Caltech CS184b Winter2001 -- DeHon 26

What (examples)

  • Page Fault
  • System call
  • Interrupt (event)

– io – timer

  • Unknown Instruction
slide-14
SLIDE 14

14

Caltech CS184b Winter2001 -- DeHon 27

Why?

  • Cases represented are uncommon
  • Instructions explicitly checking for cases

add cycles

– …lots of cycles to check all cases – when seldom occur

  • Long instructions to describe all ways can

branch

– more compact to “configure” implicit places to go

Caltech CS184b Winter2001 -- DeHon 28

Properties/Types

  • synch/Asynch
  • request/coerced
  • maskable?
  • within/between instructions
  • resume/terminate
slide-15
SLIDE 15

15

Caltech CS184b Winter2001 -- DeHon 29

How make implementation difficult?

  • Need to preserve sequential instruction

abstraction

  • Creates cause to see what happens between

instructions

– need to provide clean state view

  • Instruction fail and need to be “restarted”

– e.g. page fault

Caltech CS184b Winter2001 -- DeHon 30

Hard cases

  • Synchronous
  • within instruction
  • restartable
  • latencies or parallelism allow out-of-order

completion

slide-16
SLIDE 16

16

Caltech CS184b Winter2001 -- DeHon 31

Hazards

  • LW R1,4(R2)
  • ADD R3,R4,R3
  • Case:

– DLX – Pipeline where WB can occur before MEM

  • May be correct to complete ADD

– no hazards – but not restartable when fault on LW address

Caltech CS184b Winter2001 -- DeHon 32

Restart Hazards

  • LW R1,4(R2)
  • ADD R3,R4,R3
  • Restart/rerun

– can get wrong answer by executing instruction again

slide-17
SLIDE 17

17

Caltech CS184b Winter2001 -- DeHon 33

Next Time

  • Talk about how to solve

– (read Smith/Imprecise exception paper)

  • …and get started in ILP

– note: read tomasulo along with HP4.2

Caltech CS184b Winter2001 -- DeHon 34

Big Ideas

  • Maintaining Abstraction
  • Challenge of deciding what to do next

– cyclic dependency

  • Minimizing cost thereof

– pipeline structure (minimize latency) – branch delay – prediction

  • Common Case

– exceptions – control flow