A method for improving prediction accuracy of branch direction predictor

By introducing a branch update backup into the branch direction predictor and using the backup table and HIT check module to recalculate the update value of the saturation counter, the delayed update problem is solved, the prediction accuracy is significantly improved, and the power consumption and area overhead are reduced.

CN113553104BActive Publication Date: 2024-08-27JIANGNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110830496.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-22
Publication Date
2024-08-27
Estimated Expiration
2041-07-22

AI Technical Summary

Technical Problem

When existing branch direction predictors deal with the delayed update problem, the prediction accuracy is severely lost, and the existing IUM module has a limited repair effect on this problem, which is about 3/4.

Method used

A branch update backup device is designed, including n-way backup table, HIT check module, CTR update module and backup address selector. It recalculates the saturation counter by backing up the latest n update information and the Index/Tag at the time of prediction. Update the value, select the backup table under the appropriate path number configuration, and update the branch prediction table to improve prediction accuracy.

Benefits of technology

It effectively improves the prediction accuracy of the branch direction predictor. Experiments show that only a smaller number of backup tables can be configured to achieve a higher degree of repair with less power consumption and area overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553104B
    Figure CN113553104B
Patent Text Reader

Abstract

The present invention discloses a method for improving the prediction accuracy of a branch direction predictor, and belongs to the field of branch predictor design of a processor. The branch direction predictor adds a branch update backup device on the basis of the structure of a traditional branch direction predictor, and the branch update backup device includes an n-way backup table, a HIT check module, a CTR update module and a backup address selector; the backup table, the HIT check module and the CTR update module are connected in sequence, and the backup table, the HIT check module and the CTR update module are all connected to the backup address selector. Compared with the existing method of adding an IUM module, the present application considers more historical directions of branch instructions as much as possible, thereby more effectively improving the prediction accuracy of the branch direction predictor, and experimentally proves that the degree of repair of the prediction accuracy of the TAGE predictor exceeds 80%, effectively solving the delayed update problem of the TAGE predictor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for improving the prediction accuracy of a branch direction predictor, and belongs to the field of branch predictor design of a processor. Background Art

[0002] For modern processors, the prediction accuracy of the branch predictor seriously affects the performance of the processor.

[0003] There are two types of branch predictors: branch direction predictor and branch target predictor. The branch direction predictor can predict the direction of the branch instruction (jump or not jump), and the branch target predictor can predict the jump address of the branch instruction. At present, the mainstream branch direction predictors include Bimode, GShare and TAGE-based, all of which are predictors based on multi-bit saturated counters.

[0004] As we all know, there are three stages in the processor pipeline where the saturation counter can be updated, namely the instruction fetch stage, the execution stage, and the commit stage. Updating the saturation counter at different stages of the pipeline will affect the prediction accuracy of the branch direction predictor: (a) In the instruction fetch stage, the branch direction predictor can be updated in time, but since the correctness of the current update cannot be guaranteed, it may cause pollution to the saturation counter, which in turn has a very serious impact on the prediction accuracy of the branch direction predictor; (b) In the execution or commit stage (that is, the direction of the branch instruction can be correctly calculated), the correctness of its update can be guaranteed, but it will bring about the problem of delayed update, which in turn will have a certain impact on the prediction accuracy of the branch direction predictor. To be conservative, in real pipeline processors, the saturation counter is generally updated in the execution or commit stage.

[0005] Seznec et al. of the French National Institute for Information and Automation (see Seznec AA new case for the TAGE branch predictor [C]. In International Symposium on Microarchitecture, 2011: 117-127.) proposed a method of adding an IUM (ImmediateUpdateMimicker) module to the original branch direction predictor, which can effectively solve the problem of delayed update. However, when dealing with the delayed update problem, the IUM module simply uses the previous historical direction of branch instruction B as the predicted direction of this branch instruction B, without considering more historical directions of branch instruction B. Therefore, the IUM module has a limited degree of repair for the loss of prediction accuracy caused by delayed update, which is about 3 / 4. Summary of the invention

