CN112579166B - 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 PDF

Info

Publication number
CN112579166B
CN112579166B CN202011461847.1A CN202011461847A CN112579166B CN 112579166 B CN112579166 B CN 112579166B CN 202011461847 A CN202011461847 A CN 202011461847A CN 112579166 B CN112579166 B CN 112579166B
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.)
Active
Application number
CN202011461847.1A
Other languages
Chinese (zh)
Other versions
CN112579166A (en
Inventor
崔泽汉
张克松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Haiguang Microelectronics Technology Co Ltd
Original Assignee
Haiguang Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Haiguang Information Technology Co Ltd filed Critical Haiguang Information Technology Co Ltd
Priority to CN202011461847.1A priority Critical patent/CN112579166B/en
Publication of CN112579166A publication Critical patent/CN112579166A/en
Application granted granted Critical
Publication of CN112579166B publication Critical patent/CN112579166B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30094Condition 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; acquiring 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 training skipping is judged 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 perform training, and the prediction accuracy of the branch predictor is improved.

Description

Method and device for determining skipping training identifier of multi-level branch predictor
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 a Branch instruction executes to improve the performance of the processor's instruction pipeline.
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 branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether jumping 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 a fetch address and/or a branch history, a prediction result of a last-stage branch predictor on the fetch address and/or the branch history, and final skip identifications 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 value of the different count, and the numerical value of the different count is used for representing the reliability of correcting the first prediction result, that is, when the numerical value of the different count is 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 embodiments of the present application.
Further, the modifying 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 to obtain a final skip identifier 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 acquisition module is used for acquiring the output result of the prediction of the fetch address and/or the branch history by the first branch predictor in the multistage branch predictors; the first branch predictor is any branch predictor before the last branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether jumping 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 modify 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 of differences between predictions corresponding to the first branch predictor, 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 described in the fourth aspect, where the processor and the memory complete mutual communication 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
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 identifier according to an embodiment of the present application;
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 an instruction's operation is divided into multiple, fine steps, each step being 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 procedure 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, a branch predictor is generated accordingly. 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 by the execution unit after decoding, 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 flowchart of training a branch predictor in a comparison scheme, where the branch predictor has N stages, and the branch predictor also maintains 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 a fetch address and/or branch history is finished, the fetch address and/or 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 per se meets the condition of skipping first training or not according to the prediction result, and if yes, 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 training 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
Figure BDA0002824863560000091
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 branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether jumping or not and a skipping mark indicating whether the first branch predictor skips training or not.
The fetch address can be stored in a fetch register, the fetch register can sequentially send the 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 representation, any branch predictor preceding the last 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 a number of times that 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 one-time 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 be corrected/trained; conversely, the smaller the number of counts, the less correction/training required for the first predictor branch. It is understood that the value of the count and whether correction is required are preset, and the smaller the count value is, the less correction/training is required for the first branch predictor; 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 finally skipped. Numerical representations may be employed, such as: "0" indicates that training is not skipped, and "1" indicates that training is skipped. 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 skip identifications 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
Figure BDA0002824863560000121
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 a fetch 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 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 the 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 a 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 represents a mark for skipping training, and the numerical value of the counting with different predictions is larger than a preset threshold value, determining that the final skip mark represents a mark for not skipping 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, then 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, indicating that the reliability that the first branch predictor needs to be corrected is high, and executing step 505; 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 a 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 skipping first 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. Likewise, the skip flag may be represented by "0" or "1", i.e., "0" indicates not to skip the training and "1" indicates to skip the training.
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 similarity between the first prediction result and the second prediction result and the count of the difference 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 larger than a preset threshold value, determining the skip mark as 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 jumps. 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, where the correction table includes counts of the predictions that are different, and the correction table may be a Cache (Cache) -like set-associative structure, that is, a part of an address is used as an index, and then another part of the address is used as a tag for comparison; or index with one hash of the address and then compare with another hash of the address as a 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 may be the fetch address and/or the branch history, may also be obtained by performing hash operation on the fetch address and/or the branch history, and may 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 count of the difference between the predictions corresponding to the fetch address and/or the branch history in the correction table is 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 prediction of the branch predictor, 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;
the first branch predictor determines whether to execute the training instruction according to the corresponding final skipping identification and the training category.
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 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, the positive number can indicate skipping, and the negative number indicates 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 no jump 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, and the branch prediction divides the numerical 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, then 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 in fig. 3, and can perform various steps related to the embodiment of the method in 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-level branch predictors predicting the fetch address and/or the branch history; the first branch predictor is any branch predictor before the last branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether jumping or not and a skipping mark indicating whether the first branch predictor skips training or not; the second result obtaining module 702 is configured to obtain 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; 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 represents a mark for skipping training, and the numerical value of the count of the prediction error is greater than a preset threshold value, determining that the final skip mark represents a mark for not skipping 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 identity 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 identity 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 corresponding prediction difference in the correction table.
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 content of the first and second substances,
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: acquiring an output result of a first branch predictor in the multistage branch predictors for predicting a 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; 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 count of prediction differences refers to a number of times the first prediction result differs from a branch execution result 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 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 apparatus embodiments are merely illustrative, and for example, the division of the units into only one type of logical function may be implemented in other ways, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or units, 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-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;
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 a fetch address and/or a branch history, a prediction result of a last-stage branch predictor on the fetch address and/or the branch history, and final skip identifications 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 represents a mark for skipping training, and the numerical value of the prediction difference count is larger than a preset threshold value, determining that the final skip mark represents a mark for not skipping 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 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 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 for representing skipping training and the training category is first training, not executing the training instruction.
13. An apparatus for determining skip training flag of multi-level 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 branch predictor in the multistage branch predictors, and the output result comprises a first prediction result indicating whether the first branch predictor predicts whether jumping 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 count of prediction dissimilarity refers to a number of times the first prediction differs from the second prediction.
14. A multi-level branch predictor, wherein a first branch predictor of the multi-level branch predictor is 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: a memory, a bus, and the processor 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.
CN202011461847.1A 2020-12-08 2020-12-08 Method and device for determining skipping training identification of multi-stage branch predictor Active CN112579166B (en)

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 CN112579166A (en) 2021-03-30
CN112579166B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020199058A1 (en) * 2019-03-30 2020-10-08 华为技术有限公司 Branch instruction processing method, branch predictor, and processor

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105867884B (en) * 2016-03-24 2018-06-15 清华大学 A kind of modified PAp branch prediction methods
US10831499B2 (en) * 2018-08-21 2020-11-10 Arm Limited Apparatus and method for performing branch prediction
CN110134441B (en) * 2019-05-23 2020-11-10 苏州浪潮智能科技有限公司 RISC-V branch prediction method, apparatus, electronic device and storage medium

Also Published As

Publication number Publication date
CN112579166A (en) 2021-03-30

Similar Documents

Publication Publication Date Title
US5193205A (en) Pipeline processor, with return address stack storing only pre-return processed address for judging validity and correction of unprocessed address
US10162635B2 (en) Confidence-driven selective predication of processor instructions
CN111208933B (en) Method, device, equipment and storage medium for data access
US20140201506A1 (en) Method for determining instruction order using triggers
US9430245B2 (en) Efficient branch predictor history recovery in pipelined computer architectures employing branch prediction and branch delay slots of variable size
JP2010509680A (en) System and method with working global history register
US20140156978A1 (en) Detecting and Filtering Biased Branches in Global Branch History
JP2015133126A (en) Method and system for accelerating procedure return sequences
CN105095912A (en) Data clustering method and device
US20230350683A1 (en) Branch prediction method, branch prediction apparatus, processor, medium, and device
US20140250289A1 (en) Branch Target Buffer With Efficient Return Prediction Capability
CN110780925B (en) Pre-decoding system and method of instruction pipeline
US9176739B2 (en) System and method for checking run-time consistency for sequentially and non-sequentially fetched instructions
CN112579166B (en) Method and device for determining skipping training identification of multi-stage branch predictor
US5276825A (en) Apparatus for quickly determining actual jump addresses by assuming each instruction of a plurality of fetched instructions is a jump instruction
EP2690549A1 (en) Arithmetic processing device, information processing device, and arithmetic processing method
US9652245B2 (en) Branch prediction for indirect jumps by hashing current and previous branch instruction addresses
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
CN116149917A (en) Method and apparatus for evaluating processor performance, computing device, and readable storage medium
CN108469987B (en) Interrupt verification system based on interrupt control flow graph
US20090070569A1 (en) Branch prediction device,branch prediction method, and microprocessor
CN113467783A (en) Kernel function compiling method and device of artificial intelligent accelerator
US9003198B2 (en) Method and apparatus for data processing
CN114840255B (en) Method, apparatus and device readable storage medium for processing data

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