An arbitration method for hybrid branch prediction algorithm
By combining the results of TAGE, LOOP and SF prediction algorithms, and using the conditional judgment of saturation counters and weight counters, the problem of low prediction accuracy of loop instructions in the processor is solved, and the branch prediction accuracy and performance of the processor are improved.
Patent Information
- Application Number
- CN202210350363.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-02
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-04-02
Smart Images

Figure CN114741118B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to an arbitration method of a hybrid branch prediction algorithm, belonging to the technical field of processor design. Background Art
[0002] In the processor, the cache and branch prediction modules greatly affect the performance of the processor, and improving the accuracy of branch prediction is the key to improving the performance of the processor. In modern processor design, a combination of multiple algorithms is often used to improve its accuracy. This patent is mainly aimed at the relevant prediction algorithms of conditional jump instructions, and the arbitration scheme of three prediction algorithms: TAGE (tagged geometric), SF (statistical filter), and LOOP. Among them, although the TAGE prediction algorithm can well predict branch instructions with historical relevance, it has poor prediction effect for branch instructions that are irrelevant to history but have a strong offset direction. Therefore, someone proposed the SF algorithm. When a branch instruction that is irrelevant to history is detected, the SF prediction result will replace the TAGE prediction result, so that the accuracy of the prediction result is improved on the basis of the original predictor. Because the direction of the last instruction of the loop is different from the previous direction, the two prediction algorithms TAGE SF have greater difficulty in predicting the last branch instruction of the loop. Therefore, for such loop instructions, someone proposed the LOOP prediction algorithm, which is suitable for predicting loop exit. The above three different prediction algorithms will produce different prediction results for the same instruction, so the arbitration scheme for the three algorithms will seriously affect the prediction accuracy of the predictor, and then affect the processor performance. Summary of the invention
[0003] The present invention proposes an arbitration method for a hybrid branch prediction algorithm, and the technical solution adopted is:
[0004] An arbitration method for a hybrid branch prediction algorithm comprises the following steps:
[0005] S1 and PC input three algorithm modules respectively, namely TAGE prediction algorithm, LOOP prediction algorithm and SF prediction algorithm. PC will obtain the result TAGE_RESULT of TAGE prediction algorithm, the result LOOP_RESULT of LOOP prediction algorithm and the result SF_RESULT of SF prediction algorithm.
[0006] S2, PC determines whether the conditions for using the SF prediction result are met, if so, the final prediction result is SF_RESULT; if not, go to step S3;
[0007] The judgment method is: increase the bit width of the saturation counter in the SF prediction algorithm to 6 bits; when the following three conditions are met at the same time, SF_RESULT is used as the final prediction result;
[0008] The three conditions are: a. PC can address the corresponding item in the SF prediction algorithm; b. PC addresses the item in the SF prediction algorithm, and the saturation counter of the item has the upper 4 bits of 0 or 1, in which case the saturation counter result of the item is a strong attribute; c. PC addresses the item in the TAGE prediction algorithm, and the saturation counter result of the item is a non-strong attribute;
[0009] S3, determine whether the value of the weight counter set inside the LOOP prediction algorithm is the maximum value. When the value of the weight counter is the maximum value, the final prediction result is LOOP_RESULT; if not, proceed to step S4;
[0010] The judgment method is: set the weight counter to 4 bits. When the LOOP prediction algorithm exits the loop and finds that the prediction direction is correct after the corresponding instruction is executed, the value of the weight counter is increased by 1 as long as it is not the maximum value. When the PC can address the corresponding item in the LOOP prediction algorithm and the value of the weight counter of the item is the maximum value, the prediction result LOOP_RESULT of the LOOP prediction algorithm is used as the final result.
[0011] S4. The result TAGE_RESULT of the TAGE prediction algorithm is taken as the final result.
[0012] In the method of the present invention, the three prediction algorithms mentioned, namely, TAGE prediction algorithm, LOOP prediction algorithm and SF prediction algorithm, are all known technologies and are known to those skilled in the art.
[0013] Compared with the prior art, the present invention has the following beneficial effects:
[0014] The method of the present invention realizes a reasonable arbitration scheme for the prediction results of three branch prediction algorithms, namely TAGE, LOOP and SF, and improves the branch prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flowchart of the method of the present invention.
[0016] Figure 2 Schematic diagram of the TAGE prediction algorithm in this embodiment.
[0017] Figure 3 It is a flow chart of the LOOP prediction algorithm in this embodiment.
[0018] Figure 4 is a flow chart of the SF prediction algorithm in this embodiment. DETAILED DESCRIPTION
[0019] The technical solution of the present invention is described in detail below, but the protection scope of the present invention is not limited to the embodiments.
[0020] To make the content of the present invention more clearly understood, the following Figure 1 -Attached Figure 4 The specific implementation manner is further described.
[0021] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0022] The present invention proposes an arbitration method for a hybrid branch prediction algorithm, comprising the following steps:
[0023] S1 and PC input three algorithm modules respectively, namely TAGE prediction algorithm, LOOP prediction algorithm and SF prediction algorithm. PC will obtain the result TAGE_RESULT of TAGE prediction algorithm, the result LOOP_RESULT of LOOP prediction algorithm and the result SF_RESULT of SF prediction algorithm.
[0024] S2, PC determines whether the conditions for using the SF prediction result are met, if so, the final prediction result is SF_RESULT; if not, go to step S3;
[0025] The judgment method is: increase the bit width of the saturation counter in the SF prediction algorithm to 6 bits; when the following three conditions are met at the same time, SF_RESULT is used as the final prediction result;
[0026] The three conditions are: a. PC can address the corresponding item in the SF prediction algorithm; b. PC addresses the item in the SF prediction algorithm, and the saturation counter of the item has the upper 4 bits of 0 or 1, in which case the saturation counter result of the item is a strong attribute; c. PC addresses the item in the TAGE prediction algorithm, and the saturation counter result of the item is a non-strong attribute;
[0027] S3, determine whether the value of the weight counter set inside the LOOP prediction algorithm is the maximum value. When the value of the weight counter is the maximum value, the final prediction result is LOOP_RESULT; if not, proceed to step S4;
[0028] The judgment method is: set the weight counter to 4 bits. When the LOOP prediction algorithm exits the loop and finds that the prediction direction is correct after the corresponding instruction is executed, the value of the weight counter is increased by 1 as long as it is not the maximum value. When the PC can address the corresponding item in the LOOP prediction algorithm and the value of the weight counter of the item is the maximum value, the prediction result LOOP_RESULT of the LOOP prediction algorithm is used as the final result.
[0029] S4. The result TAGE_RESULT of the TAGE prediction algorithm is taken as the final result.
[0030] like Figure 2 As shown, in this embodiment, the operation process of the TAGE prediction algorithm is as follows:
[0031] The TAGE predictor in this scheme is called Tagged Geometric length branch predictors. As shown in the figure below, the PC is used to perform hash operations with the history length registers L(1), L(2), L(3), and L(4) with bit widths of 7, 18, 47, and 122 respectively, and then addresses T1, T2, T3, and T4 to finally obtain the saturated counter result TAGE_RESULT.
[0032] like Figure 3 As shown, in this embodiment, the basic principle of the LOOP prediction algorithm is as follows:
[0033] The LOOP prediction algorithm includes a counter, loop threshold, and prediction direction. Count indicates the state of the branch instruction in this loop control, the limit field is the number of loops in the previous loop, and DIR indicates the opposite direction of the branch exit. When loop exit is detected, the count field overwrites the limit field, and at the same time, the count is initialized to 1. When count < limit, DIR is the branch prediction direction. When count = limit, the loop exits, and the opposite direction of DIR is used as the prediction result.
[0034] Among them, LHT (Loop History Table): loop prediction table, each item in the table contains 37 bits, which is used for loop prediction; INDEX_GEN: used to generate the index of the prediction table, its source is the result of XOR of different bits of the PC; TAG_GEN: used to generate the partial tag of the prediction table, its source is the result of XOR of different bits of the PC; LOOP_RESULT: determines whether to use the result of the LOOP predictor based on the hit information and the confidence of the hit item.
[0035] like Figure 4As shown, the operation process of the SF prediction algorithm in this embodiment is as follows:
[0036] Step 1: Get PC and generate the index field and partial tag of the FHT table;
[0037] Step 2: Find the prediction items and prediction information of the FHT table through the index;
[0038] Step 3: Use the partial tag and the read prediction item to determine whether the FHT hits, and then output the predicted direction and confidence based on the hit information.
[0039] Among them, FHT (Filter History Table): SF prediction table, each item in the table contains a 6-bit saturated counter and a 7-bit tag. The saturated counter is used to predict the branch direction, and the tag is used to determine whether it is a hit; INDEX_GEN: Use part of the PC field to generate an index; TAG_GEN: Use part of the PC field to compress and generate a tag; SF_ RESULT: Determine the hit based on the generated tag and the read tag. When the SF is hit, the predicted direction and the predictor strength attributes are output.
[0040] The arbitration method of the hybrid branch prediction algorithm of this embodiment provides a technical solution for selecting prediction results for the three prediction algorithms of conditional jump instructions, thereby achieving the purpose of improving the accuracy of processor branch prediction and solving the problem of processor performance degradation due to high branch prediction error rate.
[0041] The parts not involved in the present invention are the same as the prior art or can be implemented by using the prior art.
[0042] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as limiting the present invention itself. Various changes in form and details may be made without departing from the spirit and scope of the present invention as defined in the appended claims.
Claims
1. An arbitration method for a hybrid branch prediction algorithm, comprising the following steps: S1 and PC input three algorithm modules respectively, namely TAGE prediction algorithm, LOOP prediction algorithm and SF prediction algorithm. PC will obtain the result TAGE_RESULT of TAGE prediction algorithm, the result LOOP_RESULT of LOOP prediction algorithm and the result SF_RESULT of SF prediction algorithm. S2, PC determines whether the conditions for using the SF prediction result are met, if so, the final prediction result is SF_RESULT; if not, go to step S3; The judgment method is: increase the bit width of the saturation counter in the SF prediction algorithm to 6 bits; when the following three conditions are met at the same time, SF_RESULT is used as the final prediction result; The three conditions are: a. PC can address the corresponding item in the SF prediction algorithm; b. PC addresses the item in the SF prediction algorithm, and the saturation counter of the item has the upper 4 bits of 0 or 1, in which case the saturation counter result of the item is a strong attribute; c. PC addresses the item in the TAGE prediction algorithm, and the saturation counter result of the item is a non-strong attribute; S3, determine whether the value of the weight counter set inside the LOOP prediction algorithm is the maximum value. When the value of the weight counter is the maximum value, the final prediction result is LOOP_RESULT; if not, proceed to step S4; The judgment method is: set the weight counter to 4 bits. When the LOOP prediction algorithm exits the loop and finds that the prediction direction is correct after the corresponding instruction is executed, the value of the weight counter is increased by 1 as long as it is not the maximum value. When the PC can address the corresponding item in the LOOP prediction algorithm and the value of the weight counter of the item is the maximum value, the prediction result LOOP_RESULT of the LOOP prediction algorithm is used as the final result. S4. The result TAGE_RESULT of the TAGE prediction algorithm is taken as the final result.
Citation Information
Patent Citations
Hybrid branch prediction device and method for out-of-order high-performance cores
CN111078295A
New table item distribution method for TAGE branch predictor
CN113703846A