[0006] In order to further improve the prediction accuracy of the branch direction predictor, the present invention provides a branch direction predictor that can effectively solve the delayed update problem based on the traditional branch direction predictor.

[0007] A branch direction predictor includes an Index generation module, a branch prediction table and a prediction output module. For a branch direction predictor including a Tag, it also includes a Tag generation module and a Tag matching module. The branch direction predictor also includes a branch update backup device. The branch update backup device includes:

[0008] The backup table, HIT check module, CTR update module and backup address selector of n paths are connected in sequence, and the backup table, HIT check module and CTR update module are all connected to the backup address selector.

[0009] Optionally, the backup tables of n ways are respectively used to back up the update information output by the backup address selector for the most recent n times, the update information including the saturation counter update value ctr* and the Index during prediction, and for the branch direction predictor including the Tag, the update information also includes the Tag during prediction;

[0010] The HIT checking module is used to check whether the same table entry of the branch prediction table has been updated more than once in the latest n+1 updates of the branch prediction table by the processor according to the Index in the backup table; for the branch direction predictor including the Tag, the HIT checking module is used to check according to the Index in the backup table and the Tag in the backup table;

[0011] The CTR update module is used to recalculate the update value ctr* of the saturation counter according to the saturation counter value output by the HIT check module and the actual direction of the current branch instruction, and output it to the backup address selector and the branch prediction table;

[0012] The backup address selector is used to select a backup table from the n-way backup table according to the inspection result of the HIT inspection module, and back up the saturated counter value ctr* output by the CTR update module and the Index at the time of prediction to this backup table. For the branch direction predictor containing a Tag, it also includes backing up the Tag at the time of prediction to this backup table to wait for the next processor to update the branch direction predictor.

[0013] Optionally, the HIT checking module checks whether the processor has recently updated the same entry of the branch prediction table, including:

[0014] (a) If it does not exist, that is, it does not hit in the backup table, the saturated counter value ctr0 during prediction is directly used as the output;

[0015] (b) If it exists, that is, it hits in the backup table, the saturated counter value ctr1 of the backup table that hits is used as the output.

[0016] Optionally, the update value ctr* is calculated as follows:

[0017] (a) If the actual direction of the current branch instruction is not to jump, then ctr0 / 1 is reduced by 1;

[0018] (b) If the actual direction of the current branch instruction is a jump, add 1 to ctr0 / 1.

[0019] Optionally, the backup address selector's strategy for selecting the backup table is:

[0020] (a) If the check result of the HIT check module is a miss, a backup table that has not been used recently is selected;

[0021] (b) If the inspection result of the HIT inspection module is a hit, a backup table of the hit is selected.

[0022] Optionally, the Index generation module, the branch prediction table, and the prediction output module are connected in sequence;

[0023] The Index generation module is used to generate an index address Index of a branch prediction table according to the PC of the branch instruction and the value of the history register;

[0024] The branch prediction table is used to store prediction information of branch instructions, the prediction information is the value ctr0 of the saturation counter, and for a branch direction predictor including a tag, the prediction information also includes a tag for detecting whether the table entry matches the branch instruction;

[0025] The prediction output module is used to calculate the prediction result of the branch instruction according to the index result of the branch prediction table and, for the branch direction predictor including the tag, according to the hit information generated by the tag matching module;

[0026] The tag generation module is used to generate the tag of the branch instruction according to the PC of the branch instruction and the value of the history register;

[0027] The tag matching module is used to detect the hit situation of the branch prediction table to the branch instruction according to the tag output by the tag generation module and the tag obtained by indexing the branch prediction table.

[0028] The present application also provides a method for improving the prediction accuracy of a branch direction predictor. The method adds a branch update backup device based on the structure of a traditional branch direction predictor. The branch update backup device includes:

[0029] A backup table, a HIT check module, a CTR update module and a backup address selector of n paths; the backup table, the HIT check module and the CTR update module are connected in sequence, and the backup table, the HIT check module and the CTR update module are all connected to the backup address selector;

