Branch prediction method, device and storage medium based on speculative update

By introducing the speculative update queue and the speculative allocation queue into the TAGE branch predictor, the hash operation is used to prioritize the use of speculative information for prediction, which solves the problem of processor training delay and warm-up speed and improves the prediction accuracy.

CN118626149BActive Publication Date: 2024-10-29BEIJING VCORE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411096644.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2024-10-29
Estimated Expiration
2044-08-12

AI Technical Summary

Technical Problem

The long pipeline designed by modern high-performance processors causes TAGE branch predictor training delays, affecting warm-up speed and prediction accuracy.

Method used

Introducing the speculative update queue and speculative allocation queue into the TAGE branch predictor, obtaining the instruction address and global branch history through hash operation, giving priority to using the prediction information in the speculative queue for prediction, reducing training delay and increasing the warm-up speed.

Benefits of technology

It effectively solves the training delay problem caused by long pipelines and improves the warm-up speed and average prediction accuracy of the TAGE branch predictor.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626149B_ABST
    Figure CN118626149B_ABST
Patent Text Reader

Abstract

The present application proposes a branch prediction method, device and storage medium based on speculative update, which relates to the field of data processing technology, wherein the method includes: performing hash operations on the global branch history and instruction address respectively to obtain hash results; inputting the instruction address into the basic table and the first speculative update queue respectively to determine the first output result of the basic table; inputting the hash result into the label prediction table, the second speculative update queue and the speculative allocation queue respectively to determine the second output result of the label prediction table; arbitrating and predicting the first output result and the second output result to obtain the branch prediction result. By adding the speculative update queue and the speculative allocation queue to the TAGE branch predictor, the prediction information in the speculative allocation queue is used first when making predictions, which can solve the training delay problem caused by the long pipeline and improve the warm-up speed of the TAGE.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a branch prediction method, device and storage medium based on speculative update. Background Art

[0002] Modern high-performance processors are often designed with a longer pipeline depth. A branch instruction needs to go through the entire pipeline before it can be used to train the branch predictor. This causes a training delay problem, which affects the warm-up speed of the TAGE (TAgged GEometric History Length) branch predictor, and thus affects the prediction accuracy of the TAGE branch predictor. Summary of the invention

[0003] The present application aims to solve one of the technical problems in the related art at least to some extent.

[0004] To this end, the first objective of the present application is to propose a branch prediction method based on speculative updating to reduce the training delay of the TAGE branch predictor and improve the warm-up speed of the TAGE branch predictor.

[0005] The second objective of the present application is to provide a branch prediction device based on speculative updating.

[0006] The third object of the present application is to provide a computer-readable storage medium.

[0007] A fourth object of the present application is to provide a computer program product.

[0008] To achieve the above-mentioned purpose, the first aspect of the present application proposes a branch prediction method based on speculative update, which is applied to a branch predictor, wherein the branch predictor includes a base table, a tag prediction table, a first speculative update queue corresponding to the base table, a second speculative update queue corresponding to the tag prediction table, and a speculative allocation queue, including:

[0009] Obtaining a global branch history and an instruction address of a branch instruction, and performing hash operations on the global branch history and the branch instruction respectively to obtain a hash result;

[0010] inputting the instruction address into the base table and the first speculative update queue respectively, so as to determine a first output result of the base table based on a first matching result between the instruction address and a predicted branch instruction address included in the first speculative update queue;

[0011] Inputting the hash result into a label prediction table, the second speculation update queue, and the speculation allocation queue, respectively, to determine a second output result of the label prediction table based on a second matching result between the hash result and a first hash field included in the second speculation update queue and a third matching result between the hash result and a second hash field included in the speculation allocation queue;

[0012] The first output result and the second output result are arbitrated and predicted to obtain a branch prediction result.

[0013] To achieve the above-mentioned purpose, the second aspect of the present application proposes a branch prediction device based on speculative update, which is applied to a branch predictor, wherein the branch predictor includes a base table, a tag prediction table, a first speculative update queue corresponding to the base table, a second speculative update queue corresponding to the tag prediction table, and a speculative allocation queue, including:

[0014] An acquisition module, used for acquiring a global branch history and an instruction address of a branch instruction, and performing hash operations on the global branch history and the branch instruction respectively to obtain a hash result;

