Branch prediction result determination method and electronic device

By introducing the collaborative work of the main thread and the lookout thread into the processor, and using the warning signal to determine the true branch prediction result, the pipeline flushing problem caused by branch prediction misprediction is solved, and the system processing performance is improved.

CN120994254BActive Publication Date: 2026-01-23INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511519720.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-01-23
Estimated Expiration
2045-10-23

AI Technical Summary

Technical Problem

Existing processors have a high misprediction rate during branch prediction, which leads to pipeline flushing and clock cycle loss, affecting system processing performance.

Method used

The main thread detects the starting address of the critical code region, updates the warning signal, and the lookout thread determines the actual branch prediction result after querying the warning signal. The main thread then executes the branch prediction part according to the result.

Benefits of technology

This improves the accuracy of branch prediction, avoids pipeline flushing and clock cycle loss, and enhances system processing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994254B_ABST
    Figure CN120994254B_ABST
Patent Text Reader

Abstract

The application discloses a branch prediction result determination method and an electronic device, and relates to the technical field of performance optimization. In the case that the main thread detects the first address of the key code region, the early warning signal corresponding to the key code region is updated at this time. The early warning signal can know the execution process of the main thread. The main thread executes the code data in the key code region, and when the branch prediction part in the code data is executed, the branch prediction result is obtained from the branch prediction unit. The branch prediction result is determined by the foresight thread after the early warning signal is queried, and is real. Then, the branch prediction part in the code data is executed according to the branch prediction result. By adopting the technical scheme, the code branch trend can be obtained more accurately, and the pipeline emptying and loss of clock cycles caused by branch misprediction can be avoided, and the processing performance of the system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of performance optimization technology, and in particular to a method for determining branch prediction results and an electronic device. Background Technology

[0002] Modern processors commonly employ branch prediction and out-of-order execution to enhance instruction-level parallelism. The Branch Prediction Unit (BPU) is a key component in implementing this mechanism, predicting the direction of branch instructions or jump addresses to ensure the continuity of the instruction flow.

[0003] Traditional branch predictors, such as local or global history predictors, primarily rely on statistical predictions based on historical records, such as whether the most recent branch was "T-NT-TT" or "TT-NT-NT". For some branches, the prediction pattern is highly random or depends on complex external data, such as pointer dereferencing, linked list traversal, or long-latency data correlations. In these cases, the accuracy of the history predictor drops drastically. Each misprediction of a branch causes a pipeline cleanup, resulting in the loss of tens of clock cycles, which is a significant performance bottleneck for high-performance applications.

[0004] Therefore, there is an urgent need for a method to determine the branch prediction result, which can obtain a relatively accurate code branch direction, thereby avoiding pipeline flushing and clock cycle loss due to branch misprediction, and thus improving the system's processing performance. Summary of the Invention

[0005] This application provides a method and electronic device for determining branch prediction results, which can obtain more accurate code branch paths, thereby avoiding pipeline flushing and clock cycle loss due to branch misprediction, and thus improving the system's processing performance.

[0006] This application provides a method for determining branch prediction results, applied to a processor, the method comprising:

[0007] When the main thread detects the starting address of a critical code region, it updates the warning signal corresponding to that critical code region; wherein, the critical code region is the code region where the branch misprediction rate is higher than a threshold; the warning signal is used to characterize the execution process of the main thread.

[0008] The main thread executes the code data in the critical code region, and when it reaches the branch prediction part of the code data, it obtains the branch prediction result from the branch prediction unit and executes the branch prediction part of the code data according to the branch prediction result; wherein, the branch prediction result in the branch prediction unit is determined by the look-ahead thread after querying the warning signal.

[0009] This application also provides a branch prediction result determination device, applied to a processor, the device comprising:

[0010] An update module is used to update the warning signal corresponding to a critical code region when the main thread detects the starting address of the critical code region; wherein, the critical code region is a code region where the branch misprediction rate is higher than a threshold; and the warning signal is used to characterize the execution process of the main thread.

[0011] The first acquisition module is used to execute code data in the key code region through the main thread, and when executing the branch prediction part in the code data, to obtain the branch prediction result from the branch prediction unit, and to execute the branch prediction part in the code data according to the branch prediction result; wherein, the branch prediction result in the branch prediction unit is determined by the look-ahead thread after querying the warning signal.

[0012] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described branch prediction result determination methods.

[0013] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described branch prediction result determination methods.

[0014] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described branch prediction result determination methods.

