Branch prediction

xiaoxiao2021-03-06  14

Supported branch prediction type

l Secondary branch prediction: That is, by shift register (primary) and PHT table (level 2), the current branch is analyzed according to the 2-bit saturation counter in the PHT table.

Parameters: N - number of entrances

W - shift register width

M - secondary entrance number

For GAG: three parameter values ​​are: 1 W 2 ^ W

GAP: The three parameter values ​​are: 1 w m

(Only one shift register, so N is 1, and because only one pht table, the GAG ​​is 2 ^ W, at this time, through the shift register, find the PHT table, get the branch situation; and in GAP Different branches have different PHT tables, so you need to obtain one of multiple PHT tables using the address of the branch instruction, so M = k * 2 ^ w, where K should be the number of set PHT tables, Moreover, K should be 2 index levels)

PAG: Three parameter values ​​are: n w 2 ^ w

PAP: Three parameter values ​​are: N w m

(At this time, the address index register and PHT table will be used at the same time. If it is a PAG, then the multiple shift registers indexes multiple shift registers, the obtained value is used to obtain the jump situation. If it is PAP, the branch command address index shift register and the PHT table are simultaneously utilized to obtain a jump condition).

l Two bit saturation count prediction mode

The supported prediction method is not jumped when XX = 0x is

XX = 1x jump time

l predicting non-jump L predictive jump

Each parameter definition of branch prediction 1) Defines the type of branch prediction

Enum bpRed_class {}

2) Define the structure of the BTB (branch buffer) table

The BTB table defined in the book contains three parts: the address of the branch instruction, the destination address of branch jump, and prediction results

The structure of this is defined here: the address of the branch instruction; for the current address of the current address; if the branch jumps, the destination address of the jump; and the link structure of the BTB table (two-way linked list)

3) Define the prediction structure of the two saturation counts, in consideration of the secondary branch prediction, two saturated counters are used, so various parts are defined using Union:

Class - Description Is Secondary branch prediction or BIMOD prediction;

Then if it is BIMOD, you need to define a counter structure, namely, Bimod.Size and Bimod-> Table;

If it is a second-level branch prediction, the type of defined type is: the number of registers, the number of PHT tables, the branch history length saved in the shifting register; the branch history and branch address are flagged; point to the pointer to historical table And pointing to the pointer in the PHT table;

4) Define the branch predictor: Define the type of branch prediction, and the corresponding predictor element to the point; define the number of BTB tables, and the degree of association in the BTB group, and the BTB table define the return stack: return to the stack The size of the stack is returned, and the return stack also uses the structure of the BTB and also defines multiple counts: the correctness of the direction prediction (forward, back - whether the jump), the correctness of address prediction ( Not only is the forward backward, but also the correct address. Structure. This not only predicts the branch instruction, which also includes the return of the program inter-program call. 5) Define the predictive update message and then the declaration of each function 1) Creating branch predictor 2) Creating a branch direction predictor 3) Output 4) Output 4) Output 5) The output of branch prediction status 5) Information 6) In the database (SDB), information is stored in the main location storage branch Information 7) Using Branch Predictor Processing Next Instruction 8) Preventing Error 9) Demo 9) Update 10 of several elements in the branch predictor) In order to adjust the information of the branch predictor. Specific Description of each function 1) Creating a branch predictor See this function To see the function of creating a branch direction predictor According to Class, first create a branch direction predictor (including two, BIMOD predictors) and continue according to branch The type of predictor Class, allocation return stack first looks at the structure of the BTB table, if the BTB table is 0 or not 2 index, no. Then, according to the group × connected distribution space of the BTB table, each BTB structure is then hosted into a linked list after allocating the BTB, and the returns are allocated.

Return stack is actually an array 2) Creating a branch direction predictor first assigned a structure size space, which means that the type of branch direction predictor currently created is next to the parameter assignment according to the Class as needed. : If it is a second-level branch prediction: the parameter has a size of the size (ie, several of the shift register), the size of the secondary size (ie, the number of PHT tables) The size of the shift register (0

Then if the instruction is a function call instruction, then press the return address value into the stack and then if both, then find the BTB table, because the BTB may be a group, then find the number of groups, then find specific BTB Entrance. If the corresponding instruction address is not found in the BTB, according to the previous PDIR, the analysis is not jumping, that is, the direction 10 can be given to prevent the branch prediction, and the problem, the problem is predicted. The branch is saved to save the current return stack address 11) Update to the various parameters predicted by the branch. The first is that it is determined whether it is branch instruction. If it is a branch instruction, and the address is also correct, the correct number 1 is predicted, otherwise the direction 1 This function is processed after the branch instruction is executed. But not very clearly what STATEFUL predictions mean. For the processing of the BTB table, there is an update, and there is no way to use the LRU replacement. 3) Configuration information of the output branch direction predictor 4) Output branch predictor configuration information 5) and predictive information 6) then the information 7) of the SDB predicted 7) The key area information is not important. 8) Predictively, the direction of the direction predictor of the selection of the parameters given by a branch, and the command address of the branch. During the function processing, first move the branch command address to the right, doing the shift register with the current effective