[0015] a first output module, configured to input an instruction address into the base table and the first speculative update queue respectively, so as to determine a first output result of the base table based on a first matching result between the instruction address and a predicted branch instruction address included in the first speculative update queue;

[0016] a second output module, configured to input the hash result into the label prediction table, the second speculation update queue, and the speculation allocation queue, respectively, so as to determine a second output result of the label prediction table based on a second matching result between the hash result and the first hash field included in the second speculation update queue and a third matching result between the hash result and the second hash field included in the speculation allocation queue;

[0017] A prediction module is used to arbitrate and predict the first output result and the second output result to obtain a branch prediction result.

[0018] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by the processor, they are used to implement a branch prediction method based on speculative update proposed in the first aspect embodiment of the present application.

[0019] To achieve the above-mentioned purpose, the fourth aspect of the present application proposes a computer program product, including a computer program, which, when executed by a processor, implements a branch prediction method based on speculative update proposed in the first aspect of the present application.

[0020] The branch prediction method, device and storage medium based on speculation update provided by the present application obtain the global branch history and the instruction address of the branch instruction, and perform hash operations on the global branch history and the instruction address respectively to obtain the hash result; input the instruction address into the basic table and the first speculation update queue respectively, so as to determine the first output result of the basic table based on the first matching result between the instruction address and the predicted branch instruction address included in the first speculation update queue; input the hash result into the label prediction table, the second speculation update queue and the speculation allocation queue respectively, so as to determine the second output result of the label prediction table based on the second matching result between the hash result and the first hash field included in the second speculation update queue, and the third matching result between the hash result and the second hash field included in the speculation allocation queue; arbitrate and predict the first output result and the second output result to obtain the branch prediction result. By adding the speculation update queue and the speculation allocation queue to the TAGE branch predictor, when making a prediction, the new prediction information is sent to the speculation queue, and when making a subsequent prediction, the prediction information in the speculation queue is used first, which can solve the training delay problem caused by the long pipeline, improve the warm-up speed of TAGE, and thus improve the average prediction accuracy.

[0021] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0023] Figure 1 A schematic diagram of a flow chart of a branch prediction method based on speculative update provided in an embodiment of the present application;

[0024] Figure 2 A schematic diagram of a flow chart of a branch prediction method based on speculative update provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of the structure of a branch predictor provided in an embodiment of the present application;

[0026] Figure 4 A schematic diagram of the structure of a branch prediction device based on speculative update provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0028] The following describes a branch prediction method and device based on speculative updating according to an embodiment of the present application with reference to the accompanying drawings.

[0029] Figure 1 A schematic flow chart of a branch prediction method based on speculative update provided in an embodiment of the present application.

[0030] Training delay includes update delay and allocation delay. Update delay refers to the delay from the prediction stage to the submission stage of the branch instruction, and allocation delay refers to the delay from the discovery of branch prediction errors to the instruction submission stage. The existing IUM (Immediate Update Mimicker) algorithm can only solve the update delay problem of the TAGE branch predictor, but cannot solve its allocation delay problem.

[0031] To address this problem, an embodiment of the present application provides a branch prediction method based on speculative updates, which is applied to a branch predictor to reduce the training delay of a TAGE branch predictor and improve the warm-up speed of the TAGE branch predictor. The branch predictor includes a base table, a label prediction table, a first speculative update queue corresponding to the base table, a second speculative update queue corresponding to the label prediction table, and a speculative allocation queue.

[0032] In an embodiment of the present application, a speculation update queue and a speculation allocation queue are added to the TAGE predictor. The speculation update queue is a fully associative register queue for storing prediction information of branch instructions that are not submitted after its prediction.

[0033] The speculative update queue corresponding to the basic table is the first speculative update queue, which includes the following fields:

[0034] taken: The jump direction during prediction.

[0035] ctr: The counter value (ctr) of the base table during prediction, which is consistent with TAGE.

[0036] pc: The instruction address of the branch instruction at the time of prediction (PC value).

[0037] The speculation update queue corresponding to the tag prediction table is the second speculation update queue, which includes the following fields:

[0038] table_idx: the serial number of the tag prediction table of the TAGE hit during prediction.

