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

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

CS425 Computer Systems Architecture

(Branch Prediction Mechanisms)

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

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

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

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

Instruction Execution Times

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

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

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

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

CS-425 Mid-term exam

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

Υ- 01 Αρχιτεκτονική Υπολογιστών Πρόβλεψη διακλάδωσης

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

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

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

The Simply Typed Lambda Calculus

Homework 3 Solutions

Section 8.3 Trigonometric Equations

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

EE512: Error Control Coding

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

Matrices and Determinants

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

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

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

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

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

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

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Concrete Mathematics Exercises from 30 September 2016

Δίκτυα Δακτυλίου. Token Ring - Polling

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

2 Composition. Invertible Mappings

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

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

6.3 Forecasting ARMA processes

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

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

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

Finite Field Problems: Solutions

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

derivation of the Laplacian from rectangular to spherical coordinates

Example Sheet 3 Solutions

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

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

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

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

Block Ciphers Modes. Ramki Thurimella

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Problem Set 3: Solutions

Modbus basic setup notes for IO-Link AL1xxx Master Block

Second Order Partial Differential Equations

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

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

CS425 Computer Systems Architecture

PARTIAL NOTES for 6.1 Trigonometric Identities

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

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

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

Every set of first-order formulas is equivalent to an independent set

Section 9.2 Polar Equations and Graphs

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

HY150a Φροντιστήριο 3 24/11/2017

Second Order RLC Filters

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

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

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

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Other Test Constructions: Likelihood Ratio & Bayes Tests

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Srednicki Chapter 55

Math221: HW# 1 solutions

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

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

C.S. 430 Assignment 6, Sample Solutions

Εισαγωγή στην πληροφορική -4

Math 6 SL Probability Distributions Practice Test Mark Scheme

CYTA Cloud Server Set Up Instructions

Elements of Information Theory

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

Μηχανική Μάθηση Hypothesis Testing

