Download Tomasulo Processor Architecture: Reorder Buffer and Instruction Commit - Prof. Alan L. Sus and more Exams Computer Science in PDF only on Docsity!
CMSC 411CMSC
Computer Systems Architecture
Lecture 10
Instruction Level Parallelism (cont.)Instruction Level Parallelism (cont.)
Alan Sussmanl @
d^
d
Administrivia^ •^
Finish reading Chapter 2 of H&P • First exam scheduled for this Thursday • First exam scheduled for this Thursday^ –^
on Units 1-3 – Wanli will be giving it
CMSC 411 - 10 (from Patterson)
2
Outline •^ ILP •^ Compiler techniques to increase ILP
p^
q
•^ Loop Unrolling •^ Static Branch Prediction •^ Dynamic Branch Prediction •^ Overcoming Data Hazards with DynamicSchedulingScheduling •^ Tomasulo Algorithm •^ ConclusionConclusion
CMSC 411 - 8 (from Patterson)
3
Tomasulo Organization
From H&PFigure 2.
From Mem
FP Registers
FP OpQueue
Load BuffersLoad Buffers
Load1Load2Load3Load
StoreBuffers
Load4Load5Load
Add1Add2Add
Mult1Mult
Reservation
To Mem
FP addersFP adders
FP multipliersFP multipliers
Stations CMSC 411 - 10 (from Patterson)
Common Data Bus (CDB)
4
Reservation Station ComponentsReservation
Station Components
Op:
Operation to perform in the unit (e.g., + or –)
Vj, Vk: Value of Source operands– Store buffers have V field, result to be storedQj, Qk: Reservation stations producing source registers (value to beQj, Q
p^
g^
g^
written)– Note: Qj,Qk=0 => ready– Store buffers only have Qi for RS producing result
S o e bu e s o
y^
a e Q
o^
S p oduc
g^
esu
Busy: Indicates reservation station or FU is busyAlso:
Register result status table—Indicates which functional unit will write each register, ifone exists. Blank when no pending instructions that will write that register.
CMSC 411 - 10 (from Patterson)
5
Three Stages of Tomasulo Algorithm^ 1. Issue—get instruction from FP Op Queue
If reservation station free (no structural hazard),control issues instr & sends operands (renames registers).
2. Execute—operate on operands (EX)
When both operands ready then execute;When both operands ready then execute;if not ready, watch Common Data Bus for result
3. Write result—finish 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)D
th
b^
d^
t
CMSC 411 - 10 (from Patterson)
6
–^ D
oes the broadcast
Tomasulo Example
Instruction stream^ Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F
DIVD
F^
F^
F
ADDD
F
F^
F^
3 Load/Buffers
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No
FU count
3 FP Adder R S
Add
No Mult
No Mult
No
FU count Register result status:
down
3 FP Adder R.S.2 FP Mult R.S.
Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU
Clock cycle
CMSC 411 - 10 (from Patterson)
7
Clock cycle^ counter
Tomasulo Example Cycle 1
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
Yes
34+R
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F
DIVD
F^
F^
F
ADDD
F^
F^
F
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No Mult
No Mult
No
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Load
CMSC 411 - 10 (from Patterson)
8
Tomasulo Example Cycle 6
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
1 Add
Yes
SUBD
M(A1) M(A2)
Add
Yes
ADDD
M(A2)
Add (^ )
Add
No 9 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
Add
Add
Mult
CMSC 411 - 10 (from Patterson)
13
•^ Issue ADDD here despite name dependency on F6?
Tomasulo Example Cycle 7
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F^
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
0 Add
Yes
SUBD
M(A1) M(A2)
Add
Yes
ADDD
M(A2)
Add (^ )
Add
No 8 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
Add
Add
Mult
CMSC 411 - 10 (from Patterson)
14
•^ Add1 (SUBD) completing; what is waiting for it?
Tomasulo Example Cycle 8
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No 2 Add
Yes
ADDD (M-M) M(A2)
(^
)^ (
Add
No 7 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
Add
(M-M) Mult
CMSC 411 - 10 (from Patterson)
15
Tomasulo Example Cycle 9
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F^
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No 1 Add
Yes
ADDD (M-M) M(A2)
(^
)^ (
Add
No 6 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
Add
(M-M) Mult
CMSC 411 - 10 (from Patterson)
16
Tomasulo Example Cycle 10
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No 0 Add
Yes
ADDD (M-M) M(A2)
(^
)^ (
Add
No 5 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
Add
(M-M) Mult
CMSC 411 - 10 (from Patterson)
17
•^ Add2 (ADDD) completing; what is waiting for it?
Tomasulo Example Cycle 11
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F^
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No 4 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
(M-M+M(M-M) Mult
W it
lt^
f ADDD h
?^ CMSC 411 - 10 (from Patterson)
18
•^ W
rite result of ADDD here?
•^ All quick instructions complete in this cycle!
Tomasulo Example Cycle 12
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No 3 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
(M-M+M(M-M) Mult CMSC 411 - 10 (from Patterson)
19
Tomasulo Example Cycle 13
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F^
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No 2 Mult
Yes MULTD M(A2) R(F4) Mult
Yes
DIVD
M(A1) Mult
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
Mult
M(A2)
(M-M+M(M-M) Mult CMSC 411 - 10 (from Patterson)
20
Tomasulo Example Cycle 55
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F^
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No Mult
No 1 Mult
Yes
DIVD
M*F
M(A1)
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
M*F
M(A2)
(M-M+M(M-M) Mult CMSC 411 - 10 (from Patterson)
25
Tomasulo Example Cycle 56
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F^
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No Mult
No 0 Mult
Yes
DIVD
M*F4 M(A1)
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
M*F
M(A2)
(M-M+M(M-M) Mult CMSC 411 - 10 (from Patterson)
26
•^ Mult2 (DIVD) is completing; what is waiting for it?
Tomasulo Example Cycle 57
Instruction status:
Exec
Write
Instruction
j^
k^
Issue
Comp Result
Busy
Address
LD^
F^
34+^
R^
Load
No
LD^
F^
45+^
R^
Load
No
MULTD
F
F^
F^
Load
No
SUBD
F^
F^
F^
DIVD
F^
F^
F^
ADDD
F
F^
F^
Reservation Stations:
S^
S^
RS^
RS
Time
Name
Busy
Op
Vj^
Vk^
Qj^
Qk
Add
No Add
No Add
No Mult
No Mult
Yes
DIVD
M*F4 M(A1)
Register result status:Register
result status:
Clock
F^
F^
F^
F^
F^
F
F
...^
F
FU^
M*F
M(A2)
(M-M+M(M-M) Result
•^ Once again: In
order issue out
of
order execution and
CMSC 411 - 10 (from Patterson)
27
•^ Once
again: In-order issue, out-of-order execution and
out-of-order completion.
Why can Tomasulo overlap loop iterations?^ • Register renaming
- Multiple iterations use different physical destinations for registers(dynamic loop unrolling).
• Reservation stationsReservation stations
- Permit instruction issue to advance past integer control flow operations– Also buffer old values of registers - totally avoiding WAR stalls
• Other perspective: Tomasulo building data flowdependency graph on the fly
CMSC 411 - 10 (from Patterson)
28
2 Main Advantages w/ Tomasulo 1. Distribution of the hazard detection logic
–^ distributed reservation stations and the CDBdistributed reservation stations and the CDB–^ If multiple instructions waiting on single result, & eachinstruction already has other operand, then instructions canbe released simultaneously by broadcast on CDBbe released simultaneously by broadcast on CDB–^ If a centralized register file were used, the units would haveto read their results from the registers when register busesare availableare available
2. Elimination
of
stalls
for
WAW
and
WAR
hazardshazards
CMSC 411 - 10 (from Patterson)
29
Tomasulo Drawbacks • Complexity
d l^
f 360/91 MIPS 10000 Al h
– delays of 360/91, MIPS 10000, Alpha 21264
• Many associative stores (CDB) at high speed• Performance limited by Common Data Bus• Performance limited by Common Data Bus
– Each CDB must go to multiple functional units^ ⇒
high capacitance, high wiring density
– Number of functional units that can complete per cycle limited toNumber of functional units that can complete per cycle limited toone!
» Solution is to use multiple CDBs
⇒^
more FU logic for parallel
associative stores
• Non-precise interrupts!
– We will address this later
CMSC 411 - 10 (from Patterson)
30
And In Conclusion …
• Leverage Implicit Parallelism for Performance:Instruction Level Parallelism• Loop unrolling by compiler to increase ILP• Branch prediction to increase ILP• Dynamic HW exploiting ILP
- Works when can’t know dependence at compile time– Can hide L1 cache missesCan hide L1 cache misses– Code for one machine runs well on another
CMSC 411 - 10 (from Patterson)
31
And In Conclusion …
• Reservations stations:
renaming
to larger set of registers
+ buffering source operands– Prevents registers as bottleneck– Avoids WAR, WAW hazards– Allows loop unrolling in HW
Allows loop unrolling in HW
• Not limited to basic blocks(integer units get ahead, beyond branches)• Helps cache misses as well• Lasting Contributions
- Dynamic scheduling– Register renaming– Load/store disambiguation
CMSC 411 - 10 (from Patterson)
32
g
• 360/91 descendants are Intel Pentium 4, IBM Power 5/6,AMD Athlon/Opteron, …
Reorder Buffer Entry •^
Each entry in the ROB contains four fields:
1.^
Instruction type•^ a branch (has no destination result), a store (has a memory addressdestination), or a register operation (ALU operation or load, which hasregister destinations)
D^
ti^
ti
2.^
Destination•^ Register number (for loads and ALU operations) ormemory address (for stores) where the instruction result should be written
Value
3.^
Value•^ Value of instruction result until the instruction commits
4.^
Ready•^ Indicates that instruction has completed execution, and the value is ready
CMSC 411 - 10 (from Patterson)
37
Reorder Buffer operation
• Holds instructions in FIFO order, exactly as issued• When instructions complete, results placed into ROB
- Supplies operands to other instruction between executioncomplete & commit
⇒^ more registers like RS
– Tag results with ROB buffer number instead of reservation stationI
i^
i^
l^
h^
d^
f ROB
l^
d i
• Instructions commit
values at head of ROB placed in
registers• As a result, easy to undo
Reorder
As a result, easy to undospeculated instructionson mispredicted branchesor on exceptions
ReorderBuffer
FPOpQueue
FP Regs
or on exceptions
Res Stations
Res Stations
Commit path
CMSC 411 - 10 (from Patterson)
38
FP Adder
FP Adder