[0039] index: the index of the tag prediction table entry of the TAGE hit during prediction.

[0040] tag: consistent with the tag field in the TAGE tag prediction table.

[0041] taken: The jump direction during prediction.

[0042] ctr: The counter value (ctr) field of the tag prediction table hit during prediction.

[0043] u: The u field of the label prediction table hit during prediction.

[0044] The tag prediction table also corresponds to a speculation allocation queue, which is a fully associative register queue used to store the allocated new TAGE table entries.

[0045] A speculative allocation queue table entry consists of the following fields:

[0046] table_idx: the serial number of the tag prediction table of the TAGE hit during prediction.

[0047] index: the index of the tag prediction table entry of the TAGE hit during prediction.

[0048] tag: consistent with the tag field in the TAGE tag prediction table.

[0049] taken: The jump direction when allocating.

[0050] ctr: The counter value (ctr) field of the label prediction table at allocation time, which is 4 when taken=1 and 3 otherwise.

[0051] u: The u field of the label prediction table during allocation, initialized to 0 during allocation.

[0052] like Figure 1 As shown, the branch prediction method based on speculative update includes the following steps:

[0053] Step 101, obtain the global branch history and the instruction address of the branch instruction, and perform hash operations on the global branch history and the instruction address respectively to obtain a hash result.

[0054] Among them, the existing TAGE predictor consists of a base table and multiple different label prediction tables. Each item in the label prediction table contains a counter for predicting the jump direction of the branch instruction. In addition, each label prediction table corresponds to a global branch history for addressing, and the length of each global branch history is different.

[0055] It should be noted that the Program Counter (PC) is a component in the CPU that stores the address of the current instruction to be executed. The instruction address (PC value) of the branch instruction is the address of the branch instruction to be executed.

[0056] Optionally, the global branch history and the instruction address of the branch instruction are obtained by reading the TAGE branch predictor.

[0057] Furthermore, each global branch history and the instruction address of the branch instruction are respectively input into the hash function of TAGE, so that each global branch history is XORed with the instruction address of the branch instruction, and multiple tag hashes and index hashes are calculated to obtain the hash result.

[0058] Step 102 , input the instruction address into the base table and the first speculative update queue respectively, so as to determine a first output result of the base table based on a first matching result between the instruction address and the predicted branch instruction address included in the first speculative update queue.

[0059] Optionally, the instruction address is input into a basic table for table lookup, and the instruction address is matched with the predicted branch instruction address to obtain a first matching result.

[0060] In an embodiment of the present application, an instruction address is input into a first speculative update queue of a base table, and matched with a predicted branch instruction address included in the first speculative update queue to obtain a first matching result.

[0061] The first matching result is a match hit or a non-match hit.

[0062] In case of a match hit, a first output result of the base table is determined based on the first matching result.

[0063] In the embodiment of the present application, the output of the basic table is obtained as the first output result by arbitrating the first matching result and the table entries included in the first speculative update queue.

[0064] Step 103, input the hash results into the label prediction table, the second speculation update queue and the speculation allocation queue respectively, so as to determine the second output result of the label prediction table based on the second matching result of the hash result and the first hash field included in the second speculation update queue, and the third matching result of the hash result and the second hash field included in the speculation allocation queue.

[0065] Optionally, the hash result is input into a label prediction table for table lookup and matching, and the hash result is matched with a second speculative update queue corresponding to the label prediction table to obtain a second matching result.

[0066] In an embodiment of the present application, the hash result includes a tag hash and an index hash, and the hash result is matched with the tag field and the index field in the second speculative update queue respectively to obtain a second matching result.

[0067] The second matching result is a match hit or a non-match hit.

[0068] Optionally, the hash result is input into a label prediction table for table lookup and matching, and the hash result is matched with a speculation allocation queue corresponding to the label prediction table to obtain a third matching result.

[0069] In an embodiment of the present application, the hash result includes a tag hash and an index hash, and the hash result is matched with the tag field and the index field in the speculation allocation queue respectively to obtain a third matching result.

[0070] The third matching result is a match hit or a non-match hit.

[0071] Further, a second output result of the label prediction table is determined based on the second matching result and the third matching result.

[0072] When both the second matching result and the third matching result are match hits, the output of the label prediction table is obtained as the second output result by arbitrating the table entries included in the second matching result, the third matching result, the second speculation update queue and the speculation allocation queue.