[0030] The conventional branch direction predictor includes an Index generation module, a branch prediction table and a prediction output module. For a branch direction predictor including a Tag, it also includes a Tag generation module and a Tag matching module.

[0031] The Index generation module in the traditional branch direction predictor outputs the Index at the time of prediction to the backup address selector of the branch update backup device, and the CTR update module outputs the updated value ctr* of the saturated counter to the backup address selector of the branch update backup device. For the branch direction predictor containing a Tag, the Tag generation module outputs the Tag at the time of prediction to the backup address selector of the branch update backup device, so that the backup address selector selects one backup table from the n-way backup table according to the inspection result of the HIT inspection module, and backs up the saturated counter value ctr* and the Index at the time of prediction output by the CTR update module, and for the branch direction predictor containing a Tag, also includes the Tag at the time of prediction, to this backup table to wait for the next processor to update the branch prediction table.

[0032] Optionally, the method comprises:

[0033] The Index generation module generates the index address Index of the branch prediction table according to the PC address of the branch instruction and the value of the history register. For a branch direction predictor including a Tag, the Tag generation module generates the Tag information of the branch instruction according to the PC address of the branch instruction and the value of the history register, and sends the generated Tag information of the branch instruction to the Tag matching module;

[0034] The branch prediction table retrieves the saturated counter value ctr0 in the corresponding table entry according to the generated index address Index. For a branch direction predictor including a Tag, the branch prediction table can also retrieve the tag information in the corresponding table entry according to the index address, and sends the retrieved tag information in the corresponding table entry to the Tag matching module;

[0035] The prediction output module outputs a corresponding prediction result according to the saturated counter value ctr0 output by the branch prediction table;

[0036] For a branch direction predictor including a tag, the tag matching module outputs the hit status of the branch instruction according to the tag information of the branch instruction and the tag information in the corresponding table entry; the prediction output module outputs the corresponding prediction result according to the saturated counter value ctr0 output by the branch prediction table and the hit status of the branch instruction output by the tag matching module;

[0037] When the processor updates the branch direction predictor, the branch update backup obtains the update value ctr* of the saturation counter according to the Index output by the Index generation module and the saturation counter value ctr0 output by the branch prediction table, and updates it to the branch prediction table of the traditional branch direction predictor, so as to complete the processor's update of the branch direction predictor;

[0038] For the branch direction predictor including the Tag, the branch update backup obtains the update value ctr* of the saturated counter according to the Index output by the Index generation module, the saturated counter value ctr0 output by the branch prediction table, and the Tag information output by the Tag generation module, and updates it to the branch prediction table of the traditional branch direction predictor to complete the processor's update of the branch direction predictor.

[0039] Optionally, the traditional branch direction predictor includes a GShare predictor and a TAGE predictor.

[0040] The present application also provides a processor, wherein the branch direction predictor of the processor is the above-mentioned branch direction predictor including the branch update backup device.

[0041] The beneficial effects of the present invention are:

[0042] 1) Compared with the existing method of adding an IUM module, the branch update backup provided by the present invention can enable the branch direction predictor to consider more historical directions of branch instructions as much as possible when dealing with the delayed update problem, thereby more effectively improving the prediction accuracy of the branch direction predictor.

[0043] 2) The branch update backup device provided by the present invention can be set to corresponding table entries and appropriate ways according to the characteristics of the traditional branch direction predictor, and is applicable to a variety of traditional branch direction predictors.

[0044] 3) Experiments show that a high degree of repair can be achieved by configuring only a small number of backup tables. Therefore, the branch update backup device provided by the present invention has a small power consumption and area overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 It is a structural schematic diagram of a branch direction predictor provided by the present invention.

[0047] Figure 2 yes Figure 1 Schematic diagram of the structure of the branch update backup device in .

[0048] Figure 3 The simulation diagram shows the degree to which the branch update backup device repairs the prediction accuracy of the GShare predictor under different numbers of backup tables.

[0049] Figure 4 The simulation diagram shows the degree to which the branch update backup device repairs the TAGE predictor's prediction accuracy under different numbers of backup tables. DETAILED DESCRIPTION