[0015] This application describes a method where, upon detecting the starting address of a critical code region, the main thread updates a warning signal corresponding to that region. This warning signal indicates the execution progress of the main thread. The main thread then executes the code data within the critical code region. When it reaches the branch prediction portion of the code data, it retrieves the branch prediction result from the branch prediction unit. This branch prediction result is determined by the lookahead thread after detecting the warning signal and is accurate. The branch prediction portion of the code data is then executed according to the predicted result. By employing this technical solution, since the branch prediction result is determined by the lookahead thread after detecting the warning signal and is accurate, a more accurate code branch path can be obtained. This avoids pipeline flushing and lost clock cycles due to mispredicted branches, thereby improving system processing performance. Attached Figure Description

[0016] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 A schematic diagram of an architecture for determining branch prediction results provided in an embodiment of this application;

[0018] Figure 2 A flowchart illustrating a method for determining branch prediction results provided in an embodiment of this application;

[0019] Figure 3 A flowchart illustrating a method for determining branch prediction results provided in an embodiment of this application;

[0020] Figure 4 This is a schematic diagram of a branch prediction result determination device provided in an embodiment of this application. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0022] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0023] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0024] The specific architecture upon which the method execution depends is determined by combining the branch prediction results; this specific architecture is described here. For details, please refer to... Figure 1 The diagram shows an architecture for determining branch prediction results.

[0025] This application provides a method for determining branch prediction results, applied to a processor. The method is described in detail below, along with its execution flow. For specific details, please refer to... Figure 2 The diagram illustrates a method for determining branch prediction results. The steps of this method are as follows:

[0026] S201. When the main thread detects the starting address of a critical code region, it updates the warning signal corresponding to the critical code region; whereby the critical code region is the code region where the branch misprediction rate is higher than a threshold; the warning signal is used to characterize the execution process of the main thread.

[0027] In one example, the main thread represents the thread that primarily executes code data. Critical code regions are code regions where the branch misprediction rate exceeds a threshold, where the threshold could be 70%. That is, critical code regions are code regions where branch misprediction occurs frequently. For example, the code region to be executed by the main thread is [A, B, C, D], where B and C are critical code regions.

[0028] In this embodiment, the lookahead thread and the main thread are different threads. The lookahead thread is used to represent an auxiliary thread to the main thread. Specifically, the lookahead thread is used to assist the main thread in calculating the branch prediction result. For example, the total number of threads is 3, namely thread 1, thread 2, and thread 3, with thread 1 designated as the main thread and thread 2 as the lookahead thread. Alternatively, thread 1 can be designated as the lookahead thread and thread 2 as the main thread.

[0029] In this embodiment, each critical code region has a warning signal, which can be a warning_flag. Specifically, the warning signal corresponding to critical code region B is warning_flagB. In this embodiment, if the main thread detects the starting address of critical code region B, it updates warning_flagB. At this time, if the lookahead thread detects the updated warning_flagB, it analyzes the code data in critical code region B.

[0030] S202. The main thread executes the code data in the critical code area, and when it executes the branch prediction part in the code data, it obtains the branch prediction result from the branch prediction unit and executes the branch prediction part in the code data according to the branch prediction result; wherein, the branch prediction result in the branch prediction unit is determined by the look-ahead thread after querying the warning signal.

[0031] In one example, the main thread executes code data within a critical code region. This code data includes branch predictions. When executing the branch prediction section, the branch prediction result needs to be retrieved from the branch prediction unit. The branch prediction result in the branch prediction unit is determined by the lookahead thread after detecting a warning signal, and this branch prediction result is accurate. Then, after retrieving the branch prediction result, the branch prediction portion of the code data is executed according to the branch prediction result.

[0032] This application provides a method for determining branch prediction results. When the main thread detects the starting address of a critical code region, it updates the warning signal corresponding to that region. This warning signal indicates the execution progress of the main thread. The main thread executes the code data within the critical code region, and when it reaches the branch prediction part of the code data, it retrieves the branch prediction result from the branch prediction unit. This branch prediction result is determined by the lookahead thread after querying the warning signal and is accurate. Then, the branch prediction part of the code data is executed according to the branch prediction result. By adopting this technical solution, since the branch prediction result is determined by the lookahead thread after querying the warning signal and is accurate, a more accurate code branch path can be obtained. This avoids pipeline flushing and lost clock cycles due to mispredicted branches, thereby improving system processing performance.

[0033] This application provides a method for determining branch prediction results, applied to a processor. The method is described in detail below, along with its execution flow. For specific details, please refer to... Figure 3 The diagram illustrates a method for determining branch prediction results. The steps of this method are as follows:

[0034] S301. Use the main thread to call the performance analysis tool and identify at least one critical code region in the main thread based on the performance analysis tool.

[0035] In one example, the performance analysis tool could be the perf tool. This tool identifies critical code regions in the main thread; since there may be more than one critical code region, each region is identified using the performance analysis tool.

[0036] S302. Based on performance analysis tools, record the starting address and ending address of the critical code region; whereby the starting address is used to represent the address where the code data of the critical code region begins; and the ending address is used to represent the address where the code data of the critical code region ends.

[0037] In one example, performance analysis tools are used to record the starting and ending addresses of each critical code region. This allows the location of each critical code region within the code data processed by the main thread to be determined using its starting and ending addresses.

[0038] In one example, the method also includes:

[0039] The main thread obtains the context synchronization information of the critical code region and records the context synchronization information, the critical code region, the starting address of the critical code region, and the ending address of the critical code region in a preset array. Among them, the context synchronization information, the critical code region, the starting address of the critical code region, and the ending address of the critical code region are used by the lookahead thread to determine the branch prediction result in the branch prediction unit.

[0040] In one example, the preset array could be a signal warning array. For instance, if the main thread obtains `critical_area_num` critical code regions, the length of the signal warning array would be `critical_area_num`. The starting and ending addresses of the critical code regions are recorded in `signal[current_area].branch_addr`. Since there may be multiple critical code regions, storing their information in an array allows the lookahead thread to access and calculate the branch prediction result for each critical code region.

[0041] S303. When the main thread detects the starting address of a critical code region, it updates the warning signal corresponding to the critical code region; wherein, the critical code region is the code region where the branch misprediction rate is higher than a threshold; the warning signal is used to characterize the execution process of the main thread.

[0042] In one example, this step can be found in step S201.

[0043] S304. The code data in the key code area is executed by the main thread, and when the branch prediction part in the code data is executed, the branch prediction result is obtained from the branch prediction unit, and the branch prediction part in the code data is executed according to the branch prediction result; wherein, the branch prediction result in the branch prediction unit is determined by the look-ahead thread after the warning signal is queried.

[0044] In one example, this step can be found in step S202.

[0045] In one example, the starting address of the critical code region in the main thread is the same as the starting address of the corresponding critical code region in the lookahead thread; the ending address of the critical code region in the main thread is the same as the ending address of the corresponding critical code region in the lookahead thread.

[0046] In one example, the starting and ending addresses of the critical code regions of the main thread and the lookahead thread are the same. The advantage of this setting is that when the main thread executes a certain critical code region, the lookahead thread locates the same critical code region, which can ensure the accuracy of the branch prediction results in the branch prediction unit determined by the lookahead thread.

[0047] In one example, the main thread and the lookahead thread reside on different multithreaded cores on the same physical core.

[0048] In one example, the main thread and the lookahead thread are configured to have identical index bits in the branch target buffer or pattern history table. Since the indexes in the branch target buffer and pattern history table typically only use a subset of virtual address bits, patterns with different addresses but the same low-order address can be mapped to the same prediction table entry. This allows the main thread and the lookahead thread to index the same prediction table entry in the branch prediction unit. The advantage of this setup is that the entries in the branch prediction unit can be used immediately and directly by the main thread.

[0049] In one example, the initial computation states of the main thread and the lookahead thread are synchronized.

[0050] In one example, if the branch prediction part of the code data depends on shared, unchanging data, such as a lookup table, the lookahead thread can directly read this data.

[0051] If the branch prediction part in the code data depends on intermediate variables calculated by the main thread, such as a loop counter, when the main thread sends an alert signal, it also needs to copy the values ​​of the variables that the branch prediction part in the code data depends on into the context synchronization information, and the lookahead thread reads these values ​​to initialize its own computing environment.

[0052] S305. When a warning signal is detected by the lookup thread, the key code region corresponding to the warning signal, the context synchronization information of the key code region, the starting address of the key code region, and the ending address of the key code region are obtained from a preset array.

[0053] In one example, when the lookout thread polls for warning_flagB, it retrieves the critical code region corresponding to the warning signal, the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region from the signal warning array.

[0054] S306. The lookahead thread determines the branch prediction result in the code data of the critical code region based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region.

[0055] In one example, the lookahead thread determines the branch prediction result in the code data of the critical code region B based on the context synchronization information of the critical code region B, the starting address of the critical code region B, and the ending address of the critical code region B.