[0073] Step 104 , arbitrate and predict the first output result and the second output result to obtain a branch prediction result.

[0074] Optionally, the first output result and the second output result are arbitrated and predicted according to a longest match principle.

[0075] In the embodiment of the present application, the prediction result corresponding to the longest global branch history is used as the branch prediction result.

[0076] Furthermore, the table entry hit by the longest global branch history is used as the table entry for branch prediction, that is, if the longest global branch history hits the basic table, it means that branch prediction is performed using the table entry of the basic table; if the longest global branch history hits the label prediction table, it means that branch prediction is performed using the table entry of the label prediction table.

[0077] In this embodiment, by obtaining the global branch history and the instruction address of the branch instruction, and performing hash operations on the global branch history and the instruction address respectively, to obtain a hash result; the instruction address is input into the base table and the first speculation update queue respectively, to determine the first output result of the base table based on the first matching result between the instruction address and the predicted branch instruction address included in the first speculation update queue; the hash result is input into the label prediction table, the second speculation update queue and the speculation allocation queue respectively, to determine the second output result of the label prediction table based on the second matching result between the hash result and the first hash field included in the second speculation update queue, and the third matching result between the hash result and the second hash field included in the speculation allocation queue; the first output result and the second output result are arbitrated and predicted to obtain the branch prediction result. By adding the speculation update queue and the speculation allocation queue to the TAGE branch predictor, when making a prediction, the new prediction information is sent to the speculation queue, and when making a subsequent prediction, the prediction information in the speculation queue is used first, which can solve the training delay problem caused by the long pipeline, improve the warm-up speed of the TAGE, and thus improve the average prediction accuracy.

[0078] This embodiment provides another branch prediction method based on speculative update, which is applied to a branch predictor. Figure 2 A flowchart of another branch prediction method based on speculative update provided in an embodiment of the present application.

[0079] In an embodiment of the present application, the branch predictor includes a base table, a tag prediction table, a first speculation update queue corresponding to the base table, a second speculation update queue corresponding to the tag prediction table, and a speculation allocation queue, such as Figure 2 As shown, the branch prediction method based on speculative update may include the following steps:

[0080] Step 201, obtain the global branch history and the instruction address of the branch instruction, and perform hash operations on the global branch history and the instruction address respectively to obtain a hash result.

[0081] For step 201, reference may be made to the relevant description of the corresponding step in the aforementioned embodiment, which will not be described in detail in this embodiment.

[0082] Step 202, determine the instruction address in the basic table that matches the predicted branch instruction address as the hit instruction address; according to the preset priority, arbitrate the table entry of the basic table where the hit instruction address is located and the first speculative update queue and output them as the first output result.

[0083] Optionally, the instruction address is input into the first speculative update queue of the base table and matched with the predicted branch instruction address included in the first speculative update queue. If a match is successful, the last entry inserted into the queue is used as the hit entry, that is, the hit instruction address.

[0084] The first speculative update appendix includes a plurality of table entries, and the table entries of the basic table where the hit instruction address is located and the first speculative update queue are arbitrated according to the preset priorities from high to low and then output as the first output result.

[0085] In the embodiment of the present application, the preset priority is pre-set and stored for arbitration output.

[0086] Step 203, input the hash results into the label prediction table, the second speculation update queue and the speculation allocation queue respectively, so as to determine the second output result of the label prediction table based on the second matching result of the hash result and the first hash field included in the second speculation update queue, and the third matching result of the hash result and the second hash field included in the speculation allocation queue.

[0087] Optionally, determine the hash result that matches the first hash field and the hash result that matches the second hash field in the label prediction table as the hit hash result; according to the preset priority, arbitrate and output the table entry of the label prediction table where the hit hash result is located and the second speculative update queue as the second output result.

[0088] In an embodiment of the present application, the hash result includes a tag hash and an index hash, the tag field and the index field included in the second speculative update queue are the first hash fields, and the tag field and the index field included in the speculative allocation queue are the second hash fields.

[0089] Optionally, the hash result is input into a label prediction table for table lookup and matching, and the hash result is matched with the first hash field to obtain a second matching result.