[0050] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0051] Embodiment 1:

[0052] This embodiment provides a branch direction predictor that can effectively solve the delayed update problem. The structure of the branch direction predictor is as follows: Figure 1 As shown, it includes a traditional branch direction predictor (such as GShare, TAGE, etc.) and a branch update backup device.

[0053] The traditional branch direction predictor includes an Index generation module, a branch prediction table and a prediction output module. For a traditional branch direction predictor including a Tag (such as TAGE), it also includes a Tag generation module and a Tag matching module.

[0054] The Index generation module is used to generate an index address Index of the branch prediction table according to the PC of the branch instruction and the value of the history register;

[0055] The branch prediction table is used to store prediction information of branch instructions, the prediction information is the value ctr0 of the saturation counter, and for a branch direction predictor including a tag, the prediction information also includes a tag for detecting whether the table entry matches the branch instruction, etc.;

[0056] The prediction output module is used to calculate the prediction result of the branch instruction according to the index result of the branch prediction table and, for the branch direction predictor including the tag, according to the hit information generated by the tag matching module;

[0057] The tag generation module is used to generate the tag of the branch instruction according to the PC of the branch instruction and the value of the history register;

[0058] The tag matching module is used to detect the hit situation of the branch prediction table to the branch instruction according to the tag output by the tag generation module and the tag obtained by indexing the branch prediction table.

[0059] The structure of the branch update backup device is as follows Figure 2 As shown, it includes an n-way backup table, a HIT check module, a CTR update module and a backup address selector.

[0060] The backup table is used to back up the update information output by the backup address selector for the most recent n times, wherein the update information includes the saturation counter update value ctr* and the Index during prediction. For a branch direction predictor including a Tag, the update information also includes the Tag during prediction.

[0061] The HIT check module is used to check, according to the Index in the backup table, for the branch direction predictor including the Tag, whether the same table entry in the branch prediction table has been updated more than once in the most recent n+1 updates of the branch prediction table by the processor according to the Tag in the backup table:

[0062] (a) If it does not exist, that is, it does not hit in the backup table, the saturated counter value ctr0 during prediction is directly used as the output;

[0063] (b) If it exists, that is, it hits in the backup table, the saturated counter value ctr1 of the backup table that hits is used as the output.

[0064] The CTR update module is used to recalculate the update value ctr* of the saturated counter according to the saturated counter value ctr0 / 1 output by the HIT check module and the actual direction of the current branch instruction (whether to jump), and output it to the backup address selector and the branch prediction table.

[0065] Among them, the method of calculating ctr* is:

[0066] (a) If the actual direction of the current branch instruction is not to jump, then ctr0 / 1 is reduced by 1;

[0067] (b) If the actual direction of the current branch instruction is a jump, add 1 to ctr0 / 1.

[0068] The backup address selector is used to select a backup table from the n-way backup table according to the inspection result of the HIT inspection module, and back up the saturated counter value ctr* and the index at the time of prediction output by the CTR update module, and for the branch direction predictor containing the Tag, also includes the Tag at the time of prediction, to this backup table to wait for the next processor to update the branch direction predictor.

[0069] The strategy for selecting the backup table is:

[0070] (a) If the check result of the HIT check module is a miss, a backup table that has not been used recently is selected;

[0071] (b) If the inspection result of the HIT inspection module is a hit, a backup table of the hit is selected.

[0072] In order to verify the degree to which the branch update backup device can repair the prediction accuracy loss caused by delayed updates, the present invention designs branch update backup devices with 1, 2, 3, and 4-way backup tables for the GShare predictor and the TAGE predictor, respectively.

[0073] The experimental parameters of the GShare predictor (see Wang Wei. Performance Modeling of Out-of-Order Processor Branch Predictor [D]. Southeast University, 2017: 18-19.) are: the width of the history register is 18, and the depth of the pattern history table (PHT) is 256K.

[0074] The experimental parameters of the TAGE predictor (see Seznec AA new case for the TAGE branch predictor [C]. In International Symposium on Microarchitecture, 2011: 117-127.) are shown in Table 1.

