ΗΥ425 Αρχιτεκτονική Υπολογιστών. Precise Exceptions Speculation Reorder Buffer. Βασίλης Παπαευσταθίου Ιάκωβος Μαυροειδής

Σχετικά έγγραφα
ΗΥ425 Αρχιτεκτονική Υπολογιστών. Precise Exception Speculation Reorder Buffer. Ιάκωβος Μαυροειδής

Υποθετική Εκτέλεση Εντολών

Δυναμική Δρομολόγηση Εντολών (Dynamic Scheduling)

ΗΥ425 Αρχιτεκτονική Υπολογιστών. Προχωρημένες Τεχνικές Pipelining. Ιάκωβος Μαυροειδής

ΗΥ425 Αρχιτεκτονική Υπολογιστών. Static Scheduling. Ιάκωβος Μαυροειδής

CS425 Computer Systems Architecture

CS-425 Mid-term exam

ΗΥ425 Αρχιτεκτονική Υπολογιστών. Static Scheduling. Βασίλης Παπαευσταθίου Ιάκωβος Μαυροειδής

Instruction-Level Parallelism and its Dynamic Exploitation. Μάθηµα 3ο Computer Architecture-A Quantitative Approach

ΤΕΧΝΙΚΕΣ ΑΥΞΗΣΗΣ ΤΗΣ ΑΠΟΔΟΣΗΣ ΤΩΝ ΥΠΟΛΟΓΙΣΤΩΝ I

Υ- 01 Αρχιτεκτονική Υπολογιστών Υπερβαθμωτοι επεξεργαστές

ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ ΣΧΟΛΗ ΗΛΕΚΤΡΟΛΟΓΩΝ ΜΗΧΑΝΙΚΩΝ ΚΑΙ ΜΗΧΑΝΙΚΩΝ ΥΠΟΛΟΓΙΣΤΩΝ ΤΟΜΕΑΣ ΤΕΧΝΟΛΟΓΙΑΣ ΠΛΗΡΟΦΟΡΙΚΗΣ ΚΑΙ ΥΠΟΛΟΓΙΣΤΩΝ

ΠΛΕ- 074 Αρχιτεκτονική Υπολογιστών 2

και η µονάδα ελέγχου (control) O επεξεργαστής: Η δίοδος δεδοµένων (datapath) Εντολές διακλάδωσης (branch beq, bne) I Type Σχεδίαση datapath

Επανάληψη Σύστημα Διασωλήνωσης (Pipelining) Κεφάλαιο 4 - Σύστημα ιασωλήνωσης

Instruction Execution Times

O επεξεργαστής: Η δίοδος δεδομένων (datapath) και η μονάδα ελέγχου (control)

ΠΛΕ- 027 Μικροεπεξεργαστές 8ο μάθημα: Παραλληλία επιπέδου εντολής

(Branch Prediction Mechanisms)

Εντολές Διακλάδωσης. #bubbles ~= pipeline depth X loop length. Next fetch started. Fetch. I-cache. Fetch Buffer. Decode. Issue Buffer.

ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ ΣΧΟΛΗ ΗΛΕΚΤΡΟΛΟΓΩΝ ΜΗΧΑΝΙΚΩΝ ΚΑΙ ΜΗΧΑΝΙΚΩΝ ΥΠΟΛΟΓΙΣΤΩΝ ΤΟΜΕΑΣ ΤΕΧΝΟΛΟΓΙΑΣ ΠΛΗΡΟΦΟΡΙΚΗΣ ΚΑΙ ΥΠΟΛΟΓΙΣΤΩΝ

ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ ΣΧΟΛΗ ΗΛΕΚΤΡΟΛΟΓΩΝ ΜΗΧΑΝΙΚΩΝ ΚΑΙ ΜΗΧΑΝΙΚΩΝ ΥΠΟΛΟΓΙΣΤΩΝ ΤΟΜΕΑΣ ΤΕΧΝΟΛΟΓΙΑΣ ΠΛΗΡΟΦΟΡΙΚΗΣ ΚΑΙ ΥΠΟΛΟΓΙΣΤΩΝ

Τέτοιες λειτουργίες γίνονται διαμέσου του

Εισαγωγή. Σύνοψη βασικών εννοιών, 5-stage pipeline, επεκτάσεις για λειτουργίες πολλαπλών κύκλων