[0090] The second matching result is a match hit or a non-match hit. If a match hits, the entry last inserted into the queue is selected as the hit entry, and the u field and the updated ctr in the entry are output.

[0091] Optionally, the hash result is input into a label prediction table for table lookup and matching, and the hash result is matched with the second hash field to obtain a third matching result.

[0092] Among them, the third matching result is a match hit or a non-match hit. If a match hits, the table entry last inserted into the queue is selected as the hit table entry, and the u field and the updated ctr in the table entry are output.

[0093] Furthermore, when both the second matching result and the third matching result are match hits, the output of the label prediction table is obtained as the second output result by arbitrating the table entries contained in the second matching result, the third matching result, the second speculation update queue, and the speculation allocation queue according to the preset priority from high to low.

[0094] Step 204: arbitrate and predict the first output result and the second output result to obtain a branch prediction result.

[0095] Optionally, when the tag prediction table or the second speculation update queue or the speculation allocation queue hits, the entry with the longest hit global history length is selected for prediction, otherwise the first output result is used for prediction.

[0096] Furthermore, the table entry includes a counter and a jump direction, and the counter is updated in response to a match between the instruction address and the predicted branch instruction address.

[0097] It should be noted that the first speculative update queue includes a predicted branch instruction address. When the instruction address matches the predicted branch instruction address, it indicates that the prediction is made through the result of the basic table. The basic table output result, that is, the ctr in the first output result is updated, that is, when taken=1, ctr is incremented, otherwise it is decremented.

[0098] In the embodiment of the present application, when multiple entries are matched simultaneously, the counter is updated according to the jump direction corresponding to the last inserted entry.

[0099] Furthermore, when the hit table entry belongs to the tag prediction table, the counter value of the table entry in the tag prediction table is updated and inserted at the tail of the second speculation update queue; when the hit table entry belongs to the basic table, the counter value of the table entry in the basic table is updated and inserted at the tail of the first speculation update queue; and the enqueue pointer of each queue is recorded.

[0100] In an embodiment of the present application, if the hit table item belongs to the label prediction table, indicating that the result of the label prediction table is used for prediction, the ctr in the output result of the label prediction table is updated, that is, when taken=1, ctr is incremented, otherwise it is decremented, and the hit label prediction table sequence number (table_idx), index, tag, jump direction (taken), ctr, and u are inserted into the tail of the speculation update queue of the label prediction table as the new table item content. If the hit table item belongs to the basic table, indicating that the result of the basic table is used for prediction, the ctr in the output result of the basic table is updated, that is, when taken=1, ctr is incremented, otherwise it is decremented, and the jump direction (taken), ctr, and pc are inserted into the tail of the speculation update queue of the basic table as the new table item content. Record the queue entry pointer of each queue at this time.

[0101] Furthermore, when an instruction is predicted, the prediction information to be allocated when a branch prediction error occurs is calculated in advance according to the TAGE allocation algorithm, and a new speculative allocation queue entry is generated when a branch prediction error generates a redirection.

[0102] In the embodiment of the present application, the allocation information to be used when the branch prediction is wrong is calculated, including the serial number (table_idx), index and tag of the label prediction table to be allocated. A table can be randomly selected from the label prediction table with a table serial number greater than the longest match as the allocation table.

[0103] Optionally, in the event of a branch prediction error, clear the first speculative update queue, the second speculative update queue, and the table entries of the speculative allocation queue located after the enqueue pointer at the time of prediction; update the jump direction corresponding to the enqueue pointer in the speculative update queue; generate a new speculative allocation queue table entry based on the hash result and the correct branch jump result, and insert it at the tail of the speculative allocation queue.

[0104] In the embodiment of the present application, in the case of a branch prediction error, the processor sends the branch jump direction, the queue entry pointers of each queue during prediction, and the allocation information calculated during prediction to the TAGE predictor, and uses this information to clear old table entries and allocate new table entries. The process is as follows:

[0105] Clear all entries in all speculative update queues and speculative allocation queues that follow the enqueue pointer at the time of prediction.

[0106] The update speculates that the taken field of the entry corresponding to the queue pointer in the update queue is the jump direction of the branch.

