Branch Prediction + Hyper-Threading

Total Page:16

File Type:pdf, Size:1020Kb

Branch Prediction + Hyper-Threading Computer Architectures Branch Prediction + Hyper-Threading Richard Šusta, Pavel Píša Czech Technical University in Prague, Faculty of Electrical Engineering AE0B36APO Computer Architectures Ver.3.50 2019 1 Control Hazards • Jump and Branch are great performance losses. • Jump instruction needs only the jump target address • Branch instruction requires 2 operations: • Branch Result Taken or Not Taken • Branch Target Address • PC + 4 If Branch is NOT Taken • PC + 4 + 4 × immediate If Branch is Taken AE0B36APO Computer Architectures 2 Branch Not Taken Branch to Z A B C D Z cycle b cycle b+1 cycle b+2 cycle b+3 cycle b+4 Branch fetched Branch decoded Branch decision PC keeps D (br. not taken) A fetched A decoded A executed A continues B fetched B decoded B executed C fetched C decoded D fetched AE0B36APO Computer Architectures 3 Branch Hazard • Consider heuristic – branch Not taken. • Continue fetching instructions in sequence following the branch instructions. • If branch is taken (indicated by zero output of ALU): • Control generates branch signal in ID cycle. • branch activates PCSource signal in the MEM cycle to load PC with new branch address. • Instructions in the pipeline must be flushed if branch is taken – can this penalty be reduced? AE0B36APO Computer Architectures 4 Branch Taken Branch to Z A B C D Z cycle b cycle b+1 cycle b+2 cycle b+3 cycle b+4 Branch fetched Branch decoded Branch decision PC gets Z (br. taken) A fetched A decoded A executed Nop B fetched B decoded Nop C fetched Nop Three instructions are Z fetched flushed if branch is taken AE0B36APO Computer Architectures 5 Pipeline Flush • If branch is taken (as indicated by zero), then control does the following: • Change all control signals to 0, similar to the case of stall for data hazard, i.e., insert bubble in the pipeline. • Generate a signal IF.Flush that changes the instruction in the pipeline register IF/ID to 0 (nop). • Penalty of branch hazard is reduced by • Adding branch detection and address generation hardware in the decode cycle – one bubble needed – a next address generation logic in the decode stage writes PC+4, branch address, or jump address into PC. • Using branch prediction. AE0B36APO Computer Architectures 6 Control Hazards • The result of the comparison is only known in the 4th cycle. Why? AE0B36APO Computer Architectures 7 Control Hazard – rather know the result earlier... • If we can determine the result of the comparison already in the 2nd cycle, we can reduce misprediction penalty. • Moving forward can introduce new RAW hazards !!! AE0B36APO Computer Architectures 8 Solution of Hazards by Flush RegWriteD RegWriteE RegWriteM RegWriteW Control unit MemToRegD MemToRegE MemToRegM MemWriteD MemWriteE MemWriteM MemTo ALUControlE 31:26 ALUControlD RegW Op ALUSrcD ALUSrcE 5:0 RegDstD RegDstE Funct BranchD EquaD PCSrcD = 0 PC´ PC InstrD 25:21 WE3 00 SrcAE WE A RD A1 RD1 01 ALUOutM ReadDataW 1 EN 10 20:16 A RD A2 RD2 00 SrcBE ALU Instruction 01 0 Data Memory A3 Reg. 10 1 Memory WriteDataE WriteDataM WD3 File WD 1 RsD ALUOutW 25:21 RsE 0 20:16 RtD RtE 0 WriteRegE 4:0 WriteRegM 4:0 WriteRegW 4:0 15:11 RdD RdE 1 15:0 SignImmD + Sign 4 Ext SignImmE <<2 + CLR PCPlus4F PCPlus4D CLR EN PCBranchD ResultW Forward Forward RegWrite Stall F Stall D AE BE RegWriteM FlushE W Hazard unit MemToRegE AE0B36APO Computer Architectures 9 1-Cycle Jump Delay • If the control logic detects a Jump instruction in the 2nd Stage, then Next instruction is fetched anyway. • We flush only with one instruction. cc1 cc2 cc3 cc4 cc5 cc6 cc7 J L1 IF ID Next instruction IF Bubble Bubble Bubble Bubble . Jump L1: Target instruction Target IF Reg ALU DM Reg Addr AE0B36APO Computer Architectures 10 Solution of RAW hazards by forwarding Přeposlat / Pozastavit Netřeba Pozastavit RegWriteD RegWriteE RegWriteM RegWriteW Control unit MemToRegD MemToRegE MemToRegM MemWriteD MemWriteE MemWriteM MemTo ALUControlE 31:26 ALUControlD RegW Op ALUSrcD ALUSrcE 5:0 RegDstD RegDstE Funct BranchD EquaD PCSrcD = 0 PC´ PC InstrD 25:21 WE3 0 00 SrcAE WE A RD A1 RD1 01 ALUOutM ReadDataW 1 EN 1 10 20:16 A RD A2 RD2 00 SrcBE ALU Instruction 01 0 Data Memory A3 Reg. 0 10 1 Memory 1 WriteDataE WriteDataM WD3 File WD 1 RsD ALUOutW 25:21 RsE 0 20:16 RtD RtE 0 WriteRegE 4:0 WriteRegM 4:0 WriteRegW 4:0 15:11 RdD RdE 1 15:0 SignImmD + Sign 4 Ext SignImmE <<2 + CLR PCPlus4F PCPlus4D CLR EN PCBranchD ResultW Forward Forward Forward RegWrite Stall F Stall D BranchD AE BE RegWriteM BD FlushE W ForwardAD RegWriteE Hazard unit MemToRegE AE0B36APO Computer Architectures 11 Pipeline version RegWriteD RegWriteE RegWriteM RegWriteW Contr ol unit MemToRegD MemToRegE MemToRegM MemWriteD MemWriteE MemWriteM MemTo 31:26 ALUControlD ALUControlE RegW Op ALUSrcD ALUSrcE 5:0 RegDstD RegDstE Funct BranchD EquaD = PCSrcD 0 PC´ PC InstrD 25:21 WE3 0 00 SrcAE WE A RD A1 RD1 01 ALUOutM ReadDataW 1 EN 1 10 A RD 20:16 00 SrcBE Instruction A2 RD2 01 0 ALU Data Memory A3 0 10 1 Memory Reg. WriteDataM WD3 1 WriteDataE W 1 25:21 File RsD RsE ALUOutW 20:16 RtD RtE D 0 0 WriteRegE 4:0 WriteRegM 4:0 WriteRegW 4:0 15:11 RdD RdE 1 + 15:0 SignImmD 4 Sign SignImmE Ext <<2 + PCPlus4F PCPlus4D CLR EN PCBranchD ResultW Forward Forward Forward RegWrit Stall F Stall D BranchD AE BE RegWrite BD FlushE M e ForwardAD Hazard unit RegWriteE W MemToRegE AE0B36APO Computer Architectures 12 Single cycle version Return back to single cycle processor MemToReg Control MemWrite Unit Branch 31:26 Opcode ALUControl 2:0 ALUScr 5:0 RegDest Funct AluOutW RegWrite 25:21 WE3 SrcA Zero WE 0 PC’ PC A RD Instr A1 RD1 0 Result ALU 1 20:16 A RD 1 Instr. A2 RD2 AluOutM Data 0 SrcB ReadData Memory Memory A3 Reg. 1 WD3 WD 20:16 File WriteData Rt 0 WriteReg 15:11 Rd 1 + 4 15:0 <<2 Sign Ext SignImm PCBranch PCPlus4F PCPlus4D PCPlus4E + AE0B36APO Computer Architectures 13 What we have designed? Return back to single cycle processor Řídicí část MemToReg Paměti Control MemWrite (control path) Unit Branch 31:26 Opcode ALUControl 2:0 ALUScr 5:0 RegDest Funct AluOutW RegWrite 25:21 WE3 SrcA Zero WE A RD 0 PC’ PC Instr A1 RD1 A RD ALU 0 Result 1 20:16 A RD 1 Instr. A2 RD2 0 SrcB AluOutM ReadData Memory A3 Reg. 1 WD3 WDDatová část 20:16 File WriteData Rt 0 WriteReg (data path) WE 15:11 Rd 1 + A RD 4 15:0 <<2 Data Sign Ext SignImm PCBranch Memory PCPlus4F PCPlus4D PCPlus4E + WD AE0B36APO Computer Architectures 14 What we have designed? Processor Control unit PC Instruction PC A RD RD A Instr. Memory Enable write Datapath Address of WE RD/WR Read data Address A RD RD A Data Results Written data Memory WD WD AE0B36APO Computer Architectures 15 Done - designed pipeline processor RegWriteD RegWriteE RegWriteM RegWriteW Control unit MemToRegD MemToRegE MemToRegM MemWriteD MemWriteE MemWriteM MemTo ALUControlE 31:26 ALUControlD RegW Op ALUSrcD ALUSrcE 5:0 RegDstD RegDstE Funct BranchD EquaD PCSrcD = 0 PC´ PC InstrD 25:21 WE3 0 00 SrcAE WE A RD A1 RD1 01 ALUOutM ReadDataW 1 EN 1 10 20:16 A RD A2 RD2 00 SrcBE ALU Instruction 01 0 Data Memory A3 Reg. 0 10 1 Memory 1 WriteDataE WriteDataM WD3 File WD 1 RsD ALUOutW 25:21 RsE 0 20:16 RtD RtE 0 WriteRegE 4:0 WriteRegM 4:0 WriteRegW 4:0 15:11 RdD RdE 1 15:0 SignImmD + Sign 4 Ext SignImmE <<2 + CLR PCPlus4F PCPlus4D CLR EN PCBranchD ResultW Forward Forward Forward RegWrite Stall F Stall D BranchD AE BE RegWriteM BD FlushE W ForwardAD RegWriteE Hazard unit MemToRegE AE0B36APO Computer Architectures 16 Single cycle CPU – Throughput: IPS = IC / T = IPCstr.fCLK • What is the maximal possible frequency of the CPU? • It is given by latency on the critical path – it is lw instruction in our case: Tc = tPC + tMem + tRFread + tALU + tMem + tMux + tRFsetup 25:21 WE3 SrcA WE 0 PC’ PC Instr A1 RD1 Zero A RD ALU 0 Result 1 A RD 1 20:16 Instr. A2 RD2 0 SrcB AluOut Data ReadData Memory 1 Memory A3 Reg. WD3 File WriteData WD 20:16 Rt 0 WriteReg 1 15:11 Rd + 4 15:0 <<2 Sign Ext SignImm PCBranch + PCPlus4 B35APO Computer Architectures 17 Single cycle CPU – Throughput: IPS = IC / T = IPCstr.fCLK • Tc = Tcinstr + Tcproc = (tPC + tMem) + (tRFread + tALU + tMem + tMux + tRFsetup) • Consider following parameters: tPC = 30 ns tMem = 300 ns tRFread = 50 ns tALU = 200 ns tMux = 20 ns tRFsetup = 20 ns If Tc instr is executed paralel with Tc proc, then Tc i < Tc p, and Tc p = 50+200+300+20+20 = 590 ns = 1.69 MHz -> IPS = 1 690 000 [instructions per second] B35APO Computer Architectures 18 Pipeline Processor Performance If pipeline processor has Tc clock cycle P number of pipeline steps N number of instructions in a program Tprogram = ( P + (N-1) ) * Tc because the 1st instruction needs P cycles to fill the pipeline but each additional instruction only adds one extra clock. AE0B36APO Computer Architectures 19 Pipeline Processor Performance : IPS = IC / T The cycle time is determined by the slowest step In our case memory is weak step: Tmen = 300 ns --> Tcmin = 300 ns --> 3 333 kHz • If we don't consider stall and flush pipelines, then we can say that a program with many N instructions will execute one instruction per cycle.
Recommended publications
  • Branch Prediction Side Channel Attacks
    Predicting Secret Keys via Branch Prediction Onur Ac³i»cmez1, Jean-Pierre Seifert2;3, and C»etin Kaya Ko»c1;4 1 Oregon State University School of Electrical Engineering and Computer Science Corvallis, OR 97331, USA 2 Applied Security Research Group The Center for Computational Mathematics and Scienti¯c Computation Faculty of Science and Science Education University of Haifa Haifa 31905, Israel 3 Institute for Computer Science University of Innsbruck 6020 Innsbruck, Austria 4 Information Security Research Center Istanbul Commerce University EminÄonÄu,Istanbul 34112, Turkey [email protected], [email protected], [email protected] Abstract. This paper presents a new software side-channel attack | enabled by the branch prediction capability common to all modern high-performance CPUs. The penalty payed (extra clock cycles) for a mispredicted branch can be used for cryptanalysis of cryptographic primitives that employ a data-dependent program flow. Analogous to the recently described cache-based side-channel attacks our attacks also allow an unprivileged process to attack other processes running in parallel on the same processor, despite sophisticated partitioning methods such as memory protection, sandboxing or even virtualization. We will discuss in detail several such attacks for the example of RSA, and experimentally show their applicability to real systems, such as OpenSSL and Linux. More speci¯cally, we will present four di®erent types of attacks, which are all derived from the basic idea underlying our novel side-channel attack. Moreover, we also demonstrate the strength of the branch prediction side-channel attack by rendering the obvious countermeasure in this context (Montgomery Multiplication with dummy-reduction) as useless.
    [Show full text]
  • BRANCH PREDICTORS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah
    BRANCH PREDICTORS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 6810: Computer Architecture Overview ¨ Announcements ¤ Homework 2 release: Sept. 26th ¨ This lecture ¤ Dynamic branch prediction ¤ Counter based branch predictor ¤ Correlating branch predictor ¤ Global vs. local branch predictors Big Picture: Why Branch Prediction? ¨ Problem: performance is mainly limited by the number of instructions fetched per second ¨ Solution: deeper and wider frontend ¨ Challenge: handling branch instructions Big Picture: How to Predict Branch? ¨ Static prediction (based on direction or profile) ¨ Always not-taken ¨ Target = next PC ¨ Always taken ¨ Target = unknown clk direction target ¨ Dynamic prediction clk PC + ¨ Special hardware using PC NPC 4 Inst. Memory Instruction Recall: Dynamic Branch Prediction ¨ Hardware unit capable of learning at runtime ¤ 1. Prediction logic n Direction (taken or not-taken) n Target address (where to fetch next) ¤ 2. Outcome validation and training n Outcome is computed regardless of prediction ¤ 3. Recovery from misprediction n Nullify the effect of instructions on the wrong path Branch Prediction ¨ Goal: avoiding stall cycles caused by branches ¨ Solution: static or dynamic branch predictor ¤ 1. prediction ¤ 2. validation and training ¤ 3. recovery from misprediction ¨ Performance is influenced by the frequency of branches (b), prediction accuracy (a), and misprediction cost (c) Branch Prediction ¨ Goal: avoiding stall cycles caused by branches ¨ Solution: static or dynamic branch predictor ¤ 1. prediction ¤ 2. validation and training ¤ 3. recovery from misprediction ¨ Performance is influenced by the frequency of branches (b), prediction accuracy (a), and misprediction cost (c) ��� ���� ��� 1 + �� ������� = = 234 = ��� ���� ���567 1 + 1 − � �� Problem ¨ A pipelined processor requires 3 stall cycles to compute the outcome of every branch before fetching next instruction; due to perfect forwarding/bypassing, no stall cycles are required for data/structural hazards; every 5th instruction is a branch.
    [Show full text]
  • 18-741 Advanced Computer Architecture Lecture 1: Intro And
    Computer Architecture Lecture 10: Branch Prediction Prof. Onur Mutlu ETH Zürich Fall 2017 25 October 2017 Mid-Semester Exam November 30 In class Questions similar to homework questions 2 High-Level Summary of Last Week SIMD Processing Array Processors Vector Processors SIMD Extensions Graphics Processing Units GPU Architecture GPU Programming 3 Agenda for Today & Tomorrow Control Dependence Handling Problem Six solutions Branch Prediction Other Methods of Control Dependence Handling 4 Required Readings McFarling, “Combining Branch Predictors,” DEC WRL Technical Report, 1993. Required T. Yeh and Y. Patt, “Two-Level Adaptive Training Branch Prediction,” Intl. Symposium on Microarchitecture, November 1991. MICRO Test of Time Award Winner (after 24 years) Required 5 Recommended Readings Smith and Sohi, “The Microarchitecture of Superscalar Processors,” Proceedings of the IEEE, 1995 More advanced pipelining Interrupt and exception handling Out-of-order and superscalar execution concepts Recommended Kessler, “The Alpha 21264 Microprocessor,” IEEE Micro 1999. Recommended 6 Control Dependence Handling 7 Control Dependence Question: What should the fetch PC be in the next cycle? Answer: The address of the next instruction All instructions are control dependent on previous ones. Why? If the fetched instruction is a non-control-flow instruction: Next Fetch PC is the address of the next-sequential instruction Easy to determine if we know the size of the fetched instruction If the instruction that is fetched is a control-flow
    [Show full text]
  • State of the Art Regarding Both Compiler Optimizations for Instruction Fetch, and the Fetch Architectures for Which We Try to Optimize Our Applications
    ¢¡¤£¥¡§¦ ¨ © ¡§ ¦ £ ¡ In this work we are trying to increase fetch performance using both software and hardware tech- niques, combining them to obtain maximum performance at the minimum cost and complexity. In this chapter we introduce the state of the art regarding both compiler optimizations for instruction fetch, and the fetch architectures for which we try to optimize our applications. The first section introduces code layout optimizations. The compiler can influence instruction fetch performance by selecting the layout of instructions in memory. This determines both the conflict rate of the instruction cache, and the behavior (taken or not taken) of conditional branches. We present an overview of the different layout algorithms proposed in the literature, and how our own algorithm relates to them. The second section shows how instruction fetch architectures have evolved from pipelined processors to the more aggressive wide issue superscalars. This implies increasing fetch perfor- mance from a single instruction every few cycles, to one instruction per cycle, to a full basic block per cycle, and finally to multiple basic blocks per cycle. We emphasize the description of the trace cache, as it will be the reference architecture in most of our work. 2.1 Code layout optimizations The mapping of instruction to memory is determined by the compiler. This mapping determines not only the code page where an instruction is found, but also the cache line (or which set in a set associative cache) it will map to. Furthermore, a branch will be taken or not taken depending on the placement of the successor basic blocks. By mapping instructions in a different order, the compiler has a direct impact on the fetch engine performance.
    [Show full text]
  • Branch Prediction for Network Processors
    BRANCH PREDICTION FOR NETWORK PROCESSORS by David Bermingham, B.Eng Submitted in partial fulfilment of the requirements for the Degree of Doctor of Philosophy Dublin City University School of School of Electronic Engineering Supervisors: Dr. Xiaojun Wang Prof. Lingling Sun September 2010 I hereby certify that this material, which I now submit for assessment on the programme of study leading to the award of Doctor of Philosophy is entirely my own work, that I have exercised reasonable care to ensure that the work is original, and does not to the best of my knowledge breach any law of copy- right, and has not been taken from the work of others save and to the extent that such work has been cited and acknowledged within the text of my work. Signed: David Bermingham (Candidate) ID: Date: TABLE OF CONTENTS Abstract vii List of Figures ix List of Tables xii List of Acronyms xiv List of Peer-Reviewed Publications xvi Acknowledgements xviii 1 Introduction 1 1.1 Network Processors . 1 1.2 Trends Within Networks . 2 1.2.1 Bandwidth Growth . 2 1.2.2 Network Technologies . 3 1.2.3 Application and Service Demands . 3 1.3 Network Trends and Network Processors . 6 1.3.1 The Motivation for This Thesis . 7 1.4 Research Objectives . 9 1.5 Thesis Structure . 10 iii 2 Technical Background 12 2.1 Overview . 12 2.2 Networks . 13 2.2.1 Network Protocols . 13 2.2.2 Network Technologies . 14 2.2.3 Router Architecture . 17 2.3 Network Processors . 19 2.3.1 Intel IXP-28XX Network Processor .
    [Show full text]
  • Trends in Processor Architecture
    A. González Trends in Processor Architecture Trends in Processor Architecture Antonio González Universitat Politècnica de Catalunya, Barcelona, Spain 1. Past Trends Processors have undergone a tremendous evolution throughout their history. A key milestone in this evolution was the introduction of the microprocessor, term that refers to a processor that is implemented in a single chip. The first microprocessor was introduced by Intel under the name of Intel 4004 in 1971. It contained about 2,300 transistors, was clocked at 740 KHz and delivered 92,000 instructions per second while dissipating around 0.5 watts. Since then, practically every year we have witnessed the launch of a new microprocessor, delivering significant performance improvements over previous ones. Some studies have estimated this growth to be exponential, in the order of about 50% per year, which results in a cumulative growth of over three orders of magnitude in a time span of two decades [12]. These improvements have been fueled by advances in the manufacturing process and innovations in processor architecture. According to several studies [4][6], both aspects contributed in a similar amount to the global gains. The manufacturing process technology has tried to follow the scaling recipe laid down by Robert N. Dennard in the early 1970s [7]. The basics of this technology scaling consists of reducing transistor dimensions by a factor of 30% every generation (typically 2 years) while keeping electric fields constant. The 30% scaling in the dimensions results in doubling the transistor density (doubling transistor density every two years was predicted in 1975 by Gordon Moore and is normally referred to as Moore’s Law [21][22]).
    [Show full text]
  • Energy Efficient Branch Prediction
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by University of Hertfordshire Research Archive Energy Efficient Branch Prediction Michael Andrew Hicks A thesis submitted in partial fulfilment of the requirements of the University of Hertfordshire for the degree of Doctor of Philosophy December 2007 To my family and friends. Contents 1 Introduction 1 1.1 Thesis Statement . 1 1.2 Motivation and Energy Efficiency . 1 1.3 Branch Prediction . 3 1.4 Contributions . 4 1.5 Dissertation Structure . 5 2 Energy Efficiency in Modern Processor Design 7 2.1 Transistor Level Power Dissipation . 7 2.1.1 Static Dissipation . 8 2.1.2 Dynamic Dissipation . 9 2.1.3 Energy Efficiency Metrics . 9 2.2 Transistor Level Energy Efficiency Techniques . 10 2.2.1 Clock Gating and Vdd Gating . 10 2.2.2 Technology Scaling . 11 2.2.3 Voltage Scaling . 11 2.2.4 Logic Optimisation . 11 2.3 Architecture & Software Level Efficiency Techniques . 11 2.3.1 Activity Factor Reduction . 12 2.3.2 Delay Reduction . 12 2.3.3 Low Power Scheduling . 12 2.3.4 Frequency Scaling . 13 2.4 Branch Prediction . 13 2.4.1 The Branch Problem . 13 2.4.2 Dynamic and Static Prediction . 14 2.4.3 Dynamic Predictors . 15 2.4.4 Power Consumption . 18 2.5 Summary . 18 3 Related Techniques 20 3.1 The Prediction Probe Detector (Hardware) . 20 3.1.1 Implementation . 20 3.1.2 Pipeline Gating . 22 i 3.2 Software Based Approaches . 23 3.2.1 Hinting and Hint Instructions .
    [Show full text]
  • T13: Advanced Processors – Branch Prediction
    ECE 4750 Computer Architecture, Fall 2020 T13 Advanced Processors: Branch Prediction School of Electrical and Computer Engineering Cornell University revision: 2020-11-11-15-47 1 Branch Prediction Overview 3 2 Software-Based Branch Prediction 4 2.1. Static Software Hints . .5 2.2. Branch Delay Slots . .6 2.3. Predication . .7 3 Hardware-Based Branch Prediction 8 3.1. Fixed Branch Predictor . .8 3.2. Branch History Table (BHT) Predictor . 10 3.3. Two-Level Predictor For Temporal Correlation . 14 3.4. Two-Level Predictor For Spatial Correlation . 15 3.5. Generalized Two-Level Predictors . 16 3.6. Tournament Predictors . 17 3.7. Branch Target Buffers (BTBs) Predictor . 18 Copyright © 2018 Christopher Batten, Christina Delimitrou. All rights reserved. This hand- out was originally prepared by Prof. Christopher Batten at Cornell University for ECE 4750 / CS 4420. It has since been updated by Prof. Christina Delimitrou. Download and use of this handout is permitted for individual educational non-commercial purposes only. 1 Redistribution either in part or in whole via both commercial or non-commercial means requires written permission. 2 1. Branch Prediction Overview 1. Branch Prediction Overview Assume incorrect branch prediction in dual-issue I2OL processor. bne opA opB opC opD opE opF opG opTARG Assume correct branch prediction in dual-issue I2OL processor. bne opA opTARG opX opY opZ Three critical pieces of information we need to predict control flow: • (1) Is this instruction a control flow instruction? • (2) What is the target of this control flow instruction? • (3) Do we redirect control flow to the target or next instr? 2 2.
    [Show full text]
  • Bias-Free Branch Predictor
    Bias-Free Branch Predictor Dibakar Gope and Mikko H. Lipasti Department of Electrical and Computer Engineering University of Wisconsin - Madison [email protected], [email protected] Abstract—Prior research in neurally-inspired perceptron are separated by a function call containing many branches, predictors and Geometric History Length-based TAGE predic- a longer history is likely to capture the correlated branch tors has shown significant improvements in branch prediction that appeared in the dynamic execution stream prior to the accuracy by exploiting correlations in long branch histories. However, not all branches in the long branch history provide function call. useful context. Biased branches resolve as either taken or Prediction accuracy of the recently proposed ISL-TAGE not-taken virtually every time. Including them in the branch predictor [4] further confirms that looking at much longer predictor’s history does not directly contribute any useful histories (of the order of 2000 branches) can provide useful information, but all existing history-based predictors include information for prediction. However, scaling a state-of-the- them anyway. In this work, we propose Bias-Free branch predictors that art perceptron-based predictor [1] from 64KB to 1MB to are structured to learn correlations only with non-biased track distant branch correlations results in long computa- conditional branches, aka. branches whose dynamic behavior tional latency and high energy consumption in the large varies during a program’s execution. This, combined with a storage structures, which may prohibit the incorporation recency-stack-like management policy for the global history of such a branch predictor into a commercial processor.
    [Show full text]
  • An Evaluation of Multiple Branch Predictor and Trace Cache Advanced Fetch Unit Designs for Dynamically Scheduled Superscalar Processors Slade S
    Louisiana State University LSU Digital Commons LSU Master's Theses Graduate School 2004 An evaluation of multiple branch predictor and trace cache advanced fetch unit designs for dynamically scheduled superscalar processors Slade S. Maurer Louisiana State University and Agricultural and Mechanical College, [email protected] Follow this and additional works at: https://digitalcommons.lsu.edu/gradschool_theses Part of the Electrical and Computer Engineering Commons Recommended Citation Maurer, Slade S., "An evaluation of multiple branch predictor and trace cache advanced fetch unit designs for dynamically scheduled superscalar processors" (2004). LSU Master's Theses. 335. https://digitalcommons.lsu.edu/gradschool_theses/335 This Thesis is brought to you for free and open access by the Graduate School at LSU Digital Commons. It has been accepted for inclusion in LSU Master's Theses by an authorized graduate school editor of LSU Digital Commons. For more information, please contact [email protected]. AN EVALUATION OF MULTIPLE BRANCH PREDICTOR AND TRACE CACHE ADVANCED FETCH UNIT DESIGNS FOR DYNAMICALLY SCHEDULED SUPERSCALAR PROCESSORS A Thesis Submitted to the Graduate Faculty of the Louisiana State University and Agricultural and Mechanical College in partial fulfillment of the requirements for the degree of Master of Science in Electrical Engineering in The Department of Electrical and Computer Engineering by Slade S. Maurer B.S., Southeastern Louisiana University, Hammond, Louisiana, 1998 December 2004 ACKNOWLEDGEMENTS This thesis would not be possible without several contributors. I want to thank my advisor Professor David Koppelman for his guidance and support. He brought to my attention this fascinating thesis topic and trained me to modify RSIML to support my research.
    [Show full text]
  • Branchscope: a New Side-Channel Attack on Directional Branch Predictor
    Session 8A: Security and Protection ASPLOS’18, March 24–28, 2018, Williamsburg, VA, USA BranchScope: A New Side-Channel Attack on Directional Branch Predictor Dmitry Evtyushkin Ryan Riley College of William and Mary Carnegie Mellon University in Qatar [email protected] [email protected] Nael Abu-Ghazaleh Dmitry Ponomarev University of California Riverside Binghamton University [email protected] [email protected] Abstract Support for Programming Languages and Operating Systems (AS- We present BranchScope — a new side-channel attack where PLOS’18). ACM, New York, NY, USA, 15 pages. https://doi.org/10. the attacker infers the direction of an arbitrary conditional 1145/3173162.3173204 branch instruction in a victim program by manipulating the shared directional branch predictor. The directional compo- nent of the branch predictor stores the prediction on a given 1 Introduction branch (taken or not-taken) and is a different component Modern microprocessors rely on branch prediction units from the branch target buffer (BTB) attacked by previous (BPUs) to sustain uninterrupted instruction delivery to the work. BranchScope is the first fine-grained attack on the di- execution pipeline across conditional branches. When multi- rectional branch predictor, expanding our understanding of ple processes execute on the same physical core, they share the side channel vulnerability of the branch prediction unit. a single BPU. While attractive from utilization and complex- Our attack targets complex hybrid branch predictors with ity considerations, the sharing potentially opens the door unknown organization. We demonstrate how an attacker an attacker to manipulate the shared BPU state, create a can force these predictors to switch to a simple 1-level mode side-channel, and derive a direction or target of a branch to simplify the direction recovery.
    [Show full text]
  • Branch Prediction
    Branch Prediction ▪ Static Branch Prediction ▪ Dynamic Branch Prediction ▪ Note: Assignment 1: due Feb 19th. 1 Static Branch Prediction ▪ Compiler determines whether branch is likely to be taken or likely to be not taken. – How? When is a branch likely to be taken? int gtz=0; int i = 0; while (i < 100) { x = a[i]; if (x == 0) When is a branch likely to be NOT taken? continue; gtz++; } Inf3 Computer Architecture - 2017-2018 2 Static Branch Prediction ▪ Compiler determines whether branch is likely to be taken or likely to be not taken. ▪ Decision is based on analysis or profile information – 90% of backward-going branches are taken – 50% of forward-going branches are not taken – BTFN: “backwards taken, forwards not-taken” – Used in ARC 600 and ARM 11 ▪ Decision is encoded in the branch instructions themselves – Uses 1 bit: 0 => not likely to branch, 1=> likely to branch ▪ Prediction may be wrong! – Must kill instructions in the pipeline when a bad decision is made – Speculatively issued instructions must not change processor state Inf3 Computer Architecture - 2017-2018 3 Dynamic Branch Prediction ▪ Monitor branch behavior and learn – Key assumption: past behavior indicative of future behavior ▪ Predict the present (current branch) using learned history ▪ Identify individual branches by their PC or dynamic branch history ▪ Predict: – Outcome: taken or not taken – Target: address of instruction to branch to ▪ Check actual outcome and update the history ▪ Squash incorrectly fetched instructions Inf3 Computer Architecture - 2017-2018 4 Simplest
    [Show full text]