ROB Example We will go through an example of the use of reorder buffers in two scenarios— Completion without exceptions One instruction raises an exception First, let’s consider the data structures in use for the example. ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
All values now in reg. file Reservation stations and ROB are empty RF In RF tag value - 54 76 -5 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
Code for the example A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 At each step, we will show the changes by coloring the cell backgrounds pink. ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF A LW R2, 4(R0) In RF tag value - 54 76 -5 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF A LW R2, 4(R0) In RF tag value - 54 76 -5 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 54 Imm=4 Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF B MULT R3, R1, R2 In RF tag value - 54 76 -5 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 54 Imm=4 Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF B MULT R3, R1, R2 In RF tag value - 54 76 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 1 76 Reservation Stations FUs 0 (cache miss) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF C LW R2, 8(R0) In RF tag value - 54 76 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 1 76 Reservation Stations FUs 0 (cache miss) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF C LW R2, 8(R0) In RF tag value - 54 76 2 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 C 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 2 54 Imm=8 1 76 Reservation Stations FUs 0 (cache miss) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF D ADD R1, R1, R2 In RF tag value - 54 76 2 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 C 3 4 5 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 2 54 Imm=8 1 76 Reservation Stations FUs 0 (cache miss) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF D ADD R1, R1, R2 In RF tag value - 54 3 76 2 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 C 3 R1 D 4 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 3 76 2 1 TAIL Reservation Stations FUs 0 (cache miss) 2 (cache hit) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF E SUB R2, R0, R1 In RF tag value - 54 3 76 2 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 C 3 R1 D 4 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 3 76 2 1 TAIL Reservation Stations FUs 0 (cache miss) 2 (cache hit) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF E SUB R2, R0, R1 In RF tag value - 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 C 3 R1 D 4 E 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 4 54 3 76 2 1 TAIL Reservation Stations FUs 0 (cache miss) 2 (cache hit) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value - 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 no C 3 R1 D 4 E 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 4 54 3 76 667 1 TAIL Reservation Stations FUs 0 (cache miss) 2, 667, no exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value - 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 no C 3 R1 D 4 E 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 4 54 3 1 76 TAIL Reservation Stations FUs 0 (cache miss) 3 ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value - 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 no C 3 R1 743 D 4 E 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 4 54 743 1 76 TAIL Reservation Stations FUs 0 (cache miss) 3, 743, no exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value - 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 No C 3 R1 743 D 4 –689 E 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 1 76 TAIL Reservation Stations FUs 0 (cache miss) 4, –689, no exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF F ADD R0, R1, R2 In RF tag value - 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 No C 3 R1 743 D 4 –689 E 5 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 1 76 TAIL Reservation Stations FUs 0 (cache miss) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF F ADD R0, R1, R2 In RF tag value 5 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 No C 3 R1 743 D 4 –689 E 5 R0 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 5 743 –689 1 76 TAIL Reservation Stations FUs 0 (cache miss) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 A 1 R3 B 2 667 No C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 1 76 TAIL Reservation Stations FUs 0 (cache miss) 5, 54, no exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 -5 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 1 76 650000 TAIL Reservation Stations FUs 0, 650000, no exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 650000 1 -99 Reg=R2, Tag=0, Val=650000 R0 Note: Tag doesn’t match RF tag, don’t set “In RF” Note: Commit value to register- file state R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 TAIL Reservation Stations FUs 1 (multiply) ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
Two scenarios next… Multiply Scenario #1: Completes without exception Scenario #2: Raises exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 650000 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 49400000 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 TAIL Reservation Stations FUs 1, 49400000, no exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 650000 - 49400000 Reg=R3, Tag=1, Val=49400000 R0 Note: Tag matches RF tag, so set “In RF” Note: Commit value to register-file state R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 49400000 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 TAIL Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 667 - 49400000 Reg=R2, Tag=2, Val=667 R0 Note: Tag does not match RF tag, don’t set “In RF” Note: Commit value to register-file state R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 49400000 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 TAIL Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 - 743 4 667 49400000 Reg=R1, Tag=3, Val=743 R0 Note: Tag matches RF tag, so set “In RF” Note: Commit value to register-file state R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 49400000 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 my tag src1 ready tag/value src2 HEAD TAIL Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 - 743 – 689 49400000 Reg=R2, Tag=4, Val=–689 R0 Note: Tag matches RF tag, so set “In RF” Note: Commit value to register-file state R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 49400000 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 my tag src1 ready tag/value src2 HEAD TAIL Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value - 54 743 –689 49400000 Reg=R0, Tag=5, Val=54 R0 Note: Tag matches RF tag, so set “In RF” Note: Commit value to register file state R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 49400000 B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 my tag src1 ready tag/value src2 HEAD TAIL Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
Now do scenario #2 Multiply raises exception. ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value 5 54 3 76 4 650000 1 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 - Yes B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD my tag src1 ready tag/value src2 TAIL Reservation Stations FUs 1, exception ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
A LW R2, 4(R0) B MULT R3, R1, R2 C LW R2, 8(R0) D ADD R1, R1, R2 E SUB R2, R0, R1 F ADD R0, R1, R2 RF In RF tag value - 54 76 650000 -99 R0 R1 R2 ROB R3 Entry Dest Result Exception Completed PC R2 650000 No A 1 R3 - Yes B 2 667 C 3 R1 743 D 4 –689 E 5 R0 54 F 6 7 8 9 10 11 12 13 14 15 HEAD TAIL my tag src1 ready tag/value src2 Reservation Stations FUs ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University
Other animations Another good animation of reorder buffers is the one by John Kubiatowicz. See www.cs.ccu.edu.tw/~chen/arch/reorder-step.ppt or www.cs.uit.no/studier/kurs/d241/info/2002h/notes/Berkeley/ Kubiatowicz-2001f/files/lectures/lec19-memory.ppt. A higher-level visualization of the process is at http://www.ece.lsu.edu/koppel/see/ ECE 463/521, Profs. Conte, Rotenberg, & Gehringer, Dept. of ECE, NC State University