[0107] Generate ctr according to the jump direction (taken) of the branch, that is, when taken=1, ctr is 4, otherwise it is 3. Insert the table_idx, index, tag in the allocation information, the jump direction taken of the current branch, and the initialized u field as the new table entry content into the tail of the speculative allocation queue.

[0108] Furthermore, when a branch instruction is submitted, if the instruction has a corresponding base table speculation update queue entry, the ctr field of the entry is written into the base table, the corresponding write position is the position specified by the pc field, and the corresponding entry in the speculation update queue is cleared. If the instruction has a corresponding tag prediction table speculation update queue entry and speculation allocation queue entry, the ctr in the entry is updated, and the updated ctr and tag are written into the tag prediction table specified by the table_idx field of the entry, the corresponding write position is the position specified by the index field, and the corresponding entries in the speculation update queue entry and speculation allocation queue are cleared.

[0109] like Figure 3As shown, the branch predictor includes a base table, a label prediction table, a first speculation update queue corresponding to the base table, a second speculation update queue corresponding to the label prediction table, and a speculation allocation queue. Hash operations are performed on multiple global branch histories and instruction addresses respectively to obtain hash results. The instruction addresses are respectively input into the base table and the first speculation update queue for matching to determine the first output result of the base table. In the case of redirection, the hash results are respectively input into the label prediction table, the second speculation update queue, and the speculation allocation queue to determine the second output result of the label prediction table; the first output result and the second output result are arbitrated and predicted to obtain the branch prediction result.

[0110] In this embodiment, by obtaining the global branch history and the instruction address of the branch instruction, and performing hash operations on the global branch history and the instruction address respectively, a hash result is obtained; the instruction address in the basic table that matches the predicted branch instruction address is determined as the hit instruction address; according to the preset priority, the table entry of the basic table where the hit instruction address is located and the first speculation update queue are arbitrated and output as the first output result; the hash result is input into the label prediction table, the second speculation update queue and the speculation allocation queue respectively, so as to determine the second output result of the label prediction table based on the second matching result of the hash result and the first hash field included in the second speculation update queue, and the third matching result of the hash result and the second hash field included in the speculation allocation queue; the first output result and the second output result are arbitrated and predicted to obtain the branch prediction result. By adding the speculation update queue and the speculation allocation queue to the TAGE branch predictor, when making a prediction, the new prediction information is sent to the speculation queue, and when making a subsequent prediction, the prediction information in the speculation queue is used first, which can solve the training delay problem caused by the long pipeline, improve the warm-up speed of the TAGE, and thus improve the average prediction accuracy.

[0111] In order to implement the above embodiments, the present application also proposes a branch prediction device based on speculative update.

[0112] Figure 4 A schematic diagram of the structure of a branch prediction device based on speculative update provided in an embodiment of the present application.

[0113] like Figure 4 As shown, the branch prediction device 400 based on speculative update is applied to a branch predictor, which includes a basic table, a label prediction table, a first speculative update queue corresponding to the basic table, a second speculative update queue corresponding to the label prediction table, and a speculative allocation queue, including: an acquisition module 401, a first output module 402, a second output module 403, and a prediction module 404.

[0114] The acquisition module 401 is used to acquire the global branch history and the instruction address of the branch instruction, and perform hash operations on the global branch history and the branch instruction respectively to obtain a hash result;

[0115] A first output module 402, configured to input the instruction address into the base table and the first speculative update queue respectively, so as to determine a first output result of the base table based on a first matching result between the instruction address and the predicted branch instruction address included in the first speculative update queue;

[0116] A second output module 403, used to input the hash result into the label prediction table, the second speculation update queue and the speculation allocation queue respectively, so as to determine a second output result of the label prediction table based on a second matching result between the hash result and the first hash field included in the second speculation update queue and a third matching result between the hash result and the second hash field included in the speculation allocation queue;

[0117] The prediction module 404 is used to arbitrate and predict the first output result and the second output result to obtain a branch prediction result.

[0118] Furthermore, the first speculative update appendix includes a plurality of table items. In a possible implementation of the embodiment of the present application, the first output module 402 is specifically configured to:

[0119] Determine an instruction address in the base table that matches the predicted branch instruction address as the hit instruction address;

[0120] According to a preset priority, the table entry of the basic table where the hit instruction address is located and the first speculative update queue are arbitrated and then output as a first output result.

