CS425 Computer Systems Architecture

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

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

(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. Ιάκωβος Μαυροειδής

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

Instruction Execution Times

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

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

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

CS-425 Mid-term exam

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

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

The Simply Typed Lambda Calculus

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

Homework 3 Solutions

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

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

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

Section 8.3 Trigonometric Equations

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

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

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

EE512: Error Control Coding

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

Matrices and Determinants

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

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

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

Concrete Mathematics Exercises from 30 September 2016

CS425 Computer Systems Architecture

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

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

2 Composition. Invertible Mappings

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

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

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

derivation of the Laplacian from rectangular to spherical coordinates

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

Finite Field Problems: Solutions

6.3 Forecasting ARMA processes

Example Sheet 3 Solutions

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

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

Other Test Constructions: Likelihood Ratio & Bayes Tests

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

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

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

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

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

Section 9.2 Polar Equations and Graphs

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

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

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

Block Ciphers Modes. Ramki Thurimella

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

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

Second Order Partial Differential Equations

Problem Set 3: Solutions

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

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

Modbus basic setup notes for IO-Link AL1xxx Master Block

PARTIAL NOTES for 6.1 Trigonometric Identities

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

C.S. 430 Assignment 6, Sample Solutions

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

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

Second Order RLC Filters

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

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

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

Srednicki Chapter 55

Math221: HW# 1 solutions

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

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

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

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

Math 6 SL Probability Distributions Practice Test Mark Scheme

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

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

Lecture 2. Soundness and completeness of propositional logic

Αναερόβια Φυσική Κατάσταση

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

Assalamu `alaikum wr. wb.

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

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

Congruence Classes of Invertible Matrices of Order 3 over F 2

Δίκτυα Επικοινωνιών ΙΙ: OSPF Configuration

Partial Trace and Partial Transpose

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

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

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 7η: Consumer Behavior Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

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

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

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

Transcript:

CS425 Computer Systems Architecture Fall 2017 Branch Prediction CS425 - Vassilis Papaefstathiou 1

Branch Prediction Πρόβλεψη είναι πλέον απαραίτητη για να έχουμε καλή απόδοση. Γιατί; MULT F0,F1,F2 DIVD F4,F0,F3 BNEZ F4,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. Θα μελετήσουμε τα παρακάτω θέματα: branch prediction, branch target address, cancel branch misprediction CS425 - Vassilis Papaefstathiou 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 CS425 - Vassilis Papaefstathiou 3

Static Branch Prediction Major limitation: misprediction rate for the integer programs is high CS425 - Vassilis Papaefstathiou 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. o How would this information be stored for later use? o Still some difference between best possible static prediction (using a run to predict itself) and weighted average over many different data sets CS425 - Vassilis Papaefstathiou 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] CS425 - Vassilis Papaefstathiou 6

ΒΗΤ: Πρόβλημα; 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 Πρόβλημα σε loop, 1-bit BHT προκαλεί 2 mispredictions first time through loop code, when it predicts exit instead of looping end of loop case, when it predicts looping instead of exit CS425 - Vassilis Papaefstathiou 7

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

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

Use of Branch History Table 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 Predictor 0 Predictor 1 Branch PC Predictor 7 CS425 - Vassilis Papaefstathiou 10

2-bit BHT Accuracy Mispredictions: Wrong guess for that branch Got branch history of wrong branch (aliasing) still high! CS425 - Vassilis Papaefstathiou 11

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

Correlating Predictors (Example 2) CS425 - Vassilis Papaefstathiou 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... BHT 2 Each slot is 2-bit counter CS425 - Vassilis Papaefstathiou 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 Συνολική μνήμη : o 2 k * 2 addr_size * n = 2 k+addr_size * n Trivial amount of additional HW addr_size Each slot is n-bit counter CS425 - Vassilis Papaefstathiou 15

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

Yeh and Patt s classification (ISCA 92) CS425 - Vassilis Papaefstathiou 17

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

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

Yeh and Patt s classification CS425 - Vassilis Papaefstathiou 20

Yeh and Patt s classification CS425 - Vassilis Papaefstathiou 21

Yeh and Patt s classification CS425 - Vassilis Papaefstathiou 22

Yeh and Patt s classification Per-set history predictors CS425 - Vassilis Papaefstathiou 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 not-taken CS425 - Vassilis Papaefstathiou 24

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

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

Indirect Jumps Indirect procedure calls, switch/case statements, gotos. Πλειοψηφία είναι procedure returns. Πρόβλημα accuracy low when procedure is called from multiple sites. Λύση small buffer of return addresses operating as a stack (Return Address 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 CS425 - Vassilis Papaefstathiou 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 Convert control dependence to data dependence Reduce branch pressure (reduce pred. table updates) Conditional Move (CMOV) is very common CS425 - Vassilis Papaefstathiou x A = B op C BNEZ R1,L ADDU R2,R3,R0 L: CMOVZ R2,R3,R1 28

Predicated Execution Drawbacks of conditional instructions Still takes a clock even if annulled Stall if condition evaluated late Complex conditions reduce effectiveness; condition becomes known late in pipeline CS425 - Vassilis Papaefstathiou 29

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 και τον αριθμό των λάθος προβλέψεων CS425 - Vassilis Papaefstathiou 30