CS 152 Computer Architecture and Engineering Lecture 15 Advanced Superscalars Krste Asanovic Electrical Engineering and Computer Sciences University of California at Berkeley http www eecs berkeley edu krste http inst eecs berkeley edu cs152 Last time in Lecture 14 Control hazards are serious impediment to superscalar performance Dynamic branch predictors can be quite accurate 95 and avoid most control hazards Branch History Tables BHTs just predict direction later in pipeline Just need a few bits per entry 2 bits gives hysteresis Need to decode instruction bits to determine whether this is a branch and what the target address is Branch Target Buffer BTB predicts whether a branch and target address Needs PC tag predicted Next PC and direction Just needs PC of instruction to predict target of branch if any Return address stack special form of BTB used to predict subroutine return addresses 4 1 2008 CS152 Spring 08 2 Data in ROB Design HP PA8000 Pentium Pro Core2Duo Register File holds only committed state Ins use exec op p1 src1 p2 src2 pd dest Reorder buffer Load Unit FU FU FU Store Unit data t 1 t2 tn Commit t result On dispatch into ROB ready sources can be in regfile or in ROB dest copied into src1 src2 if ready before dispatch On completion write to dest field and broadcast to src4 1 2008 fields 3 CS152 Spring 08 Unified Physical Register File MIPS R10K Alpha 21264 Pentium 4 r1 r2 ti tj Rename Table Snapshots for mispredict recovery Load Unit FU FU FU ROB not shown t1 t2 tn Reg File FU Store Unit t result One regfile for both committed and speculative values no data in ROB During decode instruction result allocated new physical register source regs translated to physical regs through rename table Instruction reads data from regfile at start of execute not in decode Write back updates reg busy bits on instructions in ROB assoc searc Snapshots of rename table taken at every branch to recover mispredicts On exception renaming undone in reverse order of issue MIPS R10000 4 1 2008 CS152 Spring 08 4 Pipeline Design with Physical Regfile Branch Prediction PC Fetch Branch kill Resolution Update predictors kill kill kill Out of Order In Order Decode Rename Reorder Buffer Commit In Order Physical Reg File Branch ALU Unit Execute 4 1 2008 CS152 Spring 08 MEM Store Buffe r D 5 Lifetime of Physical Registers Physical regfile holds committed and speculative values Physical registers decoupled from ROB entries no data in ROB ld r1 r3 add r3 r1 4 sub r6 r7 r9 add r3 r3 r6 ld r6 r1 add r6 r6 r3 st r6 r1 ld r6 r11 Rename ld P1 Px add P2 P1 sub P3 Py add P4 P2 ld P5 P1 add P6 P5 st P6 P1 ld P7 Pw 4 Pz P3 P4 When can we reuse a physical register When next write of same architectural register commits 4 1 2008 CS152 Spring 08 6 Physical Register Management Physical Regs Free List Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P0 P1 P2 P3 P4 P5 P6 P7 P8 P8 P7 P5 P6 4 1 2008 p p p p ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 r1 Pn ROB use ex R6 R7 R3 R1 P0 P1 P3 P2 P4 op p1 PR1 p2 PR2 Rd CS152 Spring 08 LPRd PRd LPRd requires third read port on Rename Table for each instruction 7 Physical Register Management Physical Regs Free List Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P0 P1 P2 P3 P4 P5 P6 P7 P8 P8 P0 P7 P5 P6 4 1 2008 p p p p ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 r1 Pn ROB use ex x r1 R6 R7 R3 R1 P0 P1 P3 P2 P4 op p1 ld PR1 p p2 PR2 P7 Rd LPRd P8 PRd P0 CS152 Spring 08 8 Physical Register Management Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P8 P0 P7 P1 P5 P6 4 1 2008 P0 P1 P2 P3 P4 P5 P6 P7 P8 R6 R7 R3 R1 p p p p P0 P1 P3 P2 P4 ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 r1 Pn ROB use ex x x r1 r3 Physical Regs Free List op p1 PR1 p2 PR2 ld p P7 add P0 P0 P1 Rd CS152 Spring 08 LPRd P8 P7 PRd 9 Physical Register Management Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P8 P0 P7 P1 P5 P3 P6 4 1 2008 P0 P1 P2 P3 P4 P5 P6 P7 P8 R6 R7 R3 R1 p p p p P0 P1 P3 P2 P4 ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 r1 Pn ROB use ex x x r1 x r3 r6 Physical Regs Free List op p1 PR1 p2 PR2 ld p P7 add P0 P0 sub p P1 P6 P3 Rd p CS152 Spring 08 LPRd P8 P7 P5 P5 PRd 10 Physical Register Management Physical Regs Free List Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P0 P1 P2 P3 P4 P5 P6 P7 P8 P8 P0 P7 P1 P2 P5 P3 P6 x x r1 xr3 x r6 r3 4 1 2008 p p p p ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 r1 Pn ROB use ex R6 R7 R3 R1 P0 P1 P3 P2 P4 op p1 ld add sub add PR1 p p2 PR2 P7 P0 P0 p P1 P6 P1 P3 P2 Rd p CS152 Spring 08 LPRd P8 P7 P5 P5 P1 P3 PRd 11 Physical Register Management Physical Regs Free List Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P8 P0 P7 P1 P2 P5 P3 P4 P6 4 1 2008 R6 R7 R3 R1 p p p p P0 P1 P3 P2 P4 ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 r1 Pn ROB use ex x x r1 xr3 x r6 x r3 r6 P0 P1 P2 P3 P4 P5 P6 P7 P8 op p1 PR1 p2 PR2 ld p P7 add P0P0 sub p P1 P6 add P3 P1 ld P0 P2 P4 Rd p CS152 Spring 08 LPRd P8 P7 P5 P5 P1P3 P3 PRd 12 Physical Register Management Physical Regs Free List Rename Table R0 R1 R2 R3 R4 R5 R6 R7 P0 P1 P2 P3 P4 P5 P6 P7 P8 P8 P0 P7 P1 P2 P5 P3 P4 P6 x x x r1 xr3 x r6 x r3 r6 4 1 2008 p R6 R7 R3 R1 p p p p P0 P1 P3 P2 P4 ld r1 0 r3 add r3 r1 4 sub r6 r7 r6 add r3 r3 r6 ld r6 0 …
View Full Document
Unlocking...