[0121] The table entry includes a counter and a jump direction. In response to a match between the instruction address and the predicted branch instruction address, the counter is updated.

[0122] When multiple entries are matched simultaneously, the counter is updated according to the jump direction corresponding to the last inserted entry.

[0123] Further, the second speculative update queue includes multiple entries. In a possible implementation of the embodiment of the present application, the second output module 403 is specifically used to:

[0124] Determine a hash result in the tag prediction table that matches the first hash field and a hash result that matches the second hash field as a hit hash result;

[0125] According to the preset priority, the table entry of the tag prediction table where the hit hash result is located and the second speculative update queue are arbitrated and output as the second output result.

[0126] Furthermore, in a possible implementation of the embodiment of the present application, the prediction module 404 is specifically configured to:

[0127] When the tag prediction table or the second speculation update queue or the speculation allocation queue hits, the entry with the longest hit global history length is selected for prediction, otherwise the first output result is used for prediction.

[0128] Furthermore, in a possible implementation of the embodiment of the present application, the device is also used for:

[0129] If the entry belongs to the tag prediction table, the counter value of the entry in the tag prediction table is updated and inserted into the tail of the second speculation update queue;

[0130] If the entry belongs to the base table, the counter value of the entry of the base table is updated and inserted into the tail of the first speculative update queue;

[0131] Record the queue entry pointer of each queue.

[0132] In the case of a branch prediction error, clearing the first speculative update queue, the second speculative update queue, and the table entries of the speculative allocation queue that are located after the queue pointer at the time of prediction;

[0133] Update the jump direction corresponding to the queue pointer in the speculation update queue;

[0134] According to the hash result and the correct branch jump result, a new speculative allocation queue entry is generated and inserted into the tail of the speculative allocation queue.

[0135] It should be noted that the above explanation of the embodiment of the branch prediction method based on speculative updating is also applicable to the branch prediction device based on speculative updating of this embodiment, which will not be repeated here.

[0136] In the embodiment of the present application, by obtaining the global branch history and the instruction address of the branch instruction, and performing hash operations on the global branch history and the instruction address respectively, to obtain the hash result; the instruction address is respectively input into the base table and the first speculation update queue, so as to determine the first output result of the base table based on the first matching result between the instruction address and the predicted branch instruction address included in the first speculation update queue; the hash result is respectively input into the label prediction table, the second speculation update queue and the speculation allocation queue, so as to determine the second output result of the label prediction table based on the second matching result between the hash result and the first hash field included in the second speculation update queue, and the third matching result between the hash result and the second hash field included in the speculation allocation queue; the first output result and the second output result are arbitrated and predicted to obtain the branch prediction result. By adding the speculation update queue and the speculation allocation queue to the TAGE branch predictor, when making a prediction, the new prediction information is sent to the speculation queue, and when making a subsequent prediction, the prediction information in the speculation queue is used first, which can solve the training delay problem caused by the long pipeline, improve the warm-up speed of the TAGE, and thus improve the average prediction accuracy.

[0137] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the branch prediction method based on speculative update provided by the above embodiments.

[0138] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which, when executed by a processor, implements the branch prediction method based on speculative update provided by the above embodiments.

[0139] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0140] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.

[0141] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.

[0142] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0143] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0144] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0145] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0146] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0147] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0148] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0149] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A branch prediction method based on speculative update, characterized in that: Applied to a branch predictor, the branch predictor includes a base table, a tag prediction table, a first speculation update queue corresponding to the base table, a second speculation update queue corresponding to the tag prediction table, and a speculation allocation queue, including the following steps: Obtaining a global branch history and an instruction address of a branch instruction, and performing hash operations on the global branch history and the branch instruction respectively to obtain a hash result; inputting the instruction address into the base table and the first speculative update queue respectively, so as to determine a first output result of the base table based on a first matching result between the instruction address and a predicted branch instruction address included in the first speculative update queue; Inputting the hash result into a label prediction table, the second speculation update queue, and the speculation allocation queue, respectively, to determine a second output result of the label prediction table based on a second matching result between the hash result and a first hash field included in the second speculation update queue and a third matching result between the hash result and a second hash field included in the speculation allocation queue; Arbitrating and predicting the first output result and the second output result to obtain a branch prediction result, wherein when the tag prediction table or the second speculation update queue or the speculation allocation queue hits, selecting the table entry with the longest global history length to make a prediction, otherwise using the first output result to make a prediction; The first speculative update queue and the second speculative update queue each include a plurality of table entries, wherein the table entries include a counter and a jump direction; Based on a first matching result between the instruction address and the predicted branch instruction address included in the first speculative update queue, determining a first output result of the base table, including: determining an instruction address in the base table that matches the predicted branch instruction address as a hit instruction address, and arbitrating, according to a preset priority, an entry in the base table where the hit instruction address is located and the first speculative update queue, and outputting the result as the first output result; Determine the second output result of the label prediction table, including: determining the hash result in the label prediction table that matches the first hash field and the hash result that matches the second hash field as hit hash results; according to a preset priority, arbitrate the table entry in the label prediction table where the hit hash result is located and the second speculative update queue and output them as the second output result.