[0056] In one example, the lookahead thread determines the branch prediction results in the code data of the critical code region based on the context synchronization information, the starting address, and the ending address of the critical code region. This includes:

[0057] The lookahead thread determines the actual branch direction and the actual target address based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region.

[0058] The lookahead thread modifies the entries in the branch prediction unit based on the actual branch direction and the actual target address until the branch prediction result is obtained; the branch prediction result is the branch prediction result in the code data of the critical code region.

[0059] In one example, the lookahead thread first determines the actual branch direction and the actual target address based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region. Then, it modifies the entries in the branch prediction unit with the actual branch direction and the actual target address. Specifically, this can be achieved by executing the instructions in the branch prediction unit multiple times to obtain the branch prediction result.

[0060] In one example, the lookahead thread determines the actual branch direction and the actual target address based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region, including:

[0061] The lookahead thread initializes its computational parameters based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region.

[0062] The lookahead thread determines the actual branch direction and the actual target address based on the calculation parameters.

[0063] In one example, the main thread executes and updates code data in real time. Therefore, the lookahead thread needs to initialize its calculation parameters based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region. This ensures that the lookahead thread's calculation parameters are up-to-date, thereby enabling accurate calculation of the actual branch direction and the actual target address.

[0064] In one example, after invoking a performance analysis tool via the main thread and identifying at least one critical code region in the main thread based on the performance analysis tool, the method further includes:

[0065] Start a lookup thread and poll the early warning signals in real time through the lookup thread.

[0066] The advantage of this setup is that the lookout thread is only activated when needed, avoiding unnecessary computational and power consumption overhead.

[0067] This application provides a method for determining branch prediction results. The method includes: when a lookahead thread polls for a warning signal, it retrieves the critical code region corresponding to the warning signal, the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region from a preset array; the lookahead thread then determines the branch prediction result in the code data of the critical code region based on the context synchronization information, the starting address, and the ending address of the critical code region. Using this technical solution, before the main thread executes a branch that is difficult to predict, the lookahead thread pre-calculates the prediction result of the branch and modifies the pre-calculated branch prediction result in the branch prediction unit. When the main thread executes this branch, it can directly obtain the correct branch prediction result from the branch prediction unit, thereby improving the accuracy of branch prediction.

[0068] Figure 4 This is a schematic diagram of a branch prediction result determination device provided in an embodiment of this application. This device is applied to a processor and can be understood as the aforementioned electronic device or a functional module within the aforementioned electronic device. Figure 4 As shown, the branch prediction result determination device 40 includes:

[0069] The update module 401 is used to update the warning signal corresponding to the critical code region when the main thread detects the starting address of the critical code region; wherein, the critical code region is the code region where the branch misprediction rate is higher than a threshold; the warning signal is used to characterize the execution process of the main thread;

[0070] The first acquisition module 402 is used to execute code data in the key code area through the main thread, and when the execution reaches the branch prediction part in the code data, it obtains the branch prediction result from the branch prediction unit and executes the branch prediction part in the code data according to the branch prediction result; wherein, the branch prediction result in the branch prediction unit is determined by the look-ahead thread after querying the warning signal.

[0071] In one example, before the starting address of the critical code region is detected by the main thread, device 40 also includes:

[0072] The identification module 403 is used to invoke a performance analysis tool through the main thread and identify at least one critical code region in the main thread based on the performance analysis tool.

[0073] The first recording module 404 is used to record the starting address and the ending address of the critical code region based on performance analysis tools; wherein, the starting address is used to represent the address where the code data of the critical code region begins; and the ending address is used to represent the address where the code data of the critical code region ends.

[0074] In one example, device 40 also includes:

[0075] The second recording module 405 is used to obtain the context synchronization information of the key code region through the main thread, and record the context synchronization information, the key code region, the starting address of the key code region and the ending address of the key code region in a preset array; wherein, the context synchronization information, the key code region, the starting address of the key code region and the ending address of the key code region are used by the lookahead thread to determine the branch prediction result in the branch prediction unit.

[0076] In one example, the starting address of the critical code region in the main thread is the same as the starting address of the corresponding critical code region in the lookahead thread; the ending address of the critical code region in the main thread is the same as the ending address of the corresponding critical code region in the lookahead thread.

[0077] In one example, the main thread and the lookahead thread reside on different multithreaded cores on the same physical core.

[0078] In one example, the initial computation states of the main thread and the lookahead thread are synchronized.

[0079] In one example, device 40 includes:

[0080] The second acquisition module 406 is used to acquire the key code region corresponding to the warning signal, the context synchronization information of the key code region, the starting address of the key code region and the ending address of the key code region from a preset array when the warning signal is polled by the lookup thread.

[0081] The determination module 407 is used to determine the branch prediction results in the code data of the critical code region by using the lookahead thread based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region.

[0082] In one example, module 407 is identified, including:

[0083] The first determination submodule is used to determine the actual branch direction and the actual target address by using the lookahead thread based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region.

[0084] The second determination submodule is used to modify the entries in the branch prediction unit according to the actual branch direction and the actual target address through the lookahead thread until the branch prediction result is obtained; wherein, the branch prediction result is the branch prediction result in the code data of the critical code region.

[0085] In one example, the first determined submodule is specifically used for:

[0086] The lookahead thread initializes its computational parameters based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region.

[0087] The lookahead thread determines the actual branch direction and the actual target address based on the calculation parameters.

[0088] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0089] For a description of the features in the embodiment corresponding to the branch prediction result determination device, please refer to the relevant description of the embodiment corresponding to the branch prediction result determination method, which will not be repeated here.

[0090] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above-described branch prediction result determination method embodiments.

[0091] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described branch prediction result determination method embodiments when run.

[0092] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0093] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described branch prediction result determination method embodiments.

[0094] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described branch prediction result determination method embodiments.

[0095] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments claimed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0096] The foregoing has provided a detailed description of a branch prediction result determination method provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A method for determining branch prediction results, characterized in that, Applied to a processor, the method includes: When the main thread detects the starting address of a critical code region, it updates the warning signal corresponding to that critical code region; wherein, the critical code region is the code region where the branch misprediction rate is higher than a threshold; the warning signal is used to characterize the execution process of the main thread. The main thread executes the code data in the key code area, and when it executes the branch prediction part in the code data, it obtains the branch prediction result from the branch prediction unit and executes the branch prediction part in the code data according to the branch prediction result. When the lookout thread polls for the warning signal, it retrieves the key code region corresponding to the warning signal, the context synchronization information of the key code region, the starting address of the key code region, and the ending address of the key code region from a preset array. The lookahead thread determines the actual branch direction and the actual target address based on the context synchronization information of the key code region, the starting address of the key code region, and the ending address of the key code region. The lookahead thread modifies the entries in the branch prediction unit based on the actual branch direction and the actual target address until the branch prediction result is obtained; wherein, the branch prediction result is the branch prediction result in the code data of the critical code region.

2. The method for determining branch prediction results according to claim 1, characterized in that, Before the main thread detects the starting address of the critical code region, the method further includes: The main thread invokes a performance analysis tool, and at least one of the critical code regions in the main thread is identified based on the performance analysis tool. Based on the performance analysis tool, the starting address and the ending address of the critical code region are recorded; wherein, the starting address is used to represent the address where the code data of the critical code region begins; and the ending address is used to represent the address where the code data of the critical code region ends.

3. The method for determining branch prediction results according to claim 2, characterized in that, The method further includes: The main thread obtains the context synchronization information of the key code region, and records the context synchronization information, the key code region, the starting address of the key code region, and the ending address of the key code region in a preset array; wherein, the context synchronization information, the key code region, the starting address of the key code region, and the ending address of the key code region are used by the lookahead thread to determine the branch prediction result in the branch prediction unit.

4. The method for determining branch prediction results according to claim 2, characterized in that, The starting address of the critical code region in the main thread is the same as the starting address of the corresponding critical code region in the lookahead thread; the ending address of the critical code region in the main thread is the same as the ending address of the corresponding critical code region in the lookahead thread.

5. The method for determining branch prediction results according to claim 1, characterized in that, The main thread and the lookahead thread reside on different multi-threaded cores on the same physical core.

6. The method for determining branch prediction results according to claim 1, characterized in that, The initial computational states of the main thread and the lookahead thread are synchronized.

7. The method for determining branch prediction results according to claim 1, characterized in that, The step of determining the actual branch direction and the actual target address by the lookahead thread based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region includes: The lookahead thread initializes its calculation parameters based on the context synchronization information of the critical code region, the starting address of the critical code region, and the ending address of the critical code region. The lookahead thread determines the actual branch direction and the actual target address based on the calculation parameters.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the branch prediction result determination method as described in any one of claims 1 to 7 when executing the computer program.

Citation Information

Patent Citations

  • Instruction, Circuits, and Logic for Data Capture for Software Monitoring and Debugging

    US20170286111A1

  • Application performance analysis method and apparatus, computing device, system, and storage medium

    WO2024187838A1