Δσναμική Δρομολόγηζη Ενηολών (Dynamic Scheduling)

ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΙΑΣ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΔΕΥΤΕΡΗ ΠΡΟΟΔΟΣ ΣΤΗΝ ΟΡΓΑΝΩΣΗ ΣΤΟΥΣ Η/Y (ΗΥ232)

Μέθοδοι Πρόβλεψης Διακλαδώσεων (Branch Prediction Mechanisms)

Συστήματα Διαχείρισης Βάσεων Δεδομένων

O επεξεργαστής: Η δίοδος δεδομένων (datapath) και η μονάδα ελέγχου (control)

ΠΛΕ- 074 Αρχιτεκτονική Υπολογιστών 2

Υπερβαθμωτή (superscalar) Οργάνωση Υπολογιστών

Διάλεξη 12 Καθυστερήσεις (Stalls) Εκκενώσεις Εντολών (Flushing)

The Simply Typed Lambda Calculus

Chapter 6 Αύξηση της απόδοσης με διοχέτευση (pipeline)

ΕΠΛ221: Οργάνωση Υπολογιστών και Συμβολικός Προγραμματισμός Κεφ. 4: O επεξεργαστής Σύστημα Διασωλήνωσης (Pipelining)

ΗΥ 232 Οργάνωση και Σχεδίαση Υπολογιστών. Διάλεξη 13. Διακλαδώσεις. Νίκος Μπέλλας Τμήμα Ηλεκτρολόγων Μηχανικών και Μηχανικών Η/Υ

ΗΥ425 Αρχιτεκτονική Υπολογιστών. Branch Prediction. Ιάκωβος Μαυροειδής

Pipeline: Ένα παράδειγμα από.τη καθημερινή ζωή. 30 min κάθε «φάση»

Διάλεξη 12 Καθυστερήσεις (Stalls)

Περιορισμοί των βαθμωτών αρχιτεκτονικών

Single Cycle Datapath. Αρχιτεκτονική Υπολογιστών. 5ο εξάμηνο ΣΗΜΜΥ ακ. έτος: Νεκ. Κοζύρης

Αρχιτεκτονική υπολογιστών

ΠΛΕ- 074 Αρχιτεκτονική Υπολογιστών 2

Ενσωµατωµένα Υπολογιστικά Συστήµατα (Embedded Computer Systems)

Παραλληλισμός σε επίπεδο εντολών

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Αρχιτεκτονική Υπολογιστών

ΗΥ425 Αρχιτεκτονική Υπολογιστών. Branch Prediction. Βασίλης Παπαευσταθίου Ιάκωβος Μαυροειδής

Τελική Εξέταση, Απαντήσεις/Λύσεις

Application Operating System. Datapath & Control/Memory. Digital Design Circuit Design. Layout

EE512: Error Control Coding

Υπερβαθµωτή Οργάνωση Υπολογιστών

CS425 Computer Systems Architecture

30 min κάθε «φάση» Pipeline: Ένα παράδειγµα από.τη καθηµερινή ζωή. 1. Πλυντήριο. 2. Στεγνωτήριο. 3. ίπλωµα. 4. αποθήκευση. προσέγγιση για 4.

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Υπερβαθµωτή Οργάνωση Υπολογιστών

Συστήματα σε Ολοκληρωμένα Κυκλώματα

ΠΛΕ- 027 Μικροεπεξεργαστές 6ο μάθημα: Αρχιτεκτονική πυρήνα: υλοποίηση με διοχέτευση

Υποθεηική Εκηέλεζη Ενηολών (Hardware-Based Speculation)

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Multi Cycle Datapath. Αρχιτεκτονική Υπολογιστών. 5ο εξάμηνο ΣΗΜΜΥ ακ. έτος: Νεκ. Κοζύρης

Pipeline: Ένα παράδειγµα από.τη καθηµερινή ζωή. 30 min κάθε «φάση»

