Title: CS252 Graduate Computer Architecture Lecture 7 ILP 1: Loop-Level parallelism extraction, Data Flow, Explicit Register Renaming.
1CS252Graduate Computer ArchitectureLecture 7
ILP 1Loop-Level parallelism extraction,Data
Flow, Explicit Register Renaming.
- September 22nd, 2003
- Prof. John Kubiatowicz
- http//www.cs.berkeley.edu/kubitron/courses/cs252
-F03
2Review Dynamic hardware techniques for
out-of-order execution
- HW exploitation of ILP
- Works when cant know dependence at compile time.
- Code for one machine runs well on another
- Scoreboard (ala CDC 6600 in 1963)
- Centralized control structure
- No register renaming, no forwarding
- Pipeline stalls for WAR and WAW hazards.
- Are these fundamental limitations??? (No)
- Reservation stations (ala IBM 360/91 in 1966)
- Distributed control structures
- Implicit renaming of registers (dispatched
pointers) - WAR and WAW hazards eliminated by register
renaming - Results broadcast to all reservation stations for
RAW
3Review Scoreboard Architecture(CDC 6600)
Functional Units
Registers
SCOREBOARD
Memory
4Review Four Stages of Scoreboard Control
- Issuedecode instructions check for structural
hazards (ID1) - Instructions issued in program order (for hazard
checking) - Dont issue if structural hazard
- Dont issue if instruction is output dependent on
any previously issued but uncompleted instruction
(no WAW hazards) - Read operandswait until no data hazards, then
read ops (ID2) - All real dependencies (RAW hazards) resolved in
this stage, since we wait for instructions to
write back data. - No forwarding of data in this model!
- Executionoperate on operands (EX)
- The functional unit begins execution upon
receiving operands. When the result is ready, it
notifies the scoreboard that it has completed
execution. - Write resultfinish execution (WB)
- Stall until no WAR hazards with previous
instructionsExample DIVD F0,F2,F4
ADDD F10,F0,F8 SUBD F8,F8,F14CDC 6600
scoreboard would stall SUBD until ADDD reads
operands
5Review Tomasulo Organization
FP Registers
From Mem
FP Op Queue
Load Buffers
Load1 Load2 Load3 Load4 Load5 Load6
Store Buffers
Add1 Add2 Add3
Mult1 Mult2
Reservation Stations
To Mem
FP adders
FP multipliers
Common Data Bus (CDB)
6Review Three Stages of Tomasulo Algorithm
- 1. Issueget instruction from FP Op Queue
- If reservation station free (no structural
hazard), control issues instr sends operands
(renames registers). - 2. Executionoperate on operands (EX)
- When both operands ready then execute if not
ready, watch Common Data Bus for result - 3. Write resultfinish execution (WB)
- Write on Common Data Bus to all awaiting units
mark reservation station available - Normal data bus data destination (go to bus)
- Common data bus data source (come from bus)
- 64 bits of data 4 bits of Functional Unit
source address - Write if matches expected Functional Unit
(produces result) - Does the broadcast
7Review Comparison Cycle 62
- Why take longer on scoreboard/6600?
- Structural Hazards
- Lack of forwarding
8Tomasulo Loop Example
- Loop LD F0 0 R1
- MULTD F4 F0 F2
- SD F4 0 R1
- SUBI R1 R1 8
- BNEZ R1 Loop
- Assume Multiply takes 4 clocks
- Assume first load takes 8 clocks (cache miss),
second load takes 1 clock (hit) - To be clear, will show clocks for SUBI, BNEZ
- Reality integer instructions ahead
9Loop Example
10Loop Example Cycle 1
11Loop Example Cycle 2
12Loop Example Cycle 3
- Implicit renaming sets up DataFlow graph
13Loop Example Cycle 4
- Dispatching SUBI Instruction
14Loop Example Cycle 5
15Loop Example Cycle 6
- Notice that F0 never sees Load from location 80
16Loop Example Cycle 7
- Register file completely detached from
computation - First and Second iteration completely overlapped
17Loop Example Cycle 8
18Loop Example Cycle 9
- Load1 completing who is waiting?
- Note Dispatching SUBI
19Loop Example Cycle 10
- Load2 completing who is waiting?
- Note Dispatching BNEZ
20Loop Example Cycle 11
21Loop Example Cycle 12
- Why not issue third multiply?
22Loop Example Cycle 13
23Loop Example Cycle 14
- Mult1 completing. Who is waiting?
24Loop Example Cycle 15
- Mult2 completing. Who is waiting?
25Loop Example Cycle 16
26Loop Example Cycle 17
27Loop Example Cycle 18
28Loop Example Cycle 19
29Loop Example Cycle 20
30Why can Tomasulo overlap iterations of loops?
- Register renaming
- Multiple iterations use different physical
destinations for registers (dynamic loop
unrolling). - Reservation stations
- Permit instruction issue to advance past integer
control flow operations - Other idea Tomasulo building dynamic DataFlow
graph from instructions.
31Administrivia
- Paper mailing list is cs252-summary_at_kubi.cs.berk
eley.edu - Prereq exams
- They are available with my administrative
assistant (really!) - If you got X or ?- please read solutions!!!
32Data-Flow Architectures
- Basic Idea Hardware respresents direct encoding
of compiler dataflow graphs - Data flows along arcs inTokens.
- When two tokens arrive atcompute box, box
fires andproduces new token. - Split operations produce copiesof tokens
Input a,b y (ab)/x x
(a(ab))b output y,x
33Paper by Dennis and Misunas
Reservation Station?
34Explicit Register Renaming
- Make use of a physical register file that is
larger than number of registers specified by ISA - Keep a translation table
- ISA register gt physical register mapping
- When register is written, replace table entry
with new register from freelist. - Physical register becomes free when not being
used by any instructions in progress. - Pipeline can be exactly like standard DLX
pipeline - IF, ID, EX, etc.
- Advantages
- Removes all WAR and WAW hazards
- Like Tomasulo, good for allowing full
out-of-order completion - Allows data to be fetched from a single register
file - Makes speculative execution/precise interrupts
easier - All that needs to be undone for precise break
pointis to undo the table mappings
35QuestionCan we use explicit register renaming
with scoreboard?
Rename Table
36Scoreboard Example
37Renamed Scoreboard 1
- Each instruction allocates free register
- Similar to single-assignment compiler
transformation
38Renamed Scoreboard 2
39Renamed Scoreboard 3
40Renamed Scoreboard 4
41Renamed Scoreboard 5
42Renamed Scoreboard 6
43Renamed Scoreboard 7
44Renamed Scoreboard 8
45Renamed Scoreboard 9
46Renamed Scoreboard 10
- Notice that P32 not listed in Rename Table
- Still live. Must not be reallocated by accident
47Renamed Scoreboard 11
48Renamed Scoreboard 12
49Renamed Scoreboard 13
50Renamed Scoreboard 14
51Renamed Scoreboard 15
52Renamed Scoreboard 16
53Renamed Scoreboard 17
54Renamed Scoreboard 18
55Explicit Renaming Support Includes
- Rapid access to a table of translations
- A physical register file that has more registers
than specified by the ISA - Ability to figure out which physical registers
are free. - No free registers ? stall on issue
- Thus, register renaming doesnt require
reservation stations. However - Many modern architectures use explicit register
renaming Tomasulo-like reservation stations to
control execution.
56Explicit register renamingR10000 Freelist
Management
Current Map Table
Freelist
- Physical register file larger than ISA register
file - On issue, each instruction that modifies a
register is allocated new physical register from
freelist - Used on R10000, Alpha 21264, HP PA8000
57Explicit register renamingR10000 Freelist
Management
Done?
Current Map Table
Freelist
F0
P0
LD P32,10(R2)
N
- Note that physical register P0 is dead (or not
live) past the point of this load. - When we go to commit the load, we free up
58Explicit register renamingR10000 Freelist
Management
Done?
Current Map Table
F10
P10
ADDD P34,P4,P32
N
Freelist
F0
P0
LD P32,10(R2)
N
59Explicit register renamingR10000 Freelist
Management
Current Map Table
Freelist
?
Checkpoint at BNE instruction
P60
P62
60Explicit register renamingR10000 Freelist
Management
Done?
Current Map Table
--
ST 0(R3),P40
Y
F0
P32
ADDD P40,P38,P6
Y
F4
P4
LD P38,0(R3)
Y
--
BNE P36,ltgt
N
F2
P2
DIVD P36,P34,P6
N
F10
P10
ADDD P34,P4,P32
y
Freelist
F0
P0
LD P32,10(R2)
y
?
Checkpoint at BNE instruction
P60
P62
61Explicit register renamingR10000 Freelist
Management
Done?
Current Map Table
F2
P2
DIVD P36,P34,P6
N
F10
P10
ADDD P34,P4,P32
y
Freelist
F0
P0
LD P32,10(R2)
y
Speculation error fixed by restoring map table
and freelist
?
Checkpoint at BNE instruction
P60
P62
62What about Precise Interrupts?
- Both Scoreboard and Tomasulo haveIn-order
issue, out-of-order execution, and out-of-order
completion - Need to fix the out-of-order completion aspect
so that we can find precise breakpoint in
instruction stream.
63Relationship between precise interrupts and
specultation
- Speculation is a form of guessing.
- Important for branch prediction
- Need to take our best shot at predicting branch
direction. - If we issue multiple instructions per cycle, lose
lots of potential instructions otherwise - Consider 4 instructions per cycle
- If take single cycle to decide on branch, waste
from 4 - 7 instruction slots! - If we speculate and are wrong, need to back up
and restart execution to point at which we
predicted incorrectly - This is exactly same as precise exceptions!
- Technique for both precise interrupts/exceptions
and speculation in-order completion or commit
64HW support for precise interrupts
- Need HW buffer for results of uncommitted
instructions reorder buffer - 3 fields instr, destination, value
- Reorder buffer can be operand source gt more
registers like RS - Use reorder buffer number instead of reservation
station when execution completes - Supplies operands between execution complete
commit - Once operand commits, result is put into
register - Instructionscommit
- As a result, its easy to undo speculated
instructions on mispredicted branches or on
exceptions
65Four Steps of Speculative Tomasulo Algorithm
- 1. Issueget instruction from FP Op Queue
- If reservation station and reorder buffer slot
free, issue instr send operands reorder
buffer no. for destination (this stage sometimes
called dispatch) - 2. Executionoperate on operands (EX)
- When both operands ready then execute if not
ready, watch CDB for result when both in
reservation station, execute checks RAW
(sometimes called issue) - 3. Write resultfinish execution (WB)
- Write on Common Data Bus to all awaiting FUs
reorder buffer mark reservation station
available. - 4. Commitupdate register with reorder result
- When instr. at head of reorder buffer result
present, update register with result (or store to
memory) and remove instr from reorder buffer.
Mispredicted branch flushes reorder buffer
(sometimes called graduation)
66Summary
- DataFlow view
- Data triggers execution rather than instructions
triggering data - Dynamic hardware schemes can unroll loops
dynamically in hardware - Form of limited dataflow
- Register renaming is essential
- Explicit Renaming more physical registers than
needed by ISA. - Rename table tracks current association between
architectural registers and physical registers - Uses a translation table to perform compiler-like
transformation on the fly - Precise Interrupts
- Must commit things back in order
- Reorder buffer temporarily holds results until
commit possible - Toss out things to achieve precise interrupt
point