Assalamu `alaikum wr. wb.

Lecture 2. Soundness and completeness of propositional logic

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

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

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

Congruence Classes of Invertible Matrices of Order 3 over F 2

Partial Trace and Partial Transpose

Προχωρηµένα Θέµατα Αρχιτεκτονικής

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

Bayesian statistics. DS GA 1002 Probability and Statistics for Data Science.

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

5.4 The Poisson Distribution.

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Transcript:

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

Branch Prediction Πρόβλεψη είναι πλέον απαραίτητη για να έχουµε καλή απόδοση. Γιατί; MULT F0,F1,F2 DIVD F4,F0,F3 BNEZ F4,Loop (EQD F4, F0; BFPF LOOP;) Σηµαντική σε out-of-order ή multi-issue επεξεργαστές (Amdahl s Law) CPI = Ideal CPI + Structural stalls + RAW stalls + WAR stalls + WAW stalls + Control stalls The prediction is a hint that is assumed to be correct, and fetching begins in the predicted direction. If the hint turns out to be wrong, the executed (not committed) instructions from the wrong path are cancelled. 3 Θέµατα θα λύσουµε: branch prediction, branch target address, cancel branch misprediction (next lecture) 2

Πρόβλεψη αποτελέσµατος Γιατί δουλεύει η πρόβλεψη? 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. Loops are easy to predict their behaviour 3

Static Branch Prediction Major limitation : misprediction rate for the integer programs is high 4

Dynamic Branch Prediction Είναι η δυναµική πρόβλεψη καλύτερη από την στατική; Έτσι φαίνεται. Josh Fisher had good paper on Predicting Conditional Branch Directions from Previous Runs of a Program. ASPLOS 92. In general, good results if allowed to run program for lots of data sets. How would this information be stored for later use? Still some difference between best possible static prediction (using a run to predict itself) and weighted average over many different data sets 5

Simplest Dynamic Approach: Branch History Table Performance = ƒ(accuracy, cost of misprediction) Branch History Table: Lower bits of PC index 1-bit table Specifies if branch was taken or not the last time When branch delay is longer than time to compute target PC 1-bit table PC[3:0] 6

ΒΗΤ: Πρόβληµα ΠρόβληµαF σε loop, 1-bit BHT προκαλεί 2 mispredictions End of loop case, when it exits instead of looping as before First time through loop on next time through code, when it predicts exit instead of looping Loop: LD F0,0(R1);F0=vector element ADDD F4,F0,F2;add scalar from F2 SD 0(R1),F4;store result SUBI R1,R1,8 ;decrement pointer 8B (DW) BNEZ R1,Loop ;branch R1!=zero NOP ;delayed branch slot 7

2-bit Prediction scheme (Jim Smith, 1981) Λύση F 2-bit scheme αλλάζει πρόβλεψη µόνο αν γίνει λάθος πρόβλεψη 2 φορές: Κόκκινο: taken Μπλε: not taken Προσθέτει hysteresis στην πρόβλεψη Also known as saturation counter or bimodal predictor 8

n-bit Predictors n-bit scheme αλλάζει πρόβλεψη µόνο αν γίνει λάθος πρόβλεψη 2 n-1 φορές. Χρήση n-bit counter. Μελέτες των n-bit predictors έχουν δείξει ότι οι 2-bit predictors είναι πολύ αποδοτικοί: τα περισσότερα συστήµατα έχουν 2-bit predictors. 9

Use of Branch History Table Predictor 0 Predictor 1 Branch PC Predictor 7 BHT είναι ένας πίνακας από Predictors Usually 2-bit, saturating counters Indexed by PC address of Branch Στο ID stage του branch κάνουµε access τον πίνακα. Στο ID stage υπολογίζεται και η διεύθυνση του branch. (χρειαζόµαστε 1 delay slot) Όταν το branch ολοκληρώθει Update corresponding Predictor 10

2-bit BHT Accuracy Λάθος πρόβλεψη επειδή: Wrong guess for that branch Got branch history of wrong branch still high! 11

Correlating Predictors Υπόθεση : πρόσφατα branches συσχετίζονται. Tα αποτελέσµατα πρόσφατων branches επηρεάζουν την πρόβλεψη του τρέχον branch. Παράδειγµα 1 (από eqntott benchmark): If branches b1 and b2 are both not taken (i.e. first two if statements are true) then b3 will be taken 12

Correlating Predictors Παράδειγµα 2: 13

Example: (4,2) Predictor (4,2) GHT (Global History Table) predictor 4 means that we keep four bits of history 2 means that we have 2 bit counters in each slot. Then behavior of recent branches selects between, say, 16 predictions of next branch, updating just that prediction Note also that aliasing is possible here... 2 BHT Each slot is 2-bit counter 2-bit global branch history register 14

Correlating Branches (k,n) GHT predictor k means that we keep k-bits of history n means that we have n-bit counters in each slot. Note that the original two-bit counter solution would be a (0,2) GAp predictor Συνολική µνήµη : 2 k * 2 addr_size * n= 2 k+addr_size * n - Trivial amount of additional HW addr_size Each slot is n-bit counter 2-bit global branch history register 15

Yeh and Patt s classification 16

Yeh and Patt s classification First Level: τα k πιο πρόσφατα branches που εκτελέστηκαν οπουδήποτε Produces a GAy (for global address ) in the Yeh and Patt classification τα k πιο πρόσφατα αποτελέσµατα του ίδιου branch. Produces a PAy (for per address ) in same classification (e.g. PAg) 17

Yeh and Patt s classification Second Level: Single entry for any branch XAg Per branch history table XAp Per set history table XAs The set attribute of a branch can be determined by the branch opcode, branch class assigned by a compiler, or branch address. 18

Yeh and Patt s classification 19

Yeh and Patt s classification 20

Yeh and Patt s classification 21

Yeh and Patt s classification Per-set history predictors 22

Accuracy of Different Schemes Frequency of Mispredictions 18% % Frequency of Mispredictions 16 % 14 % 12 % 10 % 8% 6% 4% 2% 0% nasa7 1% 4096 Entries 2-bit BHT Unlimited Entries 2-bit BHT 1024 Entries (2,2) BHT matrix300 0% tomcatv 1% doducd 5% spice 6% 6% fpppp gcc 11% espresso 4% eqntott 6% li 5% 4,0 96 entries: 2-bits per entry Unlimited entries: 2-bits/entry 1,0 24 entries (2,2) 23

Branch Target Buffer Ένα look up table µε διευθύνσεις των predicted taken branches. Όταν κάνει match στέλνει το target PC του branch. Optimization: Store the predicted-taken branches only Branch PC LookUp Predicted PC PC of instruction FETCH =? Predict taken or untaken 24

Branch Target Buffer To Branch Target Buffer (BTB) γίνεται access στο IF stage: γλυτώνουµε 1 κύκλο. IF ID EX Send PC to memory Send Out predicted PC Update BTB and BTB. if entry found in BTB 25

Branch Folding Αποθήκευσε µία ή περισσότερες target instructions µαζί µε target address στο Branch Target Buffer (BTB). - Χρόνος πρόσβασης στον BTB µπορεί να µεγαλώσει. - Zero-cycle branches: Αντικατέστησε την branch εντολή µε την target instruction. 26

Indirect Jumps Indirect procedure calls, select ή case statemenet, gotos. Πλειοψηφία είναι procedure returns. Πρόβληµα F accuracy low when procedure is called from multiple sites. Λύση F small buffer of return addresses operating as a stack. This structure caches the most recent return addresses: pushing a return address on the stack at a call and popping one off at a return. In SPEC95 benchmarks, procedure returns account for more than 15% of the branches 27

Predicated Execution Απόφυγε branch prediction µετατρέποντας τα branches σε conditionally executed instructions: if (x) then A = B op C else NOP If false, then neither store result nor cause exception Expanded ISA of Alpha, MIPS, PowerPC, SPARC have conditional move; PA-RISC can annul any following instr. IA-64: 64 1-bit condition fields selected so conditional execution of any instruction x A = B op C Αρνητικά των conditional instructions Still takes a clock even if annulled Stall if condition evaluated late Complex conditions reduce effectiveness; condition becomes known late in pipeline BNEZ R1,L ADDU R2,R3,R0 L: CMOVZ R2,R3,R1 28

Dynamic Branch Prediction Η πρόβλεψη είναι ιδιάιτερα σηµαντική για την απόδοση του συστήµατος. Prediction is exploiting information compressibility in execution Branch History Table: 2 bits for loop accuracy Correlation: Recently executed branches correlated with next branch. Either different branches (GA) Or different executions of same branches (PA). Branch Target Buffer: include branch address & prediction Predicated Execution µπορούν να ελαττώσουν των αριθµό των branches, αριθµό των λάθος προβλέψεων. 29