Assalamu `alaikum wr. wb.

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

Pipelined Datapath, Hazards and Forwarding

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Κεντρική Μονάδα Επεξεργασίας. Επανάληψη: Απόδοση ΚΜΕ. ΚΜΕ ενός κύκλου (single-cycle) Παραλληλισμός σε επίπεδο εντολών. Υπολογιστικό σύστημα

Section 8.3 Trigonometric Equations

Εικονική Μνήμη (virtual memory)

the total number of electrons passing through the lamp.

1.1 ΑΣΚΗΣΗ ΛΥΣΗ 2.1 ΑΣΚΗΣΗ ΛΥΣΗ 3.1 ΑΣΚΗΣΗ

ΕΠΛ221: Οργάνωση Υπολογιστών και Συμβολικός Προγραμματισμός. Εργαστήριο Αρ. 2

Υπερβαθμωτή (superscalar) Οργάνωση Υπολογιστών

Προηγμένοι Μικροεπεξεργαστές. Φροντιστήριο 4 Real Mode Interrupts

Instruction-Level Parallelism and its Dynamic Exploitation. Κεφάλαια 4o Computer Architecture-A Quantitative Approach 3 rd Edition

ΠΛΕ- 027 Μικροεπεξεργαστές 7ο μάθημα: Αρχιτεκτονική πυρήνα: Πρόβλεψη διακλάδωσης, Εξαιρέσεις

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

derivation of the Laplacian from rectangular to spherical coordinates

ΔΙΑΛΕΞΗ 17: Δυναμικός Παραλληλισμός Εντολών -- Superscalar Επεξεργαστές --

Αρχιτεκτονική Υπολογιστών

Υ- 01 Αρχιτεκτονική Υπολογιστών Υπόβαθρο: Διοχέτευση

ΗΥ 232 Οργάνωση και Σχεδίαση Υπολογιστών. Διάλεξη 13. Εξαιρέσεις και Διακοπές (Exceptions and Interrupts)

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

Modbus basic setup notes for IO-Link AL1xxx Master Block

Υλοποίηση Mικροεπεξεργαστή MIPS -16

Matrices and Determinants

Κάθε functional unit χρησιμοποιείται μια φορά σε κάθε κύκλο: ανάγκη για πολλαπλό hardware = κόστος υλοποίησης!

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

Approximation of distance between locations on earth given by latitude and longitude

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

The challenges of non-stable predicates

ΕΠΛ221: Οργάνωση Υπολογιστών και Συμβολικός Προγραμματισμός. Κεφ. 4: Ο επεξεργαστής 1. Διάδρομος δεδομένων και μονάδα ελέγχου 2.

Αρχιτεκτονική Υπολογιστών

Διάλεξη 11 Προώθηση (Forwarding)

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχανικών - Μηχανικών Υπολογιστών. Αρχιτεκτονική Υπολογιστών Νεκτάριος Κοζύρης.

Homework 3 Solutions

Finite Field Problems: Solutions

(C) 2010 Pearson Education, Inc. All rights reserved.

Transcript:

ΗΥ425 Αρχιτεκτονική Υπολογιστών Precise Exceptions Speculation Reorder Buffer Βασίλης Παπαευσταθίου Ιάκωβος Μαυροειδής

Αρχιτεκτονική Scoreboard (CDC 6600) Registers FP Mult FP Mult FP Divide FP Add Integer Functional Units SCOREBOARD 2

Tomasulo Organization 3

Tomasulo v. Scoreboard (IBM 360/91 v. CDC 6600) Pipelined Functional Units Multiple Functional Units (6 load, 3 store, 3 +, 2 x/ ) (1 load/store, 1 +, 2 x, 1 ) window size: 14 instructions 5 instructions o issue on structural hazard same WAR: renaming avoids stall completion WAW: renaming avoids stall issue Broadcast results from FU Write/read registers Control: reservation stations central scoreboard 4

Exception Behavior with ROB CPI = CPI ideal + Stalls structural + Stalls RAW + Stalls WAR + Stalls WAW + Stalls control Προσοχή να διατηρουνται 1. Data flow 2. Exception Behavior Έχουµε µελετήσει θα µελετήσουµε σηµερα Θα µελετήσουµε σε επόµενα µαθήµατα Δυναµικές δροµολόγηση εντολών (hardware) Scoreboard (ελάττωση RAW stalls) Register Renaming α)tomasulo (ελάττωση WAR και WAW stalls) β)reorder Buffer Branch prediction (ελάττωση Control stalls) Multiple Issue (CPI < 1) Multithreading (CPI < 1) Στατικές (shoftware/compiler) Loop Unrolling Software Pipelining Trace Scheduling 5

Device Interrupt etwork Interrupt add r1,r2,r3 subi r4,r1,#4 slli r4,r4,#2 lw lw add sw Hiccup(!) r2,0(r4) r3,4(r4) r2,r2,r3 8(r4),r2 Raise priority Disable All Ints Save registers lw r1,20(r0) lw r2,0(r1) addi r3,r0,#5 sw 0(r1),r3 Restore registers Clear current Int Reenable All Ints Restore priority RTE Or Could be interrupted by disk ote that priority must be raised to avoid recursive interrupts! 6

Types of Interrupts/Exceptions I/O device request Invoking an operating system service from a user program Breakpoint (programmer-requested interrupt) Integer arithmetic overflow FP arithmetic anomaly Page fault (not in main memory) Misaligned memory accesses (if alignment is required) protection violation Using an undefined or unimplemented instruction Hardware malfunctions Power failure 7

Precise Interrupts/Exceptions Ένα interrupt ή exception ονομάζεται precise εάν υπάρχει μία εντολή (ή interrupt point) για το οποίο: Όλες οι προηγούμενες εντολές έχουν πλήρως εκτελεστεί. Καμία εντολή μετά (μαζί με την interrupting instruction) δεν έχει αλλάξει την κατάσταση της μηχανής. Αυτό σημαίνει ότι μπορείς να επανακινήσεις την εκτέλεση από το interrupt point και να πάρεις τα σωστά αποτελέσματα Στο παράδειγμά μας: Interrupt point είναι η lw εντολή External Interrupt add subi slli lw lw add sw r1,r2,r3 r4,r1,#4 r4,r4,#2 r2,0(r4) r3,4(r4) r2,r2,r3 8(r4),r2 Int handler 8

Imprecise Interrupt/Exception An exception is imprecise if the processor state when an exception is raised does not look exactly as if the instructions were executed sequentially in strict program order Occurrence in two possibilities: The pipeline may have already completed instructions that are later in program order The pipeline may have not yet completed some instructions that are earlier in program order 9

Precise interrupt point απαιτεί πολλάπλα PCs όταν υπάρχουν delayed branches PC: PC+4: addi r4,r3,#4 sub r1,r2,r3 bne r1,there and r2,r3,r5 <other insts> Interrupt point described as <PC,PC+4> PC: PC+4: addi r4,r3,#4 sub r1,r2,r3 bne r1,there and r2,r3,r5 <other insts> Interrupt point described as: <PC+4,there> (branch was taken) or <PC+4,PC+8> (branch was not taken) 10

Γιατί χρειαζόμαστε τα precise interrupts? Αρκετά interrupts/exceptions χρειάζονται να είναι restartable I.e. TLB faults. Πρέπει να διορθώσει translation, και μετά restart load/store IEEE gradual underflow, illegal operation, etc: f ( x) = sin( x) e.g. Για παράδειγμα : Για x 0 x 0 f ( 0) = Þ a + illegal _ operation 0 Want to take exception, replace a with 1, then restart. Restartability δεν απαιτεί preciseness. Ωστόσο, με preciseness είναι πολύ πιο εύκολη η επανεκίνηση. Απλοποίει το λειτουργικό σύστημα πολύ Less state needs to be saved away if unloading process. Quick to restart (making for fast interrupts) 11

Precise Exceptions στην απλή 5-stage pipeline: Exceptions μπορούν να συμβούν σε διαφορετικά stages της pipeline (I.e. out of order): Arithmetic exceptions occur in execution stage TLB faults can occur in instruction fetch or memory stage How we guarantee precise exceptions? Η λύση είναι να μαρκάρεις την εντολή ως δημιουργεί exception ή όχι και περίμενε μέχρι το τέλος της MEM stage για να σηκώσεις το exception Interrupts become marked OPs (like bubbles) that are placed into pipeline instead of an instruction. Assume that interrupt condition persists in case OP flushed Clever instruction fetch might start fetching instructions from interrupt vector, but this is complicated by need for supervisor mode switch, saving of one or more PCs, etc 12

Another look at the exception problem Time Data TLB IFetch Dcd Exec Mem WB Bad Inst Inst TLB fault Overflow Program Flow IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB Χρήση της pipeline! Κάθε εντολή έχει ένα exception status. Καταγραφή PCs για κάθε εντολή στην pipeline. Έλεξε exception όταν η εντολή φτάσει το WB stage Όταν η εντολή φτάσει το WB stage και έχει exception: Σώσε PC Þ EPC, Interrupt vector addr Þ PC Μετάτρεψε όλες τις επόμενες εντολές που έχουν γίνει fetched σε OPs! Δουλεύει επειδή γίνεται in-order-completion/wb 13

Tomasulo Example Cycle 57 Instruction status: Exec Write Instruction j k Issue Comp Result Busy Address LD F6 34+ R2 1 3 4 Load1 o LD F2 45+ R3 2 4 5 Load2 o MULTD F0 F2 F4 3 15 16 Load3 o SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 56 57 ADDD F6 F8 F2 6 10 11 Reservation Stations: S1 S2 RS RS Time ame Busy Op Vj Vk Qj Qk Add1 o Add2 o Add3 o Mult1 o Mult2 Yes DIVD M*F4 M(A1) Register result status: Clock F0 F2 F4 F6 F8 F10 F12... F30 56 FU M*F4 M(A2) (M-M+M(M-M) Result In-order issue, out-of-order execution and completion. 14

Scoreboard (out-of-order compl) Instruction status: Read Exec Write Exec Write Instruction j k Issue Oper Comp Result Issue ComplResult LD F6 34+ R2 1 2 3 4 1 3 4 LD F2 45+ R3 5 6 7 8 2 4 5 MULTD F0 F2 F4 6 9 19 20 3 15 16 SUBD F8 F6 F2 7 9 11 12 4 7 8 DIVD F10 F0 F6 8 21 61 62 5 56 57 ADDD F6 F8 F2 13 14 16 22 6 10 11 15

Πρόβλημα: Fetch unit Instruction Fetch με Branch Prediction Εντολές προς εκτέλεση Out-Of-Order Execution Unit Επιστροφή στο σωστό path όταν βγει το αποτέλεσμα του branch Εντολές στο λανθασμένο predicted path έχουν ήδη εκτελεστεί. Instruction fetch decoupled from execution 16

Branch πρέπει να εκτελεστεί γρήγορα για loop overlap! Στο loop-unrolling παράδειγμα, στηριχθήκαμε ότι τα branches εκτελούνται από μια γρήγορη integer unit για να πετύχουμε overlap! Loop: LD F0 0 R1 MULTD F4 F0 F2 SD F4 0 R1 SUBI R1 R1 #8 BEZ R1 Loop Τι συμβαίνει αν το branch εξαρτάται από το αποτέλεσμα του multd?? Χάνουμε τελείως όλα τα πλεονεκτήματα! Πρέπει να μπορούμε να μαντεύουμε predict το αποτέλεσμα του branch. Αν μαντεύαμε ότι το branch είναι συνέχεια taken, θα είμασταν σωστοί τις περισσότερες φορές. 17

Prediction: Branches, Dependencies, Data Η πρόβλεψη είναι απαραίτητη για καλή απόδοση. Mελετήσaμε πώς προβλέπονται branches στο προηγούμενο μαθήματα. Μοντέρνες αρχιτεκτονικές τώρα προβλέπουν τα πάντα : data dependencies, actual data, and results of groups of instructions: Γιατί δουλεύει η πρόβλεψη? Underlying algorithm has regularities. Data that is being operated on has regularities. Instruction sequence has redundancies that are artifacts of way that humans/compilers think about problems. 18

Πρόβλημα: out-of-order completion Scoreboard και Tomasulo έχουν: In-order issue, out-of-order execution, out-of-order completion Τρόπος να συγχρονίσεις το completion στάδιο των εντολών με την σειρά στο πρόγραμμα (i.e. with issueorder) Easiest way is with in-order completion (i.e. reorder buffer) Other Techniques (Smith paper): Future File, History Buffer 19

Σχέση μεταξύ Precise Interrupts και Speculation: Στο Ιssue στάδιο εντολών είναι σαν να προβλέπεις ότι οι προηγούμενες εντολές δεν έχουν exception. Branch prediction, data prediction 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! Τεχνική για precise interrupts/exceptions και speculation: in-order completion or commit Γι αυτό συναντάμε reorder buffers σε όλους τους καινούριους επεξεργαστές 20

Υποστήριξη precise interrupts από HW Ιδέα του Reorder Buffer (ROB): Κράτα εντολές σε μία FIFO, ακριβώς με την σειρά που γίνονται issue.» Each ROB entry contains PC, dest reg/mem, result, exception status Όταν η εντολή τελείωσει την εκτέλεση, τοποθέτησε τα αποτελέσματα στον ROB.» Supplies operands to other instruction between execution complete & commit Þ more registers like RS» Tag results with ROB buffer number instead of reservation station Η εντολή αλλάζει την κατάσταση της μηχανης στο commit στάδιο όχι στο WB Þ in order commit Þ values at head of ROB placed in registers Σαν αποτέλεσμα είναι έυκολο να αναιρέσεις speculated instructions σε mispredicted branches ή σε exceptions FP Op Queue Commit path Reorder Buffer FP Regs Res Stations FP Adder Res Stations FP Adder 21

HW με reorder buffer (ROB)? Reg Result Instr. Type Exceptions? Ready Program Counter FP Op Queue Compare network Reorder Buffer FP Regs Reorder Table Res Stations FP Adder Res Stations FP Adder Πώς βρίσκουμε την τελευταία έκδοση του register? Πολύπορτο ROB σαν να είναι register file Integrate store buffer into ROB since in order commit. Stores use Result field for ROB tag until data ready on CDB. Can we also integrate the reservation stations? 22

Tomasulo with Reorder Buffer: Basic Block Diagram 23

Τέσσερα Στάδια του Tomasulo Αλγόριθμου με ROB 1. Issue Πάρε εντολή από FP Op Queue Αν υπάρχουν ελεύθερα reservation station και reorder buffer slot, issue instr & send operands & reorder buffer no. for destination (this stage sometimes called dispatch ) 2. Execution Εκτέλεσε εντολή στο Ex Unit(EX) Όταν και οι τιμές και των 2 source regs είναι έτοιμες εκτέλεσε εντολή; άν όχι, watch CDB for result; when both in reservation station, execute; checks RAW (sometimes called issue ) 3. Write result Τέλος εκτέλεσης (WB) Write on Common Data Bus to all awaiting FUs & reorder buffer; mark reservation station available. 4. Commit Άλλαξε τιμή του dest register με το αποτέλεσμα από το reorder buffer 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 or exception flushes reorder buffer. (sometimes called graduation ) 24

Tomasulo With Reorder buffer FP Op Queue Reorder Buffer Commit pntr. Value Instr. Type Ready F0 L.D F0,10(R2) ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest shows #ROB Registers To ROB1 from FP adders Reservation Stations FP multipliers 1 10+R2 25

FP Op Queue Reorder buffer (after 2 cycles) Reorder Buffer Commit pntr. Value F2 F10 F0 Instr. Type DIV.D F2,F10,F6 ADD.D F10,F4,F0 L.D F0,10(R2) Ready ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest 2 means ROB2 Registers 2 ADDD R(F4),ROB1 FP adders Reservation Stations 3 DIVD ROB2,R(F6) FP multipliers To from 1 10+R2 26

FP Op Queue Reorder buffer (after 3 cycles) Reorder Buffer Commit pntr. Value F0 ADD.D F0,F4,F6 F4 L.D F4,0(R3) -- BE F2,< > F2 F10 F0 Instr. Type DIV.D F2,F10,F6 ADD.D F10,F4,F0 L.D F0,10(R2) Ready ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest Registers 2 ADDD R(F4),ROB1 6 ADDD ROB5, R(F6) FP adders Reservation Stations 3 DIVD ROB2,R(F6) FP multipliers To from 1 10+R2 5 0+R3 27

FP Op Queue Reorder buffer (after 1 cycle) Reorder Buffer Commit pntr. Value Instr. Type Ready R3 F0 ROB5 S.D 0(R3),F4 ADD.D F0,F4,F6 F4 L.D F4,0(R3) -- BE F2,< > F2 F10 F0 DIV.D F2,F10,F6 ADD.D F10,F4,F0 L.D F0,10(R2) ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest Registers 2 ADDD R(F4),ROB1 6 ADDD ROB5, R(F6) FP adders Reservation Stations 3 DIVD ROB2,R(F6) FP multipliers To from 1 10+R2 5 0+R3 28

FP Op Queue Tomasulo With Reorder buffer Reorder Buffer Commit pntr. Value Instr. Type Ready R3 F0 M[Α1] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex F4 M[Α1] L.D F4,0(R3) Y -- BE F2,< > F2 F10 F0 DIV.D F2,F10,F6 ADD.D F10,F4,F0 L.D F0,10(R2) ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest Registers 2 ADDD R(F4),ROB1 FP adders Reservation Stations 3 DIVD ROB2,R(F6) FP multipliers To from 1 10+R2 29

FP Op Queue Tomasulo With Reorder buffer Reorder Buffer Commit pntr. Value Instr. Type Ready R3 F0 M[Α1] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex F4 M[Α1] L.D F4,0(R3) Y -- BE F2,< > F2 F10 F0 Μ(Α2) DIV.D F2,F10,F6 ADD.D F10,F4,F0 L.D F0,10(R2) Υ ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest Registers 2 ADDD R(F4),Μ(Α2) FP adders Reservation Stations 3 DIVD ROB2,R(F6) FP multipliers To from 30

FP Op Queue Tomasulo With Reorder buffer Reorder Buffer Commit pntr. Value Instr. Type Ready R3 F0 M[Α1] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex F4 M[Α1] L.D F4,0(R3) Y -- BE F2,< > F2 F10 DIV.D F2,F10,F6 ADD.D F10,F4,F0 ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest Registers 2 ADDD R(F4),Μ(Α2) FP adders Reservation Stations Μ(Α2) 3 DIVD ROB2,R(F6) FP multipliers To from 31

Tomasulo With Reorder buffer. Value Instr. Type Ready FP Op Queue Commit pntr R3 F0 M[Α1] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex ROB7 ROB6 ewest ROB5 Reorder Buffer ROB4 ROB3 ROB2 ROB1 Oldest Registers To from FP adders Reservation Stations FP multipliers 32

Reorder buffer : Precise Exceptions FP Op Queue Reorder Buffer Many Exceptions??? Registers 2 ADDD R(F4),ROB1 FP adders Reservation Stations. Value -- F0 M[10] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex F4 M[10] L.D F4,0(R3) Y -- BE F2,< > F2 DIV.D F2,F10,F6 Ex F10 ADD.D F10,F4,F0 Y F0 L.D F0,10(R2) Y 3 DIVD ROB2,R(F6) FP multipliers Instr. Type Ready To from 1 10+R2 ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest 33

Reorder buffer: Branch Misprediction FP Op Queue Reorder Buffer 2 ADDD R(F4),Μ(Α2) FP adders Commit pntr Branch misprediction?? Registers Reservation Stations. Value R3 F0 M[Α1] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex F4 M[Α1] L.D F4,0(R3) -- BE F2,< > Y F2 F10 DIV.D F2,F10,F6 ADD.D F10,F4,F0 Μ(Α2) 3 DIVD ROB2,R(F6) FP multipliers Instr. Type To Ready from ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest 34

Reorder buffer: Branch Misprediction FP Op Queue Reorder Buffer 2 ADDD R(F4),Μ(Α2) FP adders Commit pntr Branch misprediction Flush ROB=> Exception gone Registers Reservation Stations. Value -- BE F2,< > Y F2 DIV.D F2,F10,F6 F10 ADD.D F10,F4,F0 Μ(Α2) 3 DIVD ROB2,R(F6) FP multipliers Instr. Type To Ready from ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest 35

FP Op Queue Tomasulo With Reorder buffer Reorder Buffer What about memory hazards??? Registers 2 ADDD R(F4),ROB1 FP adders Reservation Stations. Value -- F0 M[10] <val2> S.D 0(R3),F4 ADD.D F0,F4,F6 Y Ex F4 M[10] L.D F4,0(R3) Y -- BE F2,< > F2 DIV.D F2,F10,F6 F10 ADD.D F10,F4,F0 F0 L.D F0,10(R2) 3 DIVD ROB2,R(F6) FP multipliers Instr. Type Ready To from 1 10+R2 ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest 36

Disambiguation: WAW/WAR Hazards στη μνήμη Like Hazards in Register File, we must avoid hazards through memory: WAW and WAR hazards through memory are eliminated with speculation because the actual updating of memory occurs in order, when a store is at the head of the ROB, and hence, no earlier loads or stores can still be pending. 37

Disambiguation: Λύση στα RAW Hazards στη μνήμη Ερώτηση: Given a load that follows a store in program order, are the two related? (υπάρχει ένα RAW hazard ανάμεσα στο store και στο load)? Eg: st 0(R2),R5 ld R6,0(R3) Μπορούμε να προχωρήσουμε και να αρχίσουμε το load? Store address could be delayed for a long time by some calculation that leads to R2 (divide?). We might want to issue/begin execution of both operations in same cycle. Solution1: Answer is that we are not allowed to start load until we know that address 0(R2) ¹ 0(R3) Solution2: We might guess at whether or not they are dependent (called dependence speculation ) and use reorder buffer to fixup if we are wrong. 38

Hardware υποστήριξη για Disambiguation Store buffer που κρατάει όλα τα εκκρεμή stores στη memory, σε program order. Keep track of address (when becomes available) and value (when becomes available) FIFO ordering: will retire stores from this buffer in program order Όταν κάνεις issue ένα load, κατέγραψε το head του buffer (γνώριζε ποια stores προηγούνται από εσένα). Όταν έχεις την διεύθυνση του load, έλεγξε τον buffer: If any store prior to load is waiting for its address, stall load. If load address matches earlier store address (associative lookup), then we have a memory-induced RAW hazard:» store value available Þ return value» store value not available Þ return ROB number of source Otherwise, send out request to memory Τα stores περνάνε το commit στάδιο in order, άρα δεν υπάρχουν WAW hazards στη μνήμη. 39

FP Op Queue Reorder Buffer address in ROB Disambiguation Done? F4 ROB3 L.D F4, 10(R3) 10+R3 ROB2 S.D 10(R3), F5 F5 L.D F5,32(R2) R3 R[F4] S.D 0(R3), F4 Y ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 ewest Oldest Registers To from FP adders Reservation Stations FP multipliers 2 32+R2 40

Register Renaming WAW WAR register renaming What happens with branches? Tomasulo can handle renaming across branches 41

Explicit register renaming Hardware equivalent of static, single-assignment (SSA) compiler form F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 P0 P2 P4 P6 P8 P10 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 Current Map Table Done? ewest P32 P34 P36 P38 P60 P62 Freelist Oldest Physical register file μεγαλύτερα από ISA register file (π.χ. 32 phys regs και 16 ISA regs) Στο issue, κάθε εντολή που αλλάζει έναν register παίρνει έναν καινούριο physical register από την freelist Used on: R10000, Alpha 21264, HP PA8000 42

Explicit register renaming Hardware equivalent of static, single-assignment (SSA) compiler form F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 P32 P2 P4 P6 P8 P10 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 Current Map Table Done? ewest P34 P36 P38 P40 P60 P62 Freelist F0 P0 LD P32,10(R2) Oldest ote 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 Issue LD F0,10(R2 43

Explicit register renaming Hardware equivalent of static, single-assignment (SSA) compiler form F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 P32 P2 P4 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 Current Map Table Done? ewest P36 P38 P40 P42 P60 P62 Freelist F10P10 F0 P0 ADDD P34,P4,P32 LD P32,10(R2) Oldest Issue ADD F10,F4, F0 44

Explicit register renaming Hardware equivalent of static, single-assignment (SSA) compiler form F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 P32 P36 P4 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 Done? Current Map Table -- P38 P40 P42 P44 P60 P62 Freelist -F2 P2 F10 P10 F0 P0 ewest BE P36,< > DIVD P36,P34,P6 ADDD P34,P4,P32 LD P32,10(R2) Oldest P32 P36 P4 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 P38 P40 P44 P48 P60 P62 Checkpoint at BE instruction 45

Explicit register renaming Hardware equivalent of static, single-assignment (SSA) compiler form F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 P40 P36 P38 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 Current Map Table P42 P44 P48 P50 P0 P10 Freelist -F0 P32 F4 P4 -F2 P2 F10 P10 F0 P0 Done? ST 0(R3),P40 Y ewest ADDD P40,P38,P6 Y LD P38,0(R3) Y BE P36,< > DIVD P36,P34,P6 ADDD P34,P4,P32 y Oldest LD P32,10(R2) y P32 P36 P4 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 P38 P40 P44 P48 P60 P62 Checkpoint at BE instruction 46

Explicit register renaming Hardware equivalent of static, single-assignment (SSA) compiler form F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 P32 P36 P4 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 Current Map Table Done? ewest P38 P40 P44 P48 P0 P10 Freelist F2 P2 F10P10 F0 P0 DIVD P36,P34,P6 ADDD P34,P4,P32 LD P32,10(R2) y y Oldest Speculation error fixed by restoring map table and freelist P32 P36 P4 P6 P8 P34 P12 P14 P16 P18 P20 P22 P24 P26 P28 P30 P38 P40 P44 P48 P60 P62 Checkpoint at BE instruction 47