Embodiments generally relate to instruction processing within a micro-processor, and more particularly to the handling of branch operation misprediction in a micro-processor.
Microprocessors employ branch prediction to improve performance. Traditional processor architectures include one or more branch predictors in the form of a digital circuit that predicts which way a code branch instruction (e.g., an if-then-else block, another conditional, or a jump statement) will proceed prior to its execution. A subsequent unit may then execute the branch instruction and validate the results of the branch prediction. This branch result validation circuit is often referred to as a branch execution unit or jump execution unit. Based on the branch prediction, one or more micro-operations that follow the predicted branch in program order may be fetched, scheduled, and/or speculatively executed. Without branch prediction, the processor may operate less efficiently given that it would have to wait until the branch or jump instruction has executed (e.g., until it has determined which program path to follow) before determining subsequent instructions to fetch. Thus, branch prediction enables an improved flow in an instruction pipeline of a processor.
Unfortunately, there are instances when a branch predictor circuit mispredicts the branch (i.e., predicts incorrectly). In such cases, the processor performs a clearing process to remove those micro-operations that were fetched, scheduled to execute, partially executed, and/or fully executed in anticipation of the branch being followed. The speed of mispredict detection, the execution of the clearing process, and the subsequent fetching, scheduling, and execution of the correct instructions has a direct impact on performance of a processor.
The detailed description is described with reference to the accompanying figures. In the figures, the left-most digit(s) of a reference number identifies the figure in which the reference number first appears. The same reference numbers in different figures indicate similar or identical items.
Embodiments are described that incorporate a second jump execution unit (JEU) into a processor to operate concurrently and/or in parallel with a first JEU to concurrently execute branches, and/or concurrently detect branch mispredicts on a first JEU and a second JEU. A code branch executes in a JEU of a processor, and after execution the actual branch direction is compared to the previously predicted branch direction to determine whether a mispredict has occurred. A certain amount of time (e.g., four instruction cycles) elapses from when a branch is scheduled to execute until it actually executes and a mispredict is potentially detected. During that time period, various units of the processor are informed that a JEU is preparing to execute a branch and that those units should therefore be prepared, in the event of a mispredict, to back out all micro-operations younger than the branch (e.g., operations that were fetched after the branch) because they were incorrectly speculated and are not from the proper program path.
When a mismatch between the actual branch direction and the predicted branch direction is detected, a mispredict is signaled and a clearing process is initiated to clear the incorrectly speculated micro-operations from the processor. In some embodiments, this clearing process is a core-wide clearing process to clear the core of all micro-operations younger than the branch. The speed at which a processor detects mispredicts and clears the incorrectly speculated micro-operations may be critical for processor performance. In general, branches may potentially execute out of order, and the clearing process may begin immediately after the mispredict is detected instead of waiting for the branch to retire.
When executing certain programs, it may be advantageous to execute two branches per cycle and evaluate two branches per cycle for any mispredicts, such as when running multi-threaded programs with two independently executing threads, single-threaded programs with a high density of branch operations, or in other situations. However, previous processor micro-architectures may be limited to initiating only one core-wide clearing process per instruction cycle. Given that, it may be advantageous in some situations to be able to handle concurrently detected branch mispredicts while still supporting existing micro-architectural elements that enable the initiation of a single core-wide clearing process per cycle.
Therefore, embodiments described herein support a second JEU in a processor to provide for concurrent branch evaluation with a first JEU, and support concurrent branch mispredicts by allowing the second JEU to employ the mispredict signaling mechanisms available to the first JEU. In some embodiments, the second JEU is a low-cost JEU that has reduced functionality compared to the first JEU. For example, the first JEU may have connections to other units of the processor core and accordingly be able to signal to the other units that they should prepare for a possible mispredict and to signal the other units when a mispredict occurs. In some embodiments, the second JEU lacks such capability. Moreover, in some embodiments the second JEU is further limited in that it supports certain types of branches, such as branches that are predicted to fall through (e.g., such that the fetch unit predicted that the condition was not true and continued fetching code at the instruction after the branch). Also, in some embodiments the second JEU may support certain subsets of branch conditions, may be limited to supporting unconditional branches (e.g., branches that always evaluate as true), and/or may be unable to support indirect branches.
Embodiments are described herein for four different example scenarios that employ the second JEU in conjunction with the first JEU. In a first example scenario, two branch mispredicts are detected concurrently (e.g., in a same instruction cycle) by the first and second JEUs. In this case, the second JEU triggers the scheduling of its branch processing and a core-wide clearing process into the first JEU's dispatch pipeline a certain number of instruction cycles later than the first JEU's branch processing. This later scheduling is referred to herein as a skid process. This first example scenario is described further herein with regard to
In a second example scenario, a branch mispredict on the second JEU causes a skid dispatch to be requested on the first JEU at the same time as a “nuke” command is received from another unit of the processor such as a reorder buffer (ROB), and the nuke also requests the same dispatch slot on the first JEU (e.g., a nuke-skid collision). As used herein, a nuke is a command to remove all unretired micro-operations currently in the machine for the specified thread. In some embodiments, the ROB may send such a message when there is an interrupt or other type of event that necessitates flushing the pipeline. When a nuke is detected, a dispatch slot on the first JEU is reserved for the nuke. Because the nuke mechanism uses the same clearing protocol as a branch mispredict, there may be no simultaneous mispredict on that cycle on the same port. Therefore, when there is a collision between nuke and skid the branch processing for the second branch mispredict is skidded farther down the pipeline and scheduled to occur after the processing of the nuke command (e.g., delayed one cycle). This example scenario is discussed further herein with regard to
In a third example scenario, the second JEU is promoted to have access to the mispredict mechanisms normally accessible to the first JEU. In some embodiments, all communications about a mispredict are processed through the first JEU. However, in some cases when the first JEU has a non-branch micro-operation scheduled (e.g., an add operation), the second JEU is promoted to take control of the various buffers for handling a mispredict. In such cases, the second JEU is in effect acting as though it is the first JEU, until it has completed its operations related to processing the branch and/or the branch mispredict. This example scenario is discussed further herein with regard to
The fourth example scenario is similar to the first example scenario, but with an added element of an older mispredict detected on the first JEU after the second JEU skids a mispredict but before the second JEU's mispredict takes control of the first JEU's controls to initiate the core-wide clearing process described above. In this scenario, all operations younger than this newly detected older mispredict are cleared out, including the skidded second JEU branch operations. A similar yet somewhat different process may be performed when an older nuke command is received from the ROB. These examples are described further herein with regard to
In the descriptions below, the first and second JEUs are referred to alternatively as primary and secondary JEUs. However, this identification of primary and secondary JEUs is not in itself intended as a limiting description of these components.
Each branch operation may be scheduled by the scheduler 104 to execute in one of the JEUs. As described above, architecture 100 with two JEUs operating in parallel enables two branch mispredicts to be detected concurrently (e.g., in a single instruction cycle) and processed as described further herein. As shown in
In some embodiments, secondary JEU 112 does not have access to the buffers and/or mechanisms for initiating the core-wide clearing process when a branch mispredict is directed. Therefore, when it detects a mispredict for a branch operation, secondary JEU 112 may write information associated with the mispredict into skid buffer/counter 114. This information may include a target address as well as information to assist in updating the branch predictors with the actual outcome, to improve future predictions. The information saved in skid buffer/counter 114 may then be used to initiate the core-wide clearing process.
Further, architecture 100 may include a branch order buffer (BOB) 116.
In some embodiments, BOB 116 maintains an entry that stores address information for each branch operation in a currently executing program. When a branch operation executes in primary JEU 110, address information for the taken branch (e.g., the actually taken target of the branch) is written to BOB 116. When the branch operation retires, target address information (e.g., the address of a next instruction to execute) may then be retrieved from the BOB 116. Then, the BOB 116 may communicate that information to a reorder buffer (ROB) 118, which keeps track of a current position within the currently executing program. Thus, for each taken branch, BOB 116 may update ROB 118 with address information for the next instruction after the branch in program order, so that the ROB 118 may update the current position within the program.
In some embodiments, the primary JEU 110 has the ability to write to either the BOB 116 or the ROB 118. However, the secondary JEU 112 may not able to write a taken target to BOB 116, though it may be able to write to ROB 118 to mark a branch as executed and complete. Thus, the secondary JEU 112 may be described as a low-cost JEU with somewhat more limited capabilities than those of the primary JEU 110.
Though not shown in
Moreover, in some embodiments secondary JEU 112 may be promoted so that it has the ability to write to the BOB 116 and ROB 118, and the ability to initiate a core-wide clearing process in response to a detected mispredict and write to the BOB 116. This promotion scenario is described in greater detail below with regard to
As further shown in
As shown in this example, primary JEU 110 and primary JEU DP 106 have the ability to send the mispredict message 122 and the prepare-for-mispredict message 120 respectively, but the secondary JEU 112 and its DP do not have this ability. Thus, secondary JEU 122 may employ the mechanisms of the primary JEU 110 to initiate a core-wide clearing process to clear the core of those instructions that are younger than the second branch, when a mispredict is detected by secondary JEU 112. In such cases, the secondary JEU 112 may send a message 124 to the scheduler 104 to reserve one or more slots in primary JEU DP 106 to send a prepare-for-mispredict message 120 and to initiate the core-wide clearing process by sending a mispredict message 122. When those reserved slots arrive in the primary JEU DP 106, information regarding the mispredict is retrieved from skid buffer/counter 114 in a retrieve-mispredict-information message 126. This process of the secondary JEU 112 using the mispredict mechanisms of primary JEU 110 is referred to herein as skidding, and is described in greater detail below.
System memory 202 may also include one or more executable components 206, including components, programs, applications, and/or processes, that are loadable and executable by processor(s) 100. System memory 202 may further store program/component data 208 that is generated and/or employed by executable component(s) 206 and/or operating system(s) 204 during their execution.
As shown in
In general, computer-readable media includes computer storage media and communications media.
Computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structure, program modules, and other data. Computer storage media includes, but is not limited to, RAM, ROM, erasable programmable read-only memory (EEPROM), SRAM, DRAM, flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disks (DVDs) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information for access by a computing device.
In contrast, communication media may embody computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transmission mechanism. As defined herein, computer storage media does not include communication media.
Computing system 200 may include input device(s) 214, including but not limited to a keyboard, a mouse, a pen, a game controller, a voice input device for speech recognition, a touch input device, a camera device for capturing images and/or video, one or more hardware buttons, and the like. Computing system 200 may further include output device(s) 216 including but not limited to a display, a printer, audio speakers, a haptic output, and the like. Computing system 200 may further include communications connection(s) 218 that allow computing system 200 to communicate with other computing device(s) 218, including client devices, server devices, databases, and/or other networked devices available for communication over a network.
Generally, computer-executable instructions include routines, programs, objects, modules, components, data structures, and the like that perform particular functions or implement particular abstract data types. The order in which the operations are described is not intended to be construed as a limitation, and any number of the described operations can be combined in any order, subdivided into multiple sub-operations, and/or executed in parallel to implement the described processes. The example processes illustrated by
At 302 a first branch mispredict is detected at the first JEU (e.g., the primary JEU). At 304 a second branch mispredict is detected at a second JEU (e.g., the secondary JEU) concurrently with the detection of the first branch mispredict at the first JEU. In some embodiments, detection of the two branch mispredicts may occur within a same instruction cycle of the processor. As described above, when a branch mispredict is detected a core-wide clearing process is initiated to instruct other components of the processor to remove micro-operations younger than the branch.
Because the second JEU does not have access to the mechanisms for initiating the core-wide clearing process, one or more skid operations are performed to enable an initiation of the core-wide clearing process using mechanisms available to the first JEU. These skid operations are described in more detail with regard to
At 308 a core-wide clearing process is scheduled in the DP for a first JEU, based on the information stored in the skid buffer at 306. As described above, this core-wide clearing process clears the core of instructions that are younger than the second branch. In some embodiments, the core-wide clearing process is scheduled at a predetermined number of instruction cycles after detection of the second branch mispredict by the second JEU. At 310 the core clearing is initiated from the first JEU when the scheduled core clearing instructions arrive at the first JEU.
The rows of
At this stage, the primary JEU sends a message (e.g., mispredict message 122) informing the other components of the processor that a mispredict has been detected for Branch A, and initiating the core-wide clearing process. However, because a single mispredict may be signaled in a particular instruction cycle, the detected mispredict on Branch B triggers a skid by which the five-stage branch process is scheduled later in the primary
JEU DP 404 to occur after the five-stage process for Branch A. In the example depicted, at column 414 the skid is scheduled and a slot is reserved for Branch B two instruction cycles after the mispredict is signaled for Branch A. Then, the other stages of the five-stage process are scheduled as part of the skid. For example, at column 416 branch information for Branch B is sent to the other units of the processor to inform them that Branch B may mispredict. At column 418 the mispredict signal for Branch B is sent, informing the other units that a mispredict has occurred. In this way, the skid process reschedules the five-stage branch process to occur later in the primary JEU pipeline, enabling two simultaneously detected branch mispredicts to be processed one after another using the primary JEU's mechanisms for signaling a mispredict.
In some embodiments, the skid process is such that the core-wide clearing corresponding to Branch B is scheduled to occur at a predetermined number of cycles after detection of the Branch B mispredict. For example, this predetermined number may be set at six cycles. In the example, to accomplish this, the dispatch slot on the primary JEU is reserved two cycles after Branch B mispredicts in the secondary JEU to ensure that no other operations are being executed on the primary JEU when the Branch B mispredict is signaled. In this way, the skidding process may be described as self-timed, such that the skid for Branch B is scheduled at a predetermined number of instruction cycles later than the initially scheduled processing of Branch B in the secondary JEU DP. In other embodiments, Branch B may be re-dispatched and re-executed from scratch, rather than relying on skid buffers.
In some embodiments, the skid mechanism is employed in cases when the primary and secondary JEUs are simultaneously executing branch operations in a same program thread. When the primary JEU's branch is younger in program order than the secondary JEU's branch, initiating a core clearing based on the primary JEU's branch fails to clear out operations speculatively fetched, scheduled, and/or executed for the second branch prediction. Thus, the secondary JEU's branch may be skidded to ensure that such operations are cleared. However, when the primary JEU's branch is older in program order than the secondary JEU's branch, a skid may not be performed given that the core clearing initiated by the first branch mispredict on the primary JEU also clears operations related to the second branch on the secondary JEU.
In another example, in cases when the primary and secondary JEUs are executing branch operations in separate, independent threads and both branches mispredict, the branch for the secondary JEU is skidded to ensure successful core clearing for the second branch mispredict. Moreover, in some cases two branches may be scheduled to execute concurrently on the primary and secondary JEUs, and the second branch mispredicts but the first branch does not mispredict. In these scenarios, the secondary JEU did not send the prepare-to-mispredict signal and has no access to the core clearing controls, so a skid is triggered to enable the secondary JEU access to the core clearing functionality of the primary JEU according to the mechanism described.
In some cases a branch mispredict is detected on the secondary JEU, and additionally the ROB signals a nuke command to remove all micro-operations currently in the DP. As described above, the ROB may send a nuke when there is an interrupt or other type of event that necessitates flushing the pipeline. As described above, such cases may be described as a collision between the nuke and the secondary JEU skid request given that both the nuke and the secondary JEU mispredict may both attempt to employ mechanisms of primary JEU DP to perform their respective operations. Therefore, embodiments provide a means to detect when such a collision takes place and account for it by skidding the branch processing for the second branch mispredict farther down in the primary JEU DP, so that it is scheduled to occur after the processing of the nuke command. This scenario is illustrated in
At 508 a nuke command or instruction is received from the ROB (e.g., ROB 118). In some embodiments, the nuke command may be an early nuke command, i.e. an early indication that the processor will nuke or is likely to nuke. At 510 the processing of the second branch mispredict is skidded such that a core clearing is scheduled for the second branch mispredict farther down in the primary JEU DP. In some embodiments this skidding is similar to the skidding described above with regard to
At column 612 mispredicts are simultaneously detected by the primary JEU and the secondary JEU for Branch A and Branch B respectively. During this cycle, the primary JEU sends the mispredict message corresponding to the Branch A mispredict, instructing the other units of the processor to initiate a core-wide clearing process to clear all micro-operations younger than Branch A, as described above. During the same instruction cycle, the mispredict for Branch B triggers a skid such that the five-stage branch processing is scheduled later in the primary JEU DP (e.g., skidded).
At column 614 an early nuke command is received from the ROB. This early nuke is scheduled into the primary JEU DP to be performed after the primary JEU mispredict is signaled at column 612. Then, the skidded five-stage branch process for the second branch mispredict is delayed an additional at least one instruction cycle to column 618, such that a slot is reserved for the Branch B skid at column 618. At column 620 nuke information is sent to the other units in the processor instructing them to prepare for the nuke. At column 622 the five-step branch process for Branch B proceeds with the sending of branch information for Branch B to the other units of the processor (e.g., a prepare-for-mispredict message). At column 624 the nuke command is sent to the other units and a target address is sent to the fetch unit, and at column 626 the mispredict signal is sent to trigger the core-wide clearing for the detected Branch B mispredict. If the nuke command and the Branch B mispredict are on the same thread, the core-wide clearing operation for Branch B is suppressed because the nuke is older.
At 706 based on these detected operations of 702 and 704, the DP for the second JEU is provided with access to the buffers and/or other mechanisms for initiating a core-wide clearing process. For example, the second JEU may be provided with the means to send the prepare-for-mispredict message 120 and the mispredict message 122. At 708 the second JEU DP sends branch information to the other units of the processor warning them of a possible branch mispredict (e.g., sends a prepare-for-mispredict message). At 710 the second JEU initiates a core clearing process on detecting a mispredict on its branch operation. Though not shown in
Moreover, in some embodiments a policy may dictate that promotion is permitted only in situations where the first JEU is idle (i.e., no operation is scheduled) simultaneously with a branch operation on the second JEU. In some embodiments, promotion of the second JEU may be determined when there are no other operations scheduled on the first JEU that use the mispredict signals (i.e., that use the taken address wires to the fetch unit).
In this example, because a non-branch operation is detected in the primary JEU DP, the secondary JEU is promoted and is therefore able to itself send the branch information for Branch B to the other units in the processor at column 810. Moreover, the secondary JEU is also able to send the mispredict message for Branch B to initiate a core-wide clearing process at column 812. In some embodiments after the secondary JEU completes its processing for Branch B (e.g., after the branch is retired), the secondary JEU is demoted and returns to its limited functionality state such that it is no longer able to directly initiate a clearing process in response to a mispredict.
Some embodiments support an additional example scenario in which an older mispredict is detected on the primary JEU after the secondary JEU skids for the same thread. This scenario is similar to the first skid scenario described above with regard to
At 910 an indication is received from the first JEU of a third branch mispredict that is older in program order than either the first or second branch mispredicts. At 912, in response to this indication, the initiation of the previously scheduled core clearing is blocked. In some embodiments, this includes deleting or invalidating the stored information regarding the second branch mispredict from the skid buffer, and/or setting the skid counter back to its initialization state as if there had been no skid at all for the second branch processing. In some embodiments, each mispredict that is detected by the primary JEU is compared to any mispredicts that are currently being skidded. If the newly detected mispredict is older in program order than the previously skidded mispredicts, those previously skidded mispredicts are blocked and/or cleared from the skid buffer. In this way, some embodiments may ensure that no mispredict is signaled that is younger than another detected and skidded mispredict.
Some embodiments may accommodate similar though somewhat different scenarios in which an older nuke command is received from the ROB, i.e., a nuke command that is older in program order than either the first or second branch mispredicts on the same thread. In such cases, indication of an older nuke prompts the blocking and/or clearing of a previously skidded mispredict on the second JEU as described above.
At column 1010 the branch information for Branch A is sent from the primary JEU DP to other units in the processor (e.g., a prepare-for-mispredict message is sent). At column 1012 the primary JEU signals a mispredict on Branch A, to initiate a core clearing process for that branch. In the same instruction cycle, the secondary JEU detects a mispredict on Branch B and skids as described above. After the skid, an older mispredict (or nuke command) is detected by the primary JEU. Although
The examples above describe cases when there is a branch in the skid, but the skid has not yet reached the primary JEU when the primary JEU signals an older mispredict or nuke. Some embodiments support an additional case when the skid is active and has not yet reached the primary JEU, and the secondary JEU has an older mispredict while the first JEU is active with another branch. In such cases the secondary JEU also skids, and because it is older it clears the younger mispredict out of the skid, and restarts the skid process with this older secondary mispredict.
Table 1 summarizes possible scenarios and actions taken in response to those scenarios, according to embodiments. In Table 1, the first column describes the information (e.g., a signal) received on a port for the Primary JEU. The second column describes information received on a port for the Secondary JEU. The third column lists information received on a port for the ROB. The fourth column describes the action taken in each scenario.
In the example of row 1, the primary and secondary JEUs are each executing a branch operation in a same thread and each mispredicts. If the mispredict on the primary JEU is older, then a core clearing process initiated for this older mispredict also clears operations associated with the second mispredict, and therefore no action is taken to skid the branch on the secondary JEU.
In the example of row 2, the primary and secondary JEUs are each executing a branch operation in a same thread and each mispredicts. In this example scenario, the mispredict on the primary JEU is for a younger branch, and the branch on the secondary JEU skids as described above with regard to
In the example of row 3, the primary and secondary JEUs are executing branch operations on different program threads, and each branch mispredicts. Because the branches are on different, independently executing threads, both mispredicts are handled (e.g., a core clearing process is initiated to account for each mispredict). Thus, in this example scenario, the secondary JEU branch skids as described above with regard to
In the example of row 4, a branch executed by the primary JEU does not mispredict and a branch executed by the secondary JEU does mispredict. In this example, a core clearing process is to be initiated for the secondary JEU's branch and a skid is triggered to enable the secondary JEU access to the core clearing functionality of the primary JEU.
In the example of row 5, a non-branch operation (or no operation) is executing on the primary JEU (or the primary JEU is idle) and the secondary JEU is executing a branch operation. In this example, the secondary JEU is promoted as described above with regard to
In the example of row 6, a branch is executing on the primary JEU and secondary JEU mispredicts requiring a skid, and a signal is received the ROB requesting the same primary JEU dispatch slot as the skidded branch to process a nuke. In this example, the skid is delayed to take place after the nuke operations as described above with regard to
In the example of row 7, a branch is executing on the primary JEU and the secondary JEU mispredicts requiring a skid, and the primary JEU subsequently executes a ROB-requested nuke command that is older than the mispredict for the same thread. That is, the ROB signal is a nuke signal that occurs between the time the skid was written and the time the skid was read. In this example, the skid of the secondary JEU's branch is blocked as described above with regard to
In the example of row 8, the primary and secondary JEUs are each executing a branch operation, but neither mispredicts. Thus, in this example no action is performed.
Though not listed in Table 1, some embodiments support an additional case where the secondary JEU needs a skid but there is already a branch in the skid buffer. If the newly skidded branch is younger than the one that is currently in the skid buffer, then its mispredict is cleared by the older mispredict that is currently in the skid buffer. However, if the newly skidded branch is older than the one that is currently in the skid buffer, then the skid buffer is cleared and the newly skidded branch starts its own skid process.
Finally, some embodiments may support an alternative approach in which the skidded branch micro-operations are redispatched by the scheduler down the primary JEU's pipeline, rather than skidding the result from the secondary JEU. This may still consume a certain number of cycles (e.g., six cycles) before the branch would arrive at the primary JEU as in the skidding cases discussed above. However, in many cases compare and branch micro-operations are combined into a single “fused” micro-operation by the micro-architecture. In such situations, the skid mechanism could result in lower power because the comparison operation is not re-computed. The comparison result is ready immediately after the branch executes on the secondary JEU and may be used by another consumer the following cycle rather than waiting for the redispatch to complete.
Although the techniques have been described in language specific to structural features and/or methodological acts, it is to be understood that the appended claims are not necessarily limited to the specific features or acts described. Rather, the specific features and acts are disclosed as example forms of implementing such techniques.
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/US11/67656 | 12/28/2011 | WO | 00 | 6/14/2013 |