And L2Index is the value in the current shift register.

Anyway, I now know that L2Index is an index of the value of the 2-bit saturated counter.

Here is to consider the situation when there is multiple shift registers, because L1Size is the number of shift registers, not the width of the shift register. So if it is ga *, L1Index = 0. Then, L2Index just gets one of the words if there are multiple shift registers.

If you need to shift the number and branch address in the shift register to do XOR (which is what is very accurate branch prediction method), here considering it.

It is a value in the two-bit saturated counter, which uses a bimod_hash macro, and when there are many 2-bit saturation counters, one of them is obtained through the Bimod_hash macro, it can be seen that it is to hear multiple 2-bit counters HASH linked list.

9) Predict the address of the next instruction

Note that this is considering all instructions, not just a branch instruction, ie, a macro of acquisition instruction opcode in the code.

In the prediction here, the first is to predict the direction of the branch and obtain the results of PDIR1. Then the prediction of the jump address of the branch instruction. Due to the branch of prediction conditions, that is, non-conditional branches are not predicted. Here, first look at the process of returning to the stack.

First get the top of the stack.

Then if the command is returned, that is, the process called the return, the destination address is the address inside the stack.

Then if the instruction is a function call instruction, then press the return address value into the stack.

Then, if both are, then find the BTB table, because the BTB may be group associated, so find the number of groups, then find the specific BTB entry.

If the corresponding instruction address is not found in the BTB, the analysis is not jumping according to the previous PDIR, that is, the direction can be given.

10) In order to prevent branch prediction, the problem is preserved, and the current return stack address is saved at the predicted branch in the predicted branch.

11) Update to the various parameters predicted by branch.

The first is that it is determined whether it is branch instruction.

If it is a branch instruction, and the address is also correct, the correct number 1 is predicted, otherwise the direction 1 This function is processed after the branch instruction is executed. But not very clearly what STATEFUL predictions mean. For the processing of the BTB table, there is an update, and there is no way to use the LRU replacement.

Definition of each parameter of branch prediction 1)

Define the type of branch prediction

Enum bpRed_class {}

2) Define the structure of the BTB (branch buffer) table

The BTB table defined in the book contains three parts: the address of the branch instruction, the destination address of branch jump, and prediction results

The structure of this is defined here: the address of the branch instruction; for the current address of the current address; if the branch jumps, the destination address of the jump; and the link structure of the BTB table (two-way linked list)

3) Define the prediction structure of the two saturation counts, in consideration of the secondary branch prediction, two saturated counters are used, so various parts are defined using Union:

Class - Description Is Secondary branch prediction or BIMOD prediction;

Then if it is BIMOD, you need to define a counter structure, namely, Bimod.Size and Bimod-> Table;

If it is a second-level branch prediction, the type of defined type is: the number of registers, the number of PHT tables, the branch history length saved in the shifting register; the branch history and branch address are flagged; point to the pointer to historical table And pointing to the pointer in the PHT table;

4)

Define a branch predictor:

Define the type of branch prediction, as well as the corresponding predictor element to point;

Define the number of groups of BTB tables, and the degree of association in the BTB group, and BTB table

Define the return stack: Return the size of the stack, return to the top of the stack, and the return stack also uses the BTB structure

At the same time, multiple counts are also defined: the correctness of the direction prediction (forward, back - is jumping), the correctness of the address prediction (not only is the forward backward, but also has the correct address. Wait structure .

It not only predicts branch instructions, but also includes returning to the program.

5) Define the message that predicts updated

Then the statement of each function

1) Creating a branch predictor

2) Create a branch direction predictor

3) Output of branch predictor configuration

4) Output of branch prediction status

5) Information store branch prediction in the database (SDB)

6) In the main location storage branch information 7) Using the branch predictor processing Next instruction 8) Prevent the error 9) Update for several elements in the branch predictor

10) In order to adjust the information of the branch predictor.