[0075] Table 1 Experimental parameters of TAGE predictor

[0076]

[0077]

[0078] The experiments were conducted on the simulation model provided by the 3rd Championship Branch Prediction (http: / / www.jilp.org / jwac-2 / framework.html), which simulates a superscalar out-of-order processor with a 14-stage pipeline. The test stimulus of the simulation model contains five categories (CLIENT, INT, MM, SERVER, WS), totaling about 50 million microinstructions.

[0079] Figure 3 The simulation diagram of the degree of repair of the prediction accuracy of the GShare predictor by the branch update backup under different number of backup tables. Figure 3 It can be seen from the experimental results that when the number of ways in the backup table is 3, the branch update backup device repairs the prediction accuracy of the GShare predictor by more than 80%, effectively solving the delayed update problem of the GShare predictor.

[0080] Figure 4 The simulation diagram of the degree of repair of the TAGE predictor prediction accuracy by the branch update backup under different number of backup tables. Figure 4 It can be seen from the experimental results that when the number of ways in the backup table is 2, the branch update backup device repairs the prediction accuracy of the TAGE predictor by more than 80%, effectively solving the delayed update problem of the TAGE predictor.

[0081] Some steps in the embodiments of the present invention may be implemented using software, and the corresponding software program may be stored in a readable storage medium, such as a CD or a hard disk.

[0082] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A branch direction predictor, comprising an Index generation module, a branch prediction table and a prediction output module. For a branch direction predictor including a Tag, it also comprises a Tag generation module and a Tag matching module, characterized in that: The branch direction predictor also includes a branch update backup device, and the branch update backup device includes: A backup table, a HIT check module, a CTR update module and a backup address selector of n paths; the backup table, the HIT check module and the CTR update module are connected in sequence, and the backup table, the HIT check module and the CTR update module are all connected to the backup address selector; The backup tables of n ways are respectively used to back up the update information output by the backup address selector for the latest n times, wherein the update information includes the saturation counter update value ctr* and the Index at the time of prediction. For the branch direction predictor including the Tag, the update information also includes the Tag at the time of prediction; The HIT checking module is used to check whether the same table entry of the branch prediction table has been updated more than once in the latest n+1 updates of the branch prediction table by the processor according to the Index in the backup table; for the branch direction predictor including the Tag, the HIT checking module is used to check according to the Index in the backup table and the Tag in the backup table; The CTR update module is used to recalculate the update value ctr* of the saturation counter according to the saturation counter value output by the HIT check module and the actual direction of the current branch instruction, and output it to the backup address selector and the branch prediction table; The backup address selector is used to select a backup table from the n-way backup table according to the inspection result of the HIT inspection module, and back up the saturated counter value ctr* output by the CTR update module and the Index at the time of prediction to the backup table of the way. For the branch direction predictor including the Tag, the Tag at the time of prediction is also backed up to the backup table of the way to wait for the next processor to update the branch direction predictor; The Index generation module, the branch prediction table, and the prediction output module are connected in sequence; The Index generation module is used to generate an index address Index of a branch prediction table according to the PC of the branch instruction and the value of the history register; The branch prediction table is used to store prediction information of branch instructions, the prediction information is the value ctr0 of the saturation counter, and for a branch direction predictor including a tag, the prediction information also includes a tag for detecting whether the table entry matches the branch instruction; The prediction output module is used to calculate the prediction result of the branch instruction according to the index result of the branch prediction table and, for the branch direction predictor including the tag, according to the hit information generated by the tag matching module; The tag generation module is used to generate the tag of the branch instruction according to the PC of the branch instruction and the value of the history register; The tag matching module is used to detect the hit situation of the branch prediction table to the branch instruction according to the tag output by the tag generation module and the tag obtained by indexing the branch prediction table.