2. The branch prediction method based on speculative update according to claim 1, characterized in that: The method further comprises: In response to a match between the instruction address and the predicted branch instruction address, the counter is updated.

3. The branch prediction method based on speculative update according to claim 2, characterized in that: The updating of the counter comprises: In the case of matching multiple entries at the same time, the counter is updated according to the jump direction corresponding to the last inserted entry.

4. The branch prediction method based on speculative update according to claim 1, characterized in that: The method further comprises: In the case where the entry belongs to the label prediction table, updating the counter value of the entry of the label prediction table and inserting it into the tail of the second speculation update queue; If the entry belongs to a base table, updating the counter value of the entry of the base table and inserting it into the tail of the first speculative update queue; Record the queue entry pointer of each queue.

5. The branch prediction method based on speculative update according to claim 4, characterized in that: The method further comprises: In the case of a branch prediction error, clearing the first speculation update queue, the second speculation update queue, and the table entries of the speculation allocation queue that are located after the queue pointer at the time of prediction; Updating the jump direction corresponding to the queue entry pointer in the speculation update queue; A new speculative allocation queue entry is generated according to the hash result and the correct branch jump result, and is inserted into the tail of the speculative allocation queue.

6. A branch prediction device based on speculative updating, characterized in that: Applied to a branch predictor, the branch predictor includes a base table, a tag prediction table, a first speculation update queue corresponding to the base table, a second speculation update queue corresponding to the tag prediction table, and a speculation allocation queue, including: An acquisition module, used for acquiring a global branch history and an instruction address of a branch instruction, and performing hash operations on the global branch history and the branch instruction respectively to obtain a hash result; a first output module, configured to input an instruction address into the base table and the first speculative update queue respectively, so as to determine a first output result of the base table based on a first matching result between the instruction address and a predicted branch instruction address included in the first speculative update queue; a second output module, configured to input the hash result into the label prediction table, the second speculation update queue, and the speculation allocation queue, respectively, so as to determine a second output result of the label prediction table based on a second matching result between the hash result and the first hash field included in the second speculation update queue and a third matching result between the hash result and the second hash field included in the speculation allocation queue; A prediction module, used to arbitrate and predict the first output result and the second output result to obtain a branch prediction result, wherein when the tag prediction table or the second speculation update queue or the speculation allocation queue hits, the table entry with the longest global history length is selected for prediction, otherwise the first output result is used for prediction; The first speculative update queue and the second speculative update queue each include a plurality of table entries, wherein the table entries include a counter and a jump direction; Based on a first matching result between the instruction address and the predicted branch instruction address included in the first speculative update queue, determining a first output result of the base table, including: determining an instruction address in the base table that matches the predicted branch instruction address as a hit instruction address, and arbitrating, according to a preset priority, an entry in the base table where the hit instruction address is located and the first speculative update queue, and outputting the result as the first output result; Determine the second output result of the label prediction table, including: determining the hash result in the label prediction table that matches the first hash field and the hash result that matches the second hash field as hit hash results; according to a preset priority, arbitrate the table entry in the label prediction table where the hit hash result is located and the second speculative update queue and output them as the second output result.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 5 when executed by a processor.

Citation Information

Patent Citations

  • Executing branch instructions following a speculation barrier instruction

    CN111045731A

  • Branch prediction method and device and storage medium

    CN117909254A