Exploring Correlation for Indirect Branch Prediction

Exploring Correlation for Indirect Branch Prediction

Exploring Correlation for Indirect Branch Prediction Nikunj Bhansali Chintan Panirwala Huiyang Zhou Department of Electrical and Computer Engineering North Carolina State University {nsbhansa, cdpanirw, hzhou}@ncsu.edu Abstract information for indirect branches is to view each target of an indirect branch as a virtual branch [7]. This way, a In this paper, we present a highly accurate predictor conditional branch predictor can be (re)used to predict for indirect branches. The baseline is a tagged PPM-like which virtual branch is taken and the associated target (Prediction by Partial Matching) structure. The pattern will be the prediction of the indirect branch. In a recent to be matched includes global taken/not-taken and path work [3], a value-based BTB indexing (VBBI) is history of both conditional and indirect branches. Rather proposed. In this approach, the compiler is used to than the conventional way of using the longest matches identify the last definition of the source variable of an for prediction, we propose simple yet effective ways to indirect branch (such as a switch-case variable or adaptively select from matches with both short and long function pointer) and use this definition as a hint to histories. We also designed an auxiliary predictor to predict/resolve the corresponding indirect branch. exploit the correlation between the addresses of Our proposed predictor leverages previous work producer loads and the targets of consumer indirect based on the PPM algorithm, the ITTAGE predictor in branches. particular, for indirect branches. Our key idea is that rather than always using the Markov model with the 1. Introduction longest match to make a prediction, we adaptively select the Markov models with proper history lengths. Similar observations that the longest matches may not be the best Besides conditional branches, indirect branches with choice have been made in our previous work [4] on multiple targets present a challenge for processor conditional branch prediction. performance, especially when the targets are dependent Another novelty of our work is that we found that on long-latency computation or memory accesses. there exists very strong correlation between the producer Mispredictions of such indirect branches result in load addresses and the consumer branch targets, similar significant performance loss as well as energy wasted on to address-branch correlation explored for conditional executing instructions along wrong paths. In this paper, branches [5]. We exploit such correlation at the address we propose a predictor to achieve high prediction generation (AGEN) stage of a load instruction to make accuracy for indirect branches. early correction of mispredicted indirect branches. Our 1.1. Related work approach is similar to VBBI and the fundamental difference is that we exploit the stable relationship Previous studies have shown that history information between load addresses and loaded values, which may of control flow carries strong correlation to the targets of span multiple load instructions, while VBBI focuses on indirect branches. To capture such correlation, target data dependence flow. For example, in the case of caches [1] were proposed, in which the targets of an ‘switch(p->num) {…}; p= p->next’, VBBI uses the last indirect branch with different history are maintained definition of ‘p->num’ while our approach uses ‘&(p- separately. Cascaded predictors [2] were proposed later >num)’ or ‘p’ to predict/resolve the indirect branch on to combine multiple target caches with different ‘switch(p->num)’. history lengths. The Prediction by Partial Matching (PPM) algorithm provides a more generic model to 1.2. Outline exploit control-flow history information. PPM-based In section 2, we present the design of our proposed predictors [6] contain multiple Markov predictors with predictors and discuss its implementation issues. Section each capturing a different history length and the one with 3 reports the detailed information of the storage cost of the longest match will be used to make the final our proposed design. Section 4 briefly analyzes the prediction. The ITTAGE predictor [8] is an efficient way experimental results. Section 5 concludes the paper. to implement the PPM algorithm with very long histories. Another way to exploit branch history 1 T1 T2 T3 Tn Tag u Target Tag u Target Alt Tag u Target Alt Tag u Target Alt T1_Match T2_Match T1,2_Match … Ti_Match is the tag T3_Match match signal of table Ti … T1,i_Match is the combined tag match signal of tables T1 to Ti T1,n-1_Match Tn_Match T1_Match T2_Match HBT hit … Tn_Match hlen Target Prediction (a) Predictor Structure T1_Match T1,2_Match HBT T2_Match T1,3_Match T3_Match … tag mc hlen T1,n-2_Match T1,n-1_Match T1,n-2_Match (b) Tag Match Signals (c) A table for hard-to-predict branches Figure 1. The main predictor to exploit correlation in control-flow history limited usage and relatively high storage cost. The 2. Design overall predictor structure is shown in Figure 1a. 2.1. A Main Predictor at the Fetch Stage As shown in Figure 1a, in all the tables except T1, each entry has 4 fields, tag, u (usefulness for The baseline of our design is the ITTAGE predictor. replacement), target and alt. We design two ways to It has multiple tagged tables with each capturing a choose a table to provide the final prediction when there specific history length. In our design, we use the same is more than one table having tag matches. The first is multiple-table structure. The first table (T1) uses the through the alt field. If this one-bit field is clear, it means shortest history to generate its indices and tags while the that the target from the current entry is preferred for last table (Tn) uses the longest history for its tag and prediction. If the field is set, it means that a table with index functions. Our key improvement over the ITTAGE shorter history is to be used to make the final prediction. predictor is that rather than using the cascaded design to Such logic is implemented using the multiplexers, which select the table providing the longest match, we are controlled with the alt fields, as shown in Figure 1a. adaptively choose which table to be used for the final As T1 is the one with shortest history, there is no need target prediction. In addition, we choose not to include a for the alt field. Initially, the alt fields in all the tables are base predictor, which is to be indexed with the program set to false, which is functionally equivalent to selecting counter (PC) without any history information, due to its the longest match. During the update phase, if it is found 2 that the table with the longest match fails to make the From Figure 2, we can see that the producer load correct prediction while another table does, the alt field accesses two primary addresses and either address fields will be set for those entries with longer history contains a different branch target. As long as the data lengths. The tag match signals shown in Figure 1a and structure (e.g., a virtual function table) at these addresses Figure 1b are used to ensure that the tables without a tag is not frequently updated, the addresses of the producer match will not be used for final prediction. loads are sufficient to determine the targets of their Our second way to select the proper table to provide consumer indirect branches. We refer to such correlation the prediction is to use another multiplexer controlled by as address-target correlation (ATC). a separate structure, called a hard-to-predict branch table In our design, we capture ATC in a small cache-like (HBT). The HBT is a cache-like set- associative structure set associative structure, called address-target table and each entry contains a tag, a misprediction counter (ATT) as shown in Figure 3. Each entry in ATT contains (mc), and a history length (hlen) field, as shown in a tag and multiple pairs of hashed addresses and the Figure 1c. The mc field is used for replacement so that corresponding targets. only those indirect branches with high misprediction ATT is accessed at the address generation (AGEN) rates are kept in the table. The HBT is updated based on stage of a load instruction if it has a dependent indirect the prediction made using the longest match rather than branch. The PC of the consumer indirect branch is used the actual prediction depending on the alt fields. Since for tag match to see whether an entry in ATT has been the branches in HBT are mispredicted using the longest allocated for it. If so, the hashed address of the producer match, we increase the hlen field, whose value, x, is then load will be used to compare with multiple address-target used to select the table with the xth longest histories. For pairs in the entry to find a matching pair to provide the example, if the hlen of an indirect branch is 2 and tables prediction for the consumer branch. If the prediction T2, T4, and T5 have tag matches and their corresponding differs from the one made at the fetch stage of the alt fields are false, we will not select the longest match indirect branch, an early misprediction recovery is (i.e., T5) or the second longest match (T4). Instead, the initiated to reduce the misprediction penalty. ATT is table T2 is selected as a result of the hlen field being 2. updated at the execution stage of an indirect branch. Our proposed predictor is accessed at the instruction Only if it is mispredicted at the fetch stage, we search for fetch stage to make a prediction and it is updated at the its producer load address and then update ATT with the retire stage of an indirect branch.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us