Specific Description of each function 1) Creating a branch predictor See this function To see the function of creating a branch direction predictor According to Class, first create a branch direction predictor (including two, BIMOD predictors) and continue according to branch The type of predictor Class, allocation return stack first looks at the structure of the BTB table, if the BTB table is 0 or not 2 index, no. Then, according to the group × connected distribution space of the BTB table, each BTB structure is then hosted into a linked list after allocating the BTB, and the returns are allocated. Return stack is actually an array 2) Creating a branch direction predictor first assigned a structure size space, which means that the type of branch direction predictor currently created is next to the parameter assignment according to the Class as needed. : If it is a second-level branch prediction: the parameter has a size of the size (ie, several of the shift register), the size of the secondary size (ie, the number of PHT tables) The size of the shift register (0

And L2Index is the value in the current shift register.

Anyway, I now know that L2Index is an index of the value of the 2-bit saturated counter.

Here is to consider the situation when there is multiple shift registers, because L1Size is the number of shift registers, not the width of the shift register. So if it is ga *, L1Index = 0. Then, L2Index just gets one of the words if there are multiple shift registers.

If you need to shift the number and branch address in the shift register to do XOR (which is what is very accurate branch prediction method), here considering it.

It is a value in the two-bit saturated counter, which uses a bimod_hash macro, and when there are many 2-bit saturation counters, one of them is obtained through the Bimod_hash macro, it can be seen that it is to hear multiple 2-bit counters HASH linked list.

9) Predict the address of the next instruction

Note that this is considering all instructions, not just a branch instruction, ie, a macro of acquisition instruction opcode in the code. In the prediction here, the first is to predict the direction of the branch and obtain the results of PDIR1. Then the prediction of the jump address of the branch instruction. Due to the branch of prediction conditions, that is, non-conditional branches are not predicted. Here, first look at the process of returning to the stack.

First get the top of the stack.

Then if the command is returned, that is, the process called the return, the destination address is the address inside the stack.

Then if the instruction is a function call instruction, then press the return address value into the stack.

Then, if both are, then find the BTB table, because the BTB may be group associated, so find the number of groups, then find the specific BTB entry.

If the corresponding instruction address is not found in the BTB, the analysis is not jumping according to the previous PDIR, that is, the direction can be given.

10) In order to prevent branch prediction, the problem is preserved, and the current return stack address is saved at the predicted branch in the predicted branch.

11) Update to the various parameters predicted by branch.

The first is that it is determined whether it is branch instruction.

If it is a branch instruction, and the address is also correct, the predictive number 1, otherwise the direction 1

This function is processed when the branch instruction is executed. But not very clearly what STATEFUL predictions mean. For the processing of the BTB table, there is an update, and there is no way to use the LRU replacement.

3) Configuration information of the output branch direction predictor 4) Output branch predictor configuration information 5) and predictive information 6) then the information 7) of the SDB predicted 7) The key area information is not important. 8) Predictively, the direction of the direction predictor of the selection of the parameters given by a branch, and the command address of the branch. During the function processing, first move the branch command address to the right, doing the shift register with the current effective

And L2Index is the value in the current shift register.

Anyway, I now know that L2Index is an index of the value of the 2-bit saturated counter.

Here is to consider the situation when there is multiple shift registers, because L1Size is the number of shift registers, not the width of the shift register. So if it is ga *, L1Index = 0. Then, L2Index just gets one of the words if there are multiple shift registers.

If you need to shift the number and branch address in the shift register to do XOR (which is what is very accurate branch prediction method), here considering it.

It is a value in the two-bit saturated counter, which uses a bimod_hash macro, and when there are many 2-bit saturation counters, one of them is obtained through the Bimod_hash macro, it can be seen that it is to hear multiple 2-bit counters HASH linked list.

9) Predict the address of the next instruction

Note that this is considering all instructions, not just a branch instruction, ie, a macro of acquisition instruction opcode in the code.

In the prediction here, the first is to predict the direction of the branch and obtain the results of PDIR1. Then the prediction of the jump address of the branch instruction. Due to the branch of prediction conditions, that is, non-conditional branches are not predicted. Here, first look at the process of returning to the stack.

First get the top of the stack.

Then if the command is returned, that is, the process called the return, the destination address is the address inside the stack.

Then if the instruction is a function call instruction, then press the return address value into the stack.

Then, if both are, then find the BTB table, because the BTB may be group associated, so find the number of groups, then find the specific BTB entry. If the corresponding instruction address is not found in the BTB, the analysis is not jumping according to the previous PDIR, that is, the direction can be given.

10) In order to prevent branch prediction, the problem is preserved, and the current return stack address is saved at the predicted branch in the predicted branch.

11) Update to the various parameters predicted by branch.

The first is that it is determined whether it is branch instruction.

If it is a branch instruction, and the address is also correct, the predictive number 1, otherwise the direction 1

This function is processed when the branch instruction is executed. But not very clearly what STATEFUL predictions mean. For the processing of the BTB table, there is an update, and there is no way to use the LRU replacement.

转载请注明原文地址:https://www.9cbs.com/read-44958.html

New Post(0)