CN112579166A - Method and device for determining skipping training identification of multi-stage branch predictor - Google Patents
Method and device for determining skipping training identification of multi-stage branch predictor Download PDFInfo
- Publication number
- CN112579166A CN112579166A CN202011461847.1A CN202011461847A CN112579166A CN 112579166 A CN112579166 A CN 112579166A CN 202011461847 A CN202011461847 A CN 202011461847A CN 112579166 A CN112579166 A CN 112579166A
- Authority
- CN
- China
- Prior art keywords
- branch predictor
- training
- branch
- prediction result
- skip
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000012549 training Methods 0.000 title claims abstract description 240
- 238000000034 method Methods 0.000 title claims abstract description 68
- 238000012937 correction Methods 0.000 claims description 73
- 230000008569 process Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 7
- 230000009191 jumping Effects 0.000 description 5
- 238000004891 communication Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 238000004590 computer program Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000002708 enhancing effect Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000000977 initiatory effect Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30094—Condition code generation, e.g. Carry, Zero flag
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Advance Control (AREA)
Abstract
The application provides a method and a device for determining a skip training identifier of a multi-level branch predictor. The method comprises the following steps: obtaining a first branch predictor in the multistage branch predictors to predict an instruction fetching address and/or a branch history to obtain an output result; wherein the output result comprises a first prediction result and a skip first training flag; obtaining a second prediction result obtained by predicting the fetch address and/or the branch history by the last-stage branch predictor; and determining a final skipping mark corresponding to the first branch predictor according to the similarity of the first prediction result and the second prediction result and the count of the difference of the predictions corresponding to the first branch predictor. According to the embodiment of the application, the judgment of whether the training is skipped is carried out according to the first predictor, so that when the first training is reverse training relative to the first branch predictor, the subsequent first branch predictor can still carry out the training, and the prediction precision of the branch predictor is improved.
Description
Technical Field
The application relates to the technical field of branch prediction, in particular to a method and a device for determining skip training identification of a multistage branch predictor.
Background
In computer architectures, a Branch predictor (Branch predictor) is a digital circuit that guesses which Branch will be executed before the Branch instruction executes to improve the performance of the instruction pipeline of the processor.
For the multi-stage branch predictor, the former stage branch predictor has lower precision and shorter delay compared with the latter stage branch predictor. In order to improve the prediction accuracy of the branch predictor, the working mode of the branch predictor can be divided into a prediction stage and a training stage. Training of the branch predictor is further divided into forward training for enhancing the state of the predictor and backward training for correcting the state of the predictor. Because the training occupies a production line and consumes power consumption, the training is divided into two types for the whole branch predictor, the last-stage predictor predicts correctly and performs first training, and the last-stage predictor predicts incorrectly and performs second training. Then for the first branch predictor, the training is divided into two categories: if the prediction is wrong, the training is called reverse training; if the prediction is correct, the training performed is forward training. The first training must be forward training for the last stage predictor, but it is possible for the first branch predictor to be forward training or backward training depending on whether the first branch predictor predicts correctly or not. Branch predictors typically skip forward training in order to reduce the number of training events, because the prediction is inherently right and not enhanced and will not cause a next prediction error. Reverse training is necessary, otherwise the next time there is an error. In the prior art, the prediction result of each branch predictor is not compared with the execution result so as to determine whether each branch predictor is in forward training or reverse training. But rather generates a skip first training flag based on the predicted state of each level of predictors.
Disclosure of Invention
An object of the embodiments of the present invention is to provide a method and an apparatus for determining a skip training flag of a multi-stage branch predictor, so as to improve the prediction accuracy of the branch predictor.
In a first aspect, an embodiment of the present application provides a method for determining a skip training flag of a multi-stage branch predictor, including: obtaining an output result of a first branch predictor in the multistage branch predictors for predicting an instruction fetching address and/or a branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not; acquiring a second prediction result of the last-level branch predictor for predicting the fetch address and/or the branch history; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not; correcting the skip mark corresponding to the first branch predictor according to the similarity of the first prediction result and the second prediction result and the count of the difference of the predictions corresponding to the first branch predictor to obtain a final skip mark; wherein the prediction-distinct count is a number of times that the first prediction result differs from a branch execution result of the execution unit.
According to the embodiment of the application, whether the first branch predictor skips the training is finally determined according to the output result, the second prediction result and the prediction difference count, and the judgment of whether the training is skipped is not only carried out according to the first predictor, so that when the first training is reverse training relative to the first branch predictor, the subsequent first branch predictor can still carry out the training, and the prediction precision of the branch predictor is improved.
Further, after obtaining the final skip identity, the method further comprises: writing the final skip flag into a prediction state table; the prediction state table comprises an instruction fetching address and/or a branch history, a prediction result of a last-stage branch predictor on the instruction fetching address and/or the branch history, and final skipping marks corresponding to branch predictors before the last-stage branch predictor respectively.
According to the embodiment of the application, the obtained final skipping mark is written into the prediction state table, so that each stage of branch predictor can rapidly know whether skipping training is needed or not according to the prediction state table.
Further, the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag includes: and if the first prediction result is different from the second prediction result, the skipping mark is a mark representing skipping training, and the numerical value of the counting with different predictions is larger than a preset threshold value, determining that the final skipping mark is a mark representing not skipping training.
The embodiment of the application determines whether to skip training by predicting the numerical values of the different counts, and the numerical values of the different counts are used for representing the reliability of correcting the first prediction result, namely when the numerical values of the different counts are larger, the prediction of the branch predictor is more inaccurate, and the first branch predictor needs to be corrected. Thus, whether to set the first branch predictor to skip training may be determined according to the value of the count of prediction dissimilarity.
Further, the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag includes: and if the first prediction result is the same as the second prediction result or the skip mark is a mark representing non-skip training, determining the skip mark as the final skip mark.
In the embodiment of the application, after the first branch predictor predicts the skip mark, the final skip mark is determined according to the second prediction result of the last-stage branch predictor and the count of the difference of the predictions of the first branch predictor, so that the first branch predictor can still be trained when the first training is reverse training in the future.
Further, the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag includes: and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the count of the first branch predictor corresponding to the fetch address and/or the branch history is different is default, determining that the skip mark is the final skip mark.
If the count that the predictions corresponding to the instruction fetching address and/or the branch history are different is not included, the instruction fetching address and/or the branch history are the first predictions of the multi-level branch predictor, and in order to obtain the final skip identifier corresponding to the first branch predictor, the skip identifier predicted by the first branch predictor is used as the final skip identifier. It is to be understood that the count of prediction dissimilarity may be recorded by using a table, and the table may be stored in the first branch predictor or may be stored outside the first branch predictor, and the storage location of the table is not particularly limited in the embodiment of the present application.
Further, the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag includes: and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value corresponding to the count with different predictions is not greater than a preset threshold value, determining that the skip mark is the final skip mark.
In this embodiment of the present application, when the predicted number of the dissimilar counts is not greater than the preset threshold, it indicates that the first branch predictor does not need to correct, and therefore, the final skip flag is determined according to the skip flag output by the first branch predictor.
Further, a correction table is included in the first branch predictor, the correction table including counts for which the predictions are different, and the method further includes: and if the skip identifier is an identifier representing skip training, determining whether to update the correction table according to the first prediction result, the second prediction result and the count of the correction table with different predictions. Thereby enabling the correction table to correctly characterize whether the skip flag output by the first branch predictor needs to be corrected.
Further, the determining whether to update the correction table according to the first prediction result, the second prediction result, and the count of the difference in predictions among the correction tables includes: and if the first prediction result is the same as the second prediction result, not updating the correction table.
Further, the determining whether to update the correction table according to the first prediction result, the second prediction result, and the count of the difference in prediction in the correction table further includes: and if the first prediction result is different from the second prediction result and the counts of the different predictions corresponding to the fetch address and/or the branch history in the correction table are default, creating the counts of the different predictions corresponding to the fetch address and/or the branch history in the correction table. Thereby making it possible to determine whether or not the skip flag output from the first branch predictor needs to be corrected by the correction table.
Further, the determining whether to update the correction table according to the first prediction result, the second prediction result, and the count of the difference in predictions among the correction tables includes: if the first prediction result is different from the second prediction result, and the count value with the different predictions in the correction table is not larger than a preset threshold value, updating the count value to increase the updated count value; and if the numerical value of the count is larger than a preset threshold value, resetting the count. If the first prediction result is different from the second prediction result, the skip flag output by the first branch predictor needs to be corrected according to the count value in the correction table, so as to ensure that the count value is correct.
Further, after determining the final skip flag corresponding to the first branch predictor, the method further includes: the first branch predictor receives a training instruction, the training instruction is generated by the branch predictor according to a second prediction result and a branch execution result of the execution unit, and the training instruction comprises a training category; and the first branch predictor determines whether to execute the training instruction according to the corresponding final skipping identification and the training class.
According to the embodiment of the application, the precision of the branch predictor is improved by training the branch predictors at all levels.
Further, the determining, by the first branch predictor, whether to execute the training instruction according to the corresponding final skip flag and the training class includes: if the final skipping mark is a mark representing that the training is not skipped and the training type is first training, the first branch predictor performs first training according to the training instruction; and if the final skipping mark is a mark representing skipping training and the training type is first training, not executing the training instruction. According to the embodiment of the application, whether the branch predictor skips the first training or not is determined according to the final skipping mark, so that on one hand, the power consumption is reduced, and on the other hand, the prediction precision of the branch predictor is ensured.
In a second aspect, an embodiment of the present application provides an apparatus for determining a skip training flag of a multi-stage branch predictor, including: the first result obtaining module is used for obtaining the output result of the prediction of the first branch predictor in the multistage branch predictors on the fetch address and/or the branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not; the second result obtaining module is used for obtaining a second prediction result of the last-stage branch predictor for predicting the fetch address and/or the branch history; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not; a skip mark determining module, configured to correct the skip mark corresponding to the first branch predictor according to similarities and differences between the first prediction result and the second prediction result and a count indicating that predictions corresponding to the first branch predictor are different, so as to obtain a final skip mark; wherein the prediction-distinct count is a number of times that the first prediction result differs from a branch execution result of the execution unit.
In a third aspect, an embodiment of the present application provides a multi-stage branch predictor, including: a first branch predictor of the multi-level branch predictors being for use in the method of the first aspect; wherein the first branch predictor is any branch predictor before the last branch predictor in the multistage branch predictors.
In a fourth aspect, an embodiment of the present application provides a processor including the multi-stage branch predictor described in the third aspect.
In a fifth aspect, an embodiment of the present application provides an electronic device, including the processor, the memory, and a bus of the fourth aspect, where the processor and the memory complete communication with each other through the bus; the memory stores program instructions executable by the processor, the processor invoking the method of the first aspect.
In a sixth aspect, embodiments of the present application provide a non-transitory computer-readable storage medium, comprising: the non-transitory computer readable storage medium stores computer instructions that cause the computer to perform the method of the first aspect.
Additional features and advantages of the present application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the embodiments of the present application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic structural diagram of a cpu provided in a comparison scheme;
FIG. 2 is a flow chart of training branch predictors in a comparison scheme;
FIG. 3 is a flowchart illustrating a training flag determination method for a multi-stage branch predictor according to an embodiment of the present disclosure;
FIG. 4 is a flowchart illustrating a training flag determination method for a multi-stage branch predictor according to an embodiment of the present disclosure;
fig. 5 is a flowchart of a method for obtaining a final skip flag according to an embodiment of the present disclosure;
fig. 6 is a schematic flow chart illustrating a determination process of whether to update a correction table according to an embodiment of the present application;
FIG. 7 is a schematic structural diagram of a training flag determining apparatus of a multi-stage branch predictor according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Instruction pipelining is the manner in which the operation of an instruction is divided into a number of tiny steps, each of which is performed by specialized circuitry, in order to increase the efficiency with which the processor executes the instruction. A common six-stage pipeline divides the processing procedure of an instruction stream into several serially processed process sections of instruction Fetching (FI), Decoding (DI), operand address Calculation (CO), operand Fetching (FO), instruction Execution (EI), operand Writing (WO), and the like. This is the instruction 6 stage pipeline timing. In the pipeline, the processor has six operation units, and each operation unit can simultaneously process different instructions, so that the execution speed of the program is increased. Instruction pipelines are employed by almost all high performance computers.
A problem encountered when processors incorporating pipelining process branch instructions is that depending on the true/false of the decision condition, a jump may occur which interrupts the processing of the instruction in the pipeline because the processor cannot determine the next instruction to the instruction until the branch is taken. The longer the pipeline, the longer the processor will wait because it must wait for the branch instruction to finish before determining the next instruction to enter the pipeline. Branch prediction techniques have been developed to address this problem. Branch prediction techniques include static branch prediction performed at compile time and dynamic branch prediction performed by hardware at execution time.
To implement branch prediction, branch predictors come into play. Fig. 1 is a block diagram of a cpu, and as shown in fig. 1, a branch predictor 101 issues a predicted instruction fetch request, and an instruction fetch unit 102 fetches an instruction and passes it to a subsequent decode/execute unit 103. The instruction fetch unit 102 itself accesses the instruction cache, the execution unit 103 accesses the data cache (the above figure is combined into one cache module 104), and the cache module 104 is connected to the memory 105.
The branch predictor 101 is configured to predict the direction of a branch and a target address (prediction result) in advance when a branch instruction exists, and generate a predicted instruction fetch request. While the actual execution of the branch instruction is the execution unit after decode, later than the prediction and fetch. The execution unit generates an execution result of the branch, the execution result is compared with a final prediction result of the branch predictor, if the execution result is consistent with the final prediction result, no correction instruction exists, and the branch predictor performs first training; if not, a correction instruction is sent to the branch predictor, and second training is carried out. For the last stage of branch predictor in the multi-stage branch predictor, the first training is forward training and the second training is backward training, but for the previous branch predictor, if the stage of branch predictor predicts correctly, the first training is forward training, and if the stage of branch predictor predicts incorrectly, the first training is backward training. The purpose of forward training is to bring the counter value corresponding to the branch predictor closer to the value corresponding to the highest confidence of correct prediction. The purpose of the reverse training is to move the value of the counter corresponding to the branch predictor away from the highest confidence level of the wrong prediction and close to the highest confidence level of the correct result.
Fig. 2 is a flow chart of training branch predictors in the comparison scheme, wherein the branch predictors have N stages, and the branch predictors maintain a prediction state table which is used as an information medium for a prediction stage and a training stage, as shown in fig. 2. For example, whether the prediction result of the first branch predictor reaches the condition of skipping the first training or not has a corresponding record in the prediction state table. The state is set in a prediction stage, namely in the prediction stage, after the prediction of an instruction fetch address and/or a branch history is completed, the instruction fetch address and/or the branch history and the prediction result of the corresponding last-stage branch predictor are input into a corresponding row, each-stage branch predictor judges whether the branch predictor meets the condition of skipping first training or not according to the prediction result, and if the branch predictor meets the condition, the corresponding branch predictor is set as an identifier for skipping first training; otherwise, the corresponding branch predictor is set not to skip the first trained flag. And in the subsequent training process, determining whether to train or not according to the prediction state table.
Table 1 shows the results obtained according to the training procedure of fig. 1, as shown in table 1:
TABLE 1
As can be seen from the first row of table 1, the first branch predictor predicts incorrectly, the last-stage branch predictor predicts correctly, and since the last-stage branch predictor predicts correctly, whether the first training or the second training is initiated is only related to whether the result of the last-stage predictor is correct or not, so that if the last-stage predictor is correct and the first branch predictor reaches the condition of skipping the first training in the prediction stage, the first branch predictor cannot be trained/corrected even if the first branch predictor is incorrect. This will cause a problem that the prediction accuracy of the first branch predictor is low.
In order to solve the above technical problem, an embodiment of the present application provides a method for determining a skip training flag of a multi-stage branch predictor, as shown in fig. 3, where the method includes:
step 301: obtaining an output result of a first branch predictor in the multistage branch predictors for predicting an instruction fetching address and/or a branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not.
The instruction fetch address can be stored in an instruction fetch register, the instruction fetch register can sequentially send the instruction fetch address to each stage of branch predictors, the branch history can be stored in a branch history register, and the branch history register can also send the branch history to each stage of branch predictors. Each level of branch predictor predicts the fetch address and/or the branch history after receiving the fetch address and/or the branch history.
The first prediction result is used for representing whether the first branch predictor predicts whether to jump or not; after receiving the instruction fetch address and/or the branch history, each stage of branch predictor predicts the instruction fetch address and/or the branch history to obtain a corresponding first prediction result. For convenience of presentation, any branch predictor preceding the last-level branch predictor in the multi-level branch predictor is referred to as a first branch predictor. If the next instruction fetching address predicted by the first branch predictor is the same as the next instruction fetching address calculated by the execution unit, the first branch predictor predicts correctly; conversely, if the next fetch address predicted by the first branch predictor is not the same as the next fetch address calculated by the execution unit, the first branch predictor predicts an error.
Step 302: obtaining a second prediction result obtained by predicting the fetch address and/or the branch history by the last-stage branch predictor; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not.
And after the last-stage branch predictor receives the instruction fetch address and/or the branch history, predicting the instruction fetch address and/or the branch history to obtain a second prediction result. The second prediction result is similar to the first prediction result and is used for indicating whether the last-stage branch predictor predicts whether to jump or not. If the next instruction fetch address predicted by the Nth level branch predictor is the same as the real instruction fetch address, the last level branch predictor predicts correctly, and if the next instruction fetch address predicted by the last level branch predictor is not the same as the real instruction fetch address, the last level branch predictor predicts incorrectly.
Step 304: correcting the skipping mark corresponding to the first branch predictor according to the similarity of the first prediction result and the second prediction result and the count of the difference of the predictions corresponding to the first branch predictor to obtain a final skipping mark; wherein the count of prediction dissimilarity refers to the number of times the first prediction result is different from the second prediction result.
In a specific implementation process, if the first prediction result is skip and the second prediction result is not skip, the first prediction is different; if the first prediction result is not jumping, the second prediction result is jumping, which is also called a primary prediction difference. Predicting the numerical values of the different counts to represent the reliability of correcting the result of whether the training is skipped or not, wherein the larger the numerical value of the count is, the more the first branch predictor needs to correct/train; conversely, a smaller value of the count indicates that the first branch predictor is less likely to need correction/training. It should be understood that the value of the count and whether the count needs to be corrected are preset, or the smaller the count value is, the less the first branch predictor needs to be corrected/trained; the larger the number of counts, the more correction/training the first branch predictor needs to be.
And finally determining a final skipping mark corresponding to the first branch predictor by combining the counts with different predictions corresponding to the first branch predictor after obtaining the output result of the first branch predictor and the second prediction result corresponding to the last-stage predictor. It is understood that the final skip flag is a flag corresponding to the first branch predictor as to whether training is to be finally skipped. Numerical representations may be employed, such as: "0" indicates no skip training and "1" indicates skip training. It is to be understood that the training refers to the fact that the last-stage branch predictor is initiated by the branch predictor in case the prediction is correct.
According to the embodiment of the application, whether the first branch predictor skips the training is finally determined according to the output result, the second prediction result and the prediction difference count, and the judgment of whether the training is skipped is not only carried out according to the first predictor, so that when the first training is reverse training relative to the first branch predictor, the subsequent first branch predictor can still carry out the training, and the prediction precision of the branch predictor is improved.
On the basis of the above embodiment, after obtaining the final skip flag, the method further includes:
writing the final skip flag into a prediction state table; the prediction state table comprises an instruction fetching address and/or a branch history, a prediction result of the last-stage branch predictor on the instruction fetching address, and final skipping marks corresponding to branch predictors before the last-stage branch predictor respectively.
In a specific implementation process, a prediction state table is also maintained in the prediction unit, and the prediction state table is shown in table 2:
TABLE 2
The state prediction table comprises addresses and/or branch histories (not shown in table 2), prediction results, and whether training is skipped by the first branch predictor; the address refers to an instruction fetching address received by the branch predictor, and the prediction result is the prediction result of the last-stage branch predictor. It will be appreciated that other parameter information may also be included in the prediction state table, such as: the prediction result of the first branch predictor, etc., the embodiment of the present application does not specifically limit specific parameters in the prediction state table. Whether the first branch predictor skips the first training is obtained by the method for obtaining the final skip flag in the above embodiment.
When the first branch predictor receives the instruction fetch address and/or the branch history and predicts the instruction fetch address and/or the branch history, the prediction result and whether each stage of branch predictor skips training and is written into the prediction state table. Therefore, the content in the prediction state table is generated in the prediction stage, and in the training stage, the prediction state table needs to be used to determine whether the first branch predictor skips the training.
Fig. 4 is a flowchart illustrating another method for determining skip training flags of multi-stage branch predictors according to an embodiment of the present application, where as shown in fig. 4, only correction tables corresponding to first branch predictors are shown, and in practical applications, each first branch predictor has a corresponding correction table. After receiving the instruction fetch address and/or the branch history, the first branch predictor predicts the instruction fetch address and/or the branch history to obtain a first prediction result and a skip identifier, and similarly, the last-stage branch predictor also predicts the received instruction fetch address and/or the branch history to obtain a second prediction result; the first branch predictor reads a corresponding counting value from the correction table according to the instruction fetching address and/or the branch history; and the judgment logic judges according to the first prediction result, the second prediction result and the reading result of the correction table to finally obtain the final skipping mark, and writes the final skipping mark into the prediction state table.
According to the embodiment of the application, the obtained final skipping mark is written into the prediction state table, so that each stage of branch predictor can rapidly know whether the first training needs to be skipped according to the prediction state table.
On the basis of the above embodiment, the decision logic for obtaining the final skip flag may include multiple types, as shown in fig. 5, and the following describes various decision logics respectively:
(1) the determining a final skip identifier corresponding to the first branch predictor according to the similarities and differences between the first prediction result and the second prediction result and the count of the differences of the predictions corresponding to the first branch predictor includes:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value of the counting with different predictions is larger than a preset threshold value, determining that the final skip mark is a mark representing no skip training.
In a specific implementation process, step 501: when the final skip mark is determined, whether a first prediction result output by the first branch predictor is the same as a second prediction result output by the last-stage branch predictor is judged, namely whether the first prediction result and the second prediction result are both predicted jumps or both predicted jumps and not jumps are judged. If the results are different, it indicates that the first prediction result is wrong, step 502 is executed; step 502: the skipping mark output by the first branch predictor is a mark for representing skipping training; the first predictor outputs a skip flag, which may be a flag indicating skip training or a flag indicating no skip training. If the skip flag is a flag representing skip training, execute step 503; step 503: judging whether the first branch predictor comprises counts of different predictions corresponding to the fetch address and/or the branch history, and if so, executing step 504; step 504: acquiring a counted value corresponding to the fetch address and/or the branch history, judging whether the counted value is greater than a preset threshold, and if so, executing step 505, wherein the reliability that the first branch predictor needs to be corrected is high; step 505: the final skip flag is set to a flag characterizing no skip training. It is understood that the specific value of the preset threshold can be set according to actual conditions.
The embodiment of the application determines whether to skip training by predicting the numerical values of the different counts, and the numerical values of the counts are used for representing the reliability of correcting the first prediction result, namely when the numerical value of the counter is larger, the prediction of the first branch predictor is more inaccurate, and the first branch predictor needs to be corrected. Therefore, whether to set the first branch predictor to skip training may be determined according to the value of the count.
(2) The correcting the skip identifier corresponding to the first branch predictor according to the similarities and differences between the first prediction result and the second prediction result and the count of the differences of the predictions corresponding to the first branch predictor to obtain a final skip identifier includes:
and if the first prediction result is the same as the second prediction result or the skip mark is a mark representing non-skip training, determining the skip mark as the final skip mark.
In a specific implementation process, in a prediction stage of predicting an instruction fetch address and/or a branch history, the first branch predictor judges whether a condition of skipping training is met according to a preset rule, and outputs a first skipping training identifier. The preset rule may be that the prediction accuracy of the first branch predictor satisfies a threshold, and if the prediction accuracy satisfies the threshold, the skip flag output by the first branch predictor is a flag representing skip training, otherwise, the skip flag is output. Similarly, the skip flag may be represented by "0" or "1", i.e., "0" indicates that training is not skipped and "1" indicates that training is skipped.
Step 501: judging whether the first prediction result is the same as the second prediction result or not, or the skipping flag is a flag representing that training is not skipped, if the first prediction result is the same as the second prediction result, namely the first prediction result and the second prediction result are both predicted skipping or both predicted skipping and not skipped, executing step 506; if the skip flag outputted by the first branch predictor is a flag indicating not to skip training, execute step 506; step 506: and determining a final skip mark according to the skip mark output by the first branch predictor.
In the embodiment of the application, after the first branch predictor predicts whether to skip the training, the final skipping mark is determined according to the second prediction result of the last-stage branch predictor and the count of the difference of the predictions of the first branch predictor, so that the first branch predictor can still be trained when the first training is reverse training in the future.
(3) The correcting the skip identifier corresponding to the first branch predictor according to the similarities and differences between the first prediction result and the second prediction result and the count of the differences of the predictions corresponding to the first branch predictor to obtain a final skip identifier further includes:
and if the first prediction result is different from the second prediction result, the skip first training identifier is an identifier representing skip training and does not include a count of different predictions corresponding to the fetch address in the first branch predictor, determining that the skip identifier is the final skip identifier.
In a specific implementation process, step 501: judging whether the first prediction result is the same as the second prediction result, if the first prediction result is different from the second prediction result, namely one of the first prediction result and the second prediction result is predicted to jump, and the other one is predicted not to jump, executing step 502; step 502: the skipping mark output by the first branch predictor is a mark for representing skipping training; the first predictor outputs a skip flag, which may be a flag indicating skip training or a flag indicating no skip training. If the skip flag is a flag representing skip training, execute step 503; step 503: whether the first branch predictor contains the count of the difference of the predictions corresponding to the corresponding fetch address and/or the branch history is judged, if not, the fetch address and/or the branch history are shown to be the first occurrence, and only the skip identifier output by the first branch predictor is taken as the final skip identifier, namely step 506 is executed.
(4) The determining a final skip identifier corresponding to the first branch predictor according to the similarities and differences between the first prediction result and the second prediction result and the count of the differences of the predictions corresponding to the first branch predictor further includes:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value corresponding to the count with different predictions is not greater than a preset threshold value, determining that the skip mark is the final skip mark.
In a specific implementation process, step 501: and judging whether the first prediction result and the second prediction result are the same, namely whether the first prediction result and the second prediction result are both predicted jumps or both predicted jumps and not jumped. If the results are different, go to step 502; step 502: the skipping mark output by the first branch predictor is a mark for representing skipping training; the first predictor outputs a skip flag, which may be a flag indicating skip training or a flag indicating no skip training. If the skip flag is a flag representing skip training, execute step 503; step 503: judging whether the first branch predictor comprises counts of different predictions corresponding to the fetch address and/or the branch history, if so, obtaining the counts of different predictions corresponding to the fetch address and/or the branch history, and executing step 504; step 504: judging whether the numerical values of the predicted dissimilar counts are larger than a preset threshold value, if not, indicating that the skip marks output by the first branch predictor do not need to be corrected, and executing step 505; step 505: the skip flag output by the first branch predictor may be used as the final skip flag.
On the basis of the above embodiment, the first branch predictor includes a correction table, the correction table includes counts of the predictions being different, and the correction table may be a Cache (Cache) -like set-associative structure, i.e. a part of the address is used as index, and then another part of the address is used as tag for comparison; or index with one hash of the address and then compare with another hash of the address as tag. Whether the correction table needs to be updated can also be determined according to the first prediction result, the second prediction result, and whether the first branch predictor includes the count with the different predictions, fig. 6 is a schematic diagram of a determination process of whether the correction table needs to be updated according to the embodiment of the present application, as shown in fig. 6:
step 601: judging whether the first prediction result is the same as the second prediction result; the correction table is accessed or updated when the skip flag is a flag characterizing skip training. Judging whether the correction table needs to be updated, judging whether the first prediction result is the same as the second prediction result, and if the first prediction result is the same as the second prediction result, executing step 602; otherwise, go to step 603;
step 602: the correction table is not updated;
step 603: whether the correction table hits; judging whether the correction table contains address information corresponding to the fetch address and/or the branch history, wherein the address information can be the fetch address and/or the branch history, can also be obtained by performing hash operation on the fetch address and/or the branch history, and can also be some bits in the fetch address and/or the branch history, and the fetch address is an address corresponding to the first prediction result and the second prediction result; if the counts of the difference between the predictions corresponding to the fetch address and/or the branch history in the correction table are default, that is, the correction table does not contain the fetch address and/or the address information corresponding to the branch history, it indicates that the fetch address is the first time the branch predictor predicts, and the address information corresponding to the fetch address and/or the branch history needs to be written into the correction table, that is, step 604 is executed; if the correction table contains the fetch address and/or the address information corresponding to the branch history, go to step 605;
step 604: creating a correction table entry, and resetting the count; and writing the address information corresponding to the fetch address and/or the branch history and the corresponding count as a table entry into a correction table, and resetting the numerical value corresponding to the count. It will be appreciated that resetting the value may be setting the value of the count to 0;
step 605: whether the counted number of the correction table is greater than a threshold value; obtaining a count corresponding to the fetch address and/or the branch history from the correction table, and determining whether a value corresponding to the count is greater than a preset threshold, where it can be understood that the counted value is used to represent a reliability of correcting the skip flag output by the first branch predictor, and therefore, when the first prediction result is different from the second prediction result and the counted value is greater than the preset threshold, it indicates that the result of determining that the skip flag is finally corrected at this time, and since correction has been performed once currently, the count is reset. It is possible that this correction will solve the problem. If the problem is not solved, then retraining is carried out later, and after the condition is met, the training is corrected again, and step 606 is executed; in the case that the first prediction result is not the same as the second prediction result, and the counted value is not greater than the preset threshold, it indicates that the event that the first branch predictor and the last branch predictor have different results occurs several times, but the threshold giving the "correction" indication has not been reached yet. The count is increased to enhance the reliability of "correction", and the more times the result is different, the more correction is required, and step 607 is executed;
step 606: resetting the count; it can be understood that, in addition to resetting the count, the embodiment of the present application may also perform a subtraction operation on the count to reduce the count below the threshold;
step 607: the count is incremented; the number corresponding to the count may be increased by 1 or 2 in addition to the original number of the count, and the number may be increased according to a preset number.
According to the embodiment of the application, the correction table can correctly represent whether the skip identification output by the first branch predictor needs to be corrected or not by updating the correction table.
On the basis of the above embodiment, after determining the final skip identifier corresponding to the first branch predictor, the method further includes:
the first branch predictor receives a training instruction, the training instruction is generated by the branch predictor according to a second prediction result and a branch execution result of the execution unit, and the training instruction comprises a training category;
and the first branch predictor determines whether to execute the training instruction according to the corresponding final skipping identification and the training class.
In a specific implementation, after the last-level branch predictor completes prediction of the fetch address and/or the branch history, the branch predictor determines a training instruction according to the branch execution result of the execution unit, for example: if the second prediction result corresponding to the last-stage branch predictor is the same as the branch execution result of the execution unit, initiating a first training; and if the second prediction result of the last-stage branch predictor is not the same as the branch execution result of the execution unit, the branch predictor initiates a second training. It will be appreciated that the training instructions comprise a training class, i.e. a first training or a second training, the first training being a forward training and the second training being a reverse training for the last-stage branch predictor.
And when the first branch predictor receives a training instruction, determining whether to execute the training instruction according to the final skipping mark and the training category, and determining whether to execute forward training or reverse training.
The method specifically comprises the following steps: after the first branch predictor receives a training instruction initiated by the branch predictor, if the training instruction is used for performing first training and the final skipping mark is a mark representing that the first training is not skipped, the first branch predictor performs corresponding training, and if the training instruction is used for performing the first training and the final skipping mark is a mark representing that the first training is skipped, the first branch predictor does not perform training.
It is to be understood that the first branch predictor may retrieve the final skip flag from the prediction state table. The branch predictor may be comprised of counters, each prediction using a counter read from the predictor using the fetch address and/or branch history. The corresponding numerical value of the counter can be positive or negative, positive numbers can indicate skipping, and negative numbers indicate not skipping; if the numerical value of the counter is positive, the greater the numerical value is, the higher the reliability of the jump is; if the value of the counter is negative, and the smaller the value is, the higher the reliability of not jumping is. The purpose of forward training is to make the absolute value of the register value larger, and the purpose of reverse training is to make the absolute value of the counter value smaller. It should be noted that, the representation of jump and not jump by positive and negative numbers is only an example, the branch prediction divides the value range corresponding to the counter into two intervals, namely [ jump highest confidence level, jump lowest confidence level ] and [ not jump lowest confidence level, not jump highest confidence level ], taking the counters as [4,0] and [ -1, -4] as examples, if the actual execution is jump, it is said that 4 is the highest confidence level of correct prediction, and-4 is the highest confidence level of incorrect prediction; if the prediction does not jump, then-4 bits of highest confidence for correct prediction, 4 bits of highest confidence for incorrect prediction.
It should be noted that the above interval division is not necessarily marked by positive and negative signs, and may also be [0,4] and [5,8], where 0 and 8 respectively represent the highest confidence level of jumping/not jumping.
According to the embodiment of the application, whether the branch predictor skips the first training or not is determined according to the final skipping mark, so that on one hand, the power consumption is reduced, and on the other hand, the prediction precision of the branch predictor is ensured.
Fig. 7 is a schematic structural diagram of an apparatus for determining a skip training flag of a multi-stage branch predictor according to an embodiment of the present disclosure, where the apparatus may be a module on an electronic device. It should be understood that the apparatus corresponds to the above-mentioned embodiment of the method of fig. 3, and can perform various steps related to the embodiment of the method of fig. 3, and the specific functions of the apparatus can be referred to the above description, and the detailed description is appropriately omitted here to avoid redundancy. The device includes: a first result obtaining module 701, a second result obtaining module 702, and a skip flag determining module 703, wherein:
the first result obtaining module 701 is configured to obtain an output result of a first branch predictor in the multi-stage branch predictors for predicting an instruction fetch address and/or a branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not; a second result obtaining module 702 is configured to obtain a second prediction result of the last-stage branch predictor for predicting the fetch address and/or the branch history; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not; the skip identifier determining module 703 is configured to correct the skip identifier corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor, so as to obtain a final skip identifier; wherein the prediction-distinct count is a number of times that the first prediction result differs from a branch execution result of the execution unit.
On the basis of the above embodiment, the apparatus further includes a status writing module configured to:
writing the final skip flag into a prediction state table; the prediction state table comprises an instruction fetching address and/or a branch history, a prediction result of a last-stage branch predictor on the instruction fetching address, and final skipping marks corresponding to branch predictors before the last-stage branch predictor respectively.
On the basis of the foregoing embodiment, the skip identification determining module 703 is specifically configured to:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value of the count of the prediction error is larger than a preset threshold, determining that the final skip mark is a mark representing no skip training.
On the basis of the foregoing embodiment, the skip identification determining module 703 is further configured to:
and if the first prediction result is the same as the second prediction result or the skip mark is a mark representing non-skip training, determining the skip mark as the final skip mark.
On the basis of the foregoing embodiment, the skip identification determining module 703 is further configured to:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training and does not include a count of different predictions corresponding to the fetch address in the first branch predictor, determining that the skip mark is the final skip mark.
On the basis of the foregoing embodiment, the skip identification determining module 703 is further configured to:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value of the predicted dissimilar count is not greater than a preset threshold value, determining that the skip mark is the final skip mark.
On the basis of the foregoing embodiment, the first branch predictor includes a correction table, where the correction table includes counts of the predictions that are different, and the apparatus further includes an updating module configured to:
and if the skip identifier is an identifier representing skip training, determining whether to update the correction table according to the first prediction result, the second prediction result and the count of the correction table with different predictions.
On the basis of the above embodiment, the update module is specifically configured to:
and if the first prediction result is the same as the second prediction result, not updating the correction table.
On the basis of the foregoing embodiment, the update module is further configured to:
if the first prediction result is different from the second prediction result and the correction table does not include the count of the prediction difference corresponding to the fetch address and/or the branch history, the count of the prediction difference corresponding to the fetch address and/or the branch history is created in the correction table.
On the basis of the foregoing embodiment, the update module is further configured to:
if the first prediction result is different from the second prediction result, and the correction table includes that the numerical values of the counts with different predictions corresponding to the fetch address and/or the branch history are not larger than a preset threshold value, updating the numerical values of the counts to increase the numerical values of the updated counts;
and if the counted numerical value is larger than a preset threshold value, resetting the count.
On the basis of the above embodiment, the apparatus further includes a training module configured to:
the first branch predictor receives a training instruction, the training instruction is generated by the branch predictor according to a second prediction result and a branch execution result of the execution unit, and the training instruction comprises a training category;
and the first branch predictor determines whether to execute the training instruction according to the corresponding final skipping identification and the training class.
On the basis of the above embodiment, the training module is specifically configured to:
if the final skipping mark is a mark representing that the training is not skipped and the training type is first training, the first branch predictor performs first training according to the training instruction;
and if the final skipping mark is a mark representing skipping training and the training type is first training, not executing the training instruction.
The embodiment of the present application further provides a multi-level branch predictor, where a first branch predictor in the multi-level branch predictor is configured to perform the method described in the foregoing embodiment; wherein the first branch predictor is any branch predictor before the last branch predictor in the multistage branch predictors.
Fig. 8 is a schematic structural diagram of an entity of an electronic device provided in an embodiment of the present application, and as shown in fig. 8, the electronic device includes: a processor (processor)801, a memory (memory)802, and a bus 803; wherein,
the processor 801 and the memory 802 communicate with each other via the bus 803;
the multi-stage branch predictor in the processor 801 is configured to call program instructions in the memory 802 to perform the methods provided by the above-described method embodiments, including, for example: obtaining an output result of a first branch predictor in the multistage branch predictors for predicting an instruction fetching address and/or a branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not; acquiring a second prediction result of the last-level branch predictor for predicting the fetch address and/or the branch history; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not; correcting the skip mark corresponding to the first branch predictor according to the similarity of the first prediction result and the second prediction result and the count of the difference of the predictions corresponding to the first branch predictor to obtain a final skip mark; wherein the second prediction result is correct, that is, the second prediction result is the same as a branch execution result of the execution unit; the prediction-distinct count is the number of times the first prediction outcome differs from the branch execution outcome of the execution unit.
The processor 801 may be an integrated circuit chip having signal processing capabilities. The Processor 801 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. Which may implement or perform the various methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The Memory 802 may include, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read Only Memory (PROM), Erasable Read Only Memory (EPROM), Electrically Erasable Read Only Memory (EEPROM), and the like.
The present embodiments disclose a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the methods provided by the above-described method embodiments.
The present embodiments provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the methods provided by the method embodiments described above.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims (17)
1. A method for determining skip training flags for a multi-level branch predictor, the method comprising:
obtaining an output result of a first branch predictor in the multistage branch predictors for predicting an instruction fetching address and/or a branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not;
acquiring a second prediction result of the last-level branch predictor for predicting the fetch address and/or the branch history; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not;
correcting the skip mark corresponding to the first branch predictor according to the similarity of the first prediction result and the second prediction result and the count of the difference of the predictions corresponding to the first branch predictor to obtain a final skip mark; wherein the count of prediction dissimilarity refers to the number of times the first prediction result is different from the second prediction result.
2. The method of claim 1, wherein after obtaining the final skip identity, the method further comprises:
writing the final skip flag into a prediction state table; the prediction state table comprises an instruction fetching address and/or a branch history, a prediction result of a last-stage branch predictor on the instruction fetching address and/or the branch history, and final skipping marks corresponding to branch predictors before the last-stage branch predictor respectively.
3. The method of claim 1, wherein the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag comprises:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value of the predicted different counts is greater than a preset threshold value, determining that the final skip mark is a mark representing no skip training.
4. The method of claim 1, wherein the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag comprises:
and if the first prediction result is the same as the second prediction result or the skip mark is a mark representing non-skip training, determining the skip mark as the final skip mark.
5. The method of claim 1, wherein the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag comprises:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the count of the first branch predictor corresponding to the fetch address and/or the branch history is different is default, determining that the skip mark is the final skip mark.
6. The method of claim 1, wherein the modifying the skip flag corresponding to the first branch predictor according to the similarity between the first prediction result and the second prediction result and the count of the difference between the predictions corresponding to the first branch predictor to obtain a final skip flag comprises:
and if the first prediction result is different from the second prediction result, the skip mark is a mark representing skip training, and the numerical value corresponding to the count with different predictions is not greater than a preset threshold value, determining that the skip mark is the final skip mark.
7. The method of claim 1, wherein a correction table is included in the first branch predictor, the correction table including counts for which the predictions differ, the method further comprising:
and if the skip mark is a mark representing skip training, determining whether to update the correction table according to the first prediction result, the second prediction result and the count of different predictions in the correction table.
8. The method of claim 7, wherein determining whether to update the correction table based on the first prediction, the second prediction, and a count of differences in corresponding predictions in the correction table comprises:
and if the first prediction result is the same as the second prediction result, not updating the correction table.
9. The method of claim 7, wherein determining whether to update the correction table based on the first prediction, the second prediction, and a count of differences in corresponding predictions in the correction table comprises:
and if the first prediction result is different from the second prediction result and the counts of the different predictions corresponding to the fetch address and/or the branch history in the correction table are default, creating the counts of the different predictions corresponding to the fetch address and/or the branch history in the correction table.
10. The method of claim 7, wherein determining whether to update the correction table based on the first prediction, the second prediction, and a count of differences in corresponding predictions in the correction table comprises:
if the first prediction result is different from the second prediction result, and the count value with the different predictions in the correction table is not larger than a preset threshold value, updating the count value to increase the updated count value;
and if the numerical value of the count is larger than a preset threshold value, resetting the count.
11. The method according to any of claims 1-10, wherein after determining the final skip identity corresponding to the first branch predictor, the method further comprises:
the first branch predictor receives a training instruction, the training instruction is generated by the branch predictor according to a second prediction result and a branch execution result of the execution unit, and the training instruction comprises a training category;
and the first branch predictor determines whether to execute the training instruction according to the corresponding final skipping identification and the training class.
12. The method of claim 11, wherein determining whether to execute the training instruction according to the corresponding final skip flag and the training class by the first branch predictor comprises:
if the final skipping mark is a mark representing that the training is not skipped and the training type is first training, the first branch predictor performs first training according to the training instruction; the first training is initiated when a second prediction result corresponding to the last-stage branch predictor is correct;
and if the final skipping mark is a mark representing skipping training and the training type is first training, not executing the training instruction.
13. An apparatus for determining skip training flag of multi-stage branch predictor, comprising:
the first result obtaining module is used for obtaining the output result of the prediction of the first branch predictor in the multistage branch predictors on the fetch address and/or the branch history; the first branch predictor is any branch predictor before the last-level branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether to jump or not and a skipping mark indicating whether the first branch predictor skips training or not;
the second result obtaining module is used for obtaining a second prediction result of the last-stage branch predictor for predicting the fetch address and/or the branch history; the second prediction result is used for representing whether the last-stage branch predictor predicts whether to jump or not;
a skip mark determining module, configured to correct the skip mark corresponding to the first branch predictor according to similarities and differences between the first prediction result and the second prediction result and a count indicating that predictions corresponding to the first branch predictor are different, so as to obtain a final skip mark; wherein the prediction-distinct count is a number of times the first prediction outcome differs from a branch execution outcome of an execution unit.
14. A multi-level branch predictor, a first branch predictor of the multi-level branch predictor being configured to perform the method of any one of claims 1-12; wherein the first branch predictor is any branch predictor before the last branch predictor in the multistage branch predictors.
15. A processor comprising the branch predictor of claim 14.
16. An electronic device, comprising: the processor, memory and bus of claim 15,
the processor and the memory are communicated with each other through the bus;
the memory stores program instructions executable by the processor.
17. A non-transitory computer-readable storage medium storing computer instructions which, when executed by a computer, cause the computer to perform the method of any one of claims 1-12.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011461847.1A CN112579166B (en) | 2020-12-08 | 2020-12-08 | Method and device for determining skipping training identification of multi-stage branch predictor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011461847.1A CN112579166B (en) | 2020-12-08 | 2020-12-08 | Method and device for determining skipping training identification of multi-stage branch predictor |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112579166A true CN112579166A (en) | 2021-03-30 |
CN112579166B CN112579166B (en) | 2022-11-15 |
Family
ID=75132249
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011461847.1A Active CN112579166B (en) | 2020-12-08 | 2020-12-08 | Method and device for determining skipping training identification of multi-stage branch predictor |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112579166B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113544640A (en) * | 2019-03-30 | 2021-10-22 | 华为技术有限公司 | Processing method of branch instruction, branch predictor and processor |
CN114020334A (en) * | 2021-11-04 | 2022-02-08 | 中国电子科技集团公司第五十八研究所 | Multi-cycle instruction fetching branch prediction mechanism and branch alias and jitter optimization scheme |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105867884A (en) * | 2016-03-24 | 2016-08-17 | 清华大学 | An improved PAp branch prediction method |
CN110134441A (en) * | 2019-05-23 | 2019-08-16 | 苏州浪潮智能科技有限公司 | RISC-V branch prediction method, device, electronic equipment and storage medium |
US20200065111A1 (en) * | 2018-08-21 | 2020-02-27 | Arm Limited | Apparatus and method for performing branch prediction |
-
2020
- 2020-12-08 CN CN202011461847.1A patent/CN112579166B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105867884A (en) * | 2016-03-24 | 2016-08-17 | 清华大学 | An improved PAp branch prediction method |
US20200065111A1 (en) * | 2018-08-21 | 2020-02-27 | Arm Limited | Apparatus and method for performing branch prediction |
CN110134441A (en) * | 2019-05-23 | 2019-08-16 | 苏州浪潮智能科技有限公司 | RISC-V branch prediction method, device, electronic equipment and storage medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113544640A (en) * | 2019-03-30 | 2021-10-22 | 华为技术有限公司 | Processing method of branch instruction, branch predictor and processor |
CN114020334A (en) * | 2021-11-04 | 2022-02-08 | 中国电子科技集团公司第五十八研究所 | Multi-cycle instruction fetching branch prediction mechanism and branch alias and jitter optimization scheme |
CN114020334B (en) * | 2021-11-04 | 2024-09-20 | 中国电子科技集团公司第五十八研究所 | Multi-period instruction fetching branch prediction mechanism, branch alias and jitter optimization scheme |
Also Published As
Publication number | Publication date |
---|---|
CN112579166B (en) | 2022-11-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112579166B (en) | Method and device for determining skipping training identification of multi-stage branch predictor | |
US20100312988A1 (en) | Data processing apparatus and method for handling vector instructions | |
US10162635B2 (en) | Confidence-driven selective predication of processor instructions | |
CN109643237B (en) | Branch target buffer compression | |
CN111208933B (en) | Method, device, equipment and storage medium for data access | |
US9430245B2 (en) | Efficient branch predictor history recovery in pipelined computer architectures employing branch prediction and branch delay slots of variable size | |
US20140201506A1 (en) | Method for determining instruction order using triggers | |
US20200278867A1 (en) | Device, processor, and method for splitting instructions and register renaming | |
US20230350683A1 (en) | Branch prediction method, branch prediction apparatus, processor, medium, and device | |
US9870314B1 (en) | Update testing by build introspection | |
US20140250289A1 (en) | Branch Target Buffer With Efficient Return Prediction Capability | |
US9176739B2 (en) | System and method for checking run-time consistency for sequentially and non-sequentially fetched instructions | |
CN110780925B (en) | Pre-decoding system and method of instruction pipeline | |
US5276825A (en) | Apparatus for quickly determining actual jump addresses by assuming each instruction of a plurality of fetched instructions is a jump instruction | |
US9652245B2 (en) | Branch prediction for indirect jumps by hashing current and previous branch instruction addresses | |
EP2690549A1 (en) | Arithmetic processing device, information processing device, and arithmetic processing method | |
CN116932424B (en) | Cache access method, device, medium and equipment based on ECC detection | |
CN113853581A (en) | Processing apparatus with differential branch target buffer for branch prediction | |
US11526359B2 (en) | Caching override indicators for statistically biased branches to selectively override a global branch predictor | |
US20050172110A1 (en) | Information processing apparatus | |
CN114840258B (en) | Multi-level hybrid algorithm filtering type branch prediction method and prediction system | |
US20090070569A1 (en) | Branch prediction device,branch prediction method, and microprocessor | |
US20040059899A1 (en) | Effectively infinite branch prediction table mechanism | |
US20130318327A1 (en) | Method and apparatus for data processing | |
US7302556B2 (en) | Method, apparatus and computer program product for implementing level bias function for branch prediction control for generating test simulation vectors |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230103 Address after: 610000 China (Sichuan) pilot Free Trade Zone, Chengdu high tech Zone Patentee after: CHENGDU HAIGUANG MICROELECTRONICS TECHNOLOGY Co.,Ltd. Address before: Industrial incubation-3-8, North 2-204, No. 18, Haitai West Road, Huayuan Industrial Zone, Binhai New Area, Tianjin 300450 Patentee before: Haiguang Information Technology Co.,Ltd. |
|
TR01 | Transfer of patent right |