2. The branch direction predictor according to claim 1, characterized in that: The HIT checking module checks whether the processor has recently updated the same entry of the branch prediction table, including: (a) If it does not exist, that is, it does not hit in the backup table, the saturated counter value ctr0 during prediction is directly used as the output; (b) If it exists, that is, it hits in the backup table, the saturated counter value ctr1 of the backup table that hits is used as the output.

3. The branch direction predictor according to claim 2, characterized in that: The calculation method of the update value ctr* is: (a) If the actual direction of the current branch instruction is not to jump, then ctr0 / 1 is reduced by 1; (b) If the actual direction of the current branch instruction is a jump, add 1 to ctr0 / 1.

4. The branch direction predictor according to claim 3, characterized in that: The strategy of selecting the backup table of the backup address selector is: (a) If the check result of the HIT check module is a miss, a backup table that has not been used recently is selected; (b) If the inspection result of the HIT inspection module is a hit, a backup table of the hit is selected.

5. A method for improving the prediction accuracy of a branch direction predictor, characterized in that: The method adds a branch update backup device based on the structure of a traditional branch direction predictor, and the branch update backup device includes: n-way backup table, HIT check module, CTR update module and backup address selector; the backup table, HIT check module and CTR update module are connected in sequence, and the backup table, HIT check module and CTR update module are all connected to the backup address selector; the n-way backup table is used to back up the latest n times of update information output by the backup address selector respectively; The conventional branch direction predictor includes an Index generation module, a branch prediction table and a prediction output module. For a branch direction predictor including a Tag, it also includes a Tag generation module and a Tag matching module. The Index generation module in the traditional branch direction predictor outputs the Index at the time of prediction to the backup address selector of the branch update backup device, and the CTR update module outputs the updated value ctr* of the saturated counter to the backup address selector of the branch update backup device. For the branch direction predictor containing a Tag, the Tag generation module outputs the Tag at the time of prediction to the backup address selector of the branch update backup device, so that the backup address selector selects one backup table from the n-way backup table according to the inspection result of the HIT inspection module, and backs up the saturated counter value ctr* and the Index at the time of prediction output by the CTR update module, and for the branch direction predictor containing a Tag, also includes the Tag at the time of prediction, to this backup table to wait for the next processor to update the branch prediction table.

6. The method according to claim 5, characterized in that The method comprises: The Index generation module generates the index address Index of the branch prediction table according to the PC address of the branch instruction and the value of the history register. For a branch direction predictor including a Tag, the Tag generation module generates the Tag information of the branch instruction according to the PC address of the branch instruction and the value of the history register, and sends the generated Tag information of the branch instruction to the Tag matching module; The branch prediction table retrieves the saturated counter value ctr0 in the corresponding table entry according to the generated index address Index. For a branch direction predictor including a Tag, the branch prediction table can also retrieve the tag information in the corresponding table entry according to the index address, and sends the retrieved tag information in the corresponding table entry to the Tag matching module; The prediction output module outputs a corresponding prediction result according to the saturated counter value ctr0 output by the branch prediction table; For a branch direction predictor including a tag, the tag matching module outputs the hit status of the branch instruction according to the tag information of the branch instruction and the tag information in the corresponding table entry; the prediction output module outputs the corresponding prediction result according to the saturated counter value ctr0 output by the branch prediction table and the hit status of the branch instruction output by the tag matching module; When the processor updates the branch direction predictor, the branch update backup obtains the update value ctr* of the saturation counter according to the Index output by the Index generation module and the saturation counter value ctr0 output by the branch prediction table, and updates it to the branch prediction table of the traditional branch direction predictor, so as to complete the processor's update of the branch direction predictor; For the branch direction predictor including the Tag, the branch update backup obtains the update value ctr* of the saturated counter according to the Index output by the Index generation module, the saturated counter value ctr0 output by the branch prediction table, and the Tag information output by the Tag generation module, and updates it to the branch prediction table of the traditional branch direction predictor to complete the processor's update of the branch direction predictor.

7. The method according to claim 6, characterized in that The conventional branch direction predictors include GShare and TAGE predictors.

8. A processor, characterized in that: The branch direction predictor of the processor is the branch direction predictor described in any one of claims 1-4.