Tagged geometric (TAGE) branch predictors use a combination of tagged TAGE table entries and increasing history lengths in order to generate predictions for a branch instruction. To do so, the TAGE branch predictor maintains a single, large global branch history describing whether previously encountered branches were taken or not taken. Portions of the global branch history of geometrically increasing lengths are used to index TAGE tables to generate the prediction. As the size of the global branch history increases, folding can be used to calculate the indexes for the TAGE tables. However, generating these folded values are computationally intensive and require significant computation time to build for each prediction cycle.
Tagged geometric (TAGE) branch predictors maintain a global branch history for generating predictions. Portions of the global branch history of geometrically increasing lengths are used to index TAGE tables to generate the prediction. As the size of the global branch history increases, folding can be used to calculate the indexes for the TAGE tables. However, generating these folded values are computationally intensive and require significant computation time to build for each prediction cycle.
The present specification sets forth various implementations for managing large TAGE histories. In some implementations, a tagged geometric (TAGE) branch predictor for managing large TAGE histories is disclosed. Such a TAGE branch predictor includes a global branch history including a circular buffer, a plurality of TAGE tables, and a plurality of folded branch histories. Each folded branch history of the plurality of folded branch histories corresponds to a TAGE table of the plurality of TAGE tables. The folded branch histories are each based on different length subsets of the global branch history.
In some implementations, the TAGE branch predictor generates the plurality of folded branch histories by subdividing, for each of TAGE table of the plurality of TAGE tables, a corresponding subset of the global branch history into equal length portions, and generating, for each TAGE table of the plurality of TAGE tables, a corresponding folded branch history by applying a function to the equal length portions. In some implementations, the function includes an XOR function. In some implementations, the TAGE branch predictor updates the plurality of folded branch histories without regenerating the plurality of folded branch histories from the global branch history. In some implementations, the TAGE branch predictor generates, for a branch prediction cycle, a checkpoint for the plurality of folded branch histories. In some implementations, the TAGE branch predictor restores, in response to a flush for the branch prediction cycle, the plurality of folded branch histories based on the checkpoint. In some implementations, the different length subsets of the global branch history are of geometrically increasing length.
The present specification also describes various implementations for a method of managing large TAGE histories. Such methods include storing a global branch history of a tagged geometric (TAGE) branch predictor including a circular buffer and generating, for each TAGE table of a plurality of TAGE tables, a folded branch history of a plurality of folded branch histories. The folded branch histories are each based on different length subsets of the global branch history. Such methods also include storing the plurality of folded branch histories.
In some implementations, generating the plurality of folded branch histories includes subdividing, for each of TAGE table of the plurality of TAGE tables, a corresponding subset of the global branch history into equal length portions, and generating, for each TAGE table of the plurality of TAGE tables, a corresponding folded branch history by applying a function to the equal length portions. In some implementations, the function includes an XOR function. In some implementations, the method further includes updating the plurality of folded branch histories without regenerating the plurality of folded branch histories from the global branch history. In some implementations, the method further includes generating, for a branch prediction cycle, a checkpoint for the plurality of folded branch histories. In some implementations, the method further includes restoring, in response to a flush for the branch prediction cycle, the plurality of folded branch histories based on the checkpoint. In some implementations, the different length subsets of the global branch history are of geometrically increasing length.
Also described in this specification are various implementations of an apparatus for managing large TAGE histories. Such an apparatus includes computer memory and a processor operatively coupled to the computer memory. The processor includes a TAGE branch predictor. The TAGE branch predictor includes a global branch history, a plurality of TAGE tables, and a plurality of folded branch histories. The global branch history also includes a circular buffer. Each folded branch history of the plurality of folded branch histories corresponds to a TAGE table of the plurality of TAGE tables and the folded branch histories are each based on different length subsets of the global branch history.
In some implementations, the TAGE branch predictor generates the plurality of folded branch histories by: subdividing, for each of TAGE table of the plurality of TAGE tables, a corresponding subset of the global branch history into equal length portions, and generating, for each TAGE table of the plurality of TAGE tables, a corresponding folded branch history by applying a function to the equal length portions. In some implementations, the function is an XOR function. In some implementations, the TAGE branch predictor updates the plurality of folded branch histories without regenerating the plurality of folded branch histories from the global branch history. In some implementations, the TAGE branch predictor generates, for a branch prediction cycle, a checkpoint for the plurality of folded branch histories. In some implementations, the TAGE branch predictor restores, in response to a flush for the branch prediction cycle, the plurality of folded branch histories based on the checkpoint.
The following disclosure provides many different implementations, or examples, for implementing different features of the provided subject matter. Specific examples of components and arrangements are described below to simplify the present disclosure. These are, of course, merely examples and are not intended to be limiting. For example, the formation of a first feature over or on a second feature in the description that follows include implementations in which the first and second features are formed in direct contact, and also include implementations in which additional features be formed between the first and second features, such that the first and second features are not in direct contact. Further, spatially relative terms, such as “beneath,” “below,” “lower,” “above,” “upper,” “back,” “front,” “top,” “bottom,” and the like, are used herein for ease of description to describe one element or feature's relationship to another element(s) or feature(s) as illustrated in the figures. Similarly, terms such as “front surface” and “back surface” or “top surface” and “back surface” are used herein to more easily identify various components, and identify that those components are, for example, on opposing sides of another component. The spatially relative terms are intended to encompass different orientations of the device in use or operation in addition to the orientation depicted in the figures.
The processor 104 includes a TAGE branch predictor 102 for managing large TAGE histories according to some implementations described in further detail below. The TAGE branch predictor 102 performs a branch prediction on instructions provided to the processor 104 for execution (e.g., instructions loaded from memory 106). The TAGE branch predictor 102 uses a TAGE algorithm to perform branch prediction as will be described in further detail below.
To generate the prediction 202, the TAGE branch predictor 200 maintains multiple TAGE tables 204a-n. Each TAGE table 204a-n is a logical table that includes a plurality of entries. As will be described in further detail below, each TAGE table 204a-n is indexed based on an increasingly long portion of branch prediction history, with the utilized lengths of branch prediction history increasing according to a geometric sequence.
For further explanation of a TAGE TABLE,
Returning to
As the global branch history 206 is of limited size, after the global branch history 206 is full, an oldest entry should be removed when a newest entry is added. In existing solutions, prediction branch histories 206 are stored using an N-bit shift register. When a new entry is added to the global branch history 206, the entire register is shifted by a single bit and a bit is stored at the new head of the register. The amount of power required to perform this bit shift increases as the size of the shift register increases. Accordingly, a large global branch history 206 using a shift register would require a large amount of power to shift the register for each update to the global branch history 206.
To address this concern, in some implementations, the global branch history 206 is instead implemented using an array, such as the array depicted in the example of
Consider an example where the head pointer 404 identifies entry Hn-2 and the tail pointer 406 identifies entry H0, with entry Hn-1 currently unused. An update to the global branch history 206 will then cause a value to be stored at entry Hn-1 and the head pointer 404 to be updated to identify the entry Hn-1. The array 402 is now full, with all entries storing a value for the global branch history. Another update will require an oldest value to be removed from the array 402. Accordingly, in response to another update, the tail pointer 406 will be updated to identify entry Hi, the head pointer 404 will be updated to identify entry H0, and the value for the update will then be stored at entry H0. Additional updates will continue to cause the head pointer 404 and tail pointer 406 to be updated, with the value for the latest update to be stored at the entry identified by the updated head pointer 404.
As will be appreciated by one skilled in the art, updating a global branch history implemented using an array 402, head pointer 404 and tail pointer 404 only requires modification of a single entry in the array 402 and updates to the head pointer 404 and, if the array 402 is full, the tail pointer 404. This provides considerable power savings when compared to shifting a shift register of sufficiently large size.
Again returning to
As the number of global branch history 206 bits used for a given TAGE table 204a-n (hereinafter referred to as “history bits”) increases, the number of history bits used will exceed the number of bits needed to index a TAGE table 204a-n (e.g., to identify a particular entry in the TAGE table 204a). For example, a TAGE table 204a-n with 1024 entries only needs ten bits to identify any of the entries. Accordingly, before hashing the PC 210 with the history bits, in some implementations the used history bits are “folded” on themselves to generate a folded branch history 212a-n.
The history bits are “folded” by subdividing the history bits into portions of equal length (e.g., corresponding to the number of bits needed to identify an entry in the TAGE table 204a-n) and then applying an XOR function to combine each of the portions into a single portion. Assuming N history bits used for a given TAGE table 204a-n and assuming M bits are needed to identify an entry in the TAGE table 204a-n, the N history bits are divided into N/M portions of M bits and XOR-ed together to create a single folded branch history 212a-n of M bits. For example, assume that a given TAGE table 204a-n with 2024 entries (therefore needing 10 bits to index) uses 500 bits of the global branch history 206. These 500 bits are divided into fifty 10-bit portions. These fifty portions are then XOR-ed together to create a single 10-bit folded branch history 212a-n from which an index 208a-n is generated.
In some implementations, a folded branch history 212a-n for each TAGE table 204a-n is calculated from the global branch history 206 each time a branch prediction is to be performed. However, this requires significant computational and time resources, and would require a large number of XOR gates in order to be implemented in hardware as the size of the global branch history 206 grows. Instead, in some implementations, the TAGE branch predictor 200 includes allocated portions of memory to logically store the folded branch history 212a-n for each TAGE table 204a-n. When the global branch history 206 is updated, instead of recalculating the folded branch history 212a-n for each TAGE table 204a-n, the stored folded branch histories 212a-n are modified to reflect the update (e.g., by shifting or rotating the folded branch history 212a-n, modifying one or more bits in the shifted value, accessing particular bits in the global branch history 206 to calculate particular bits in the folded branch history 212a-n, etc.). Thus, the folded branch history 212a-n for each TAGE table 204a-n is maintained without the need to fully recalculate each folded branch history 212a-n on an update to the global branch history 206.
In addition to the TAGE tables 204a-n, the TAGE branch predictor 200 also maintains a base predictor 214. The base predictor 214 is a table of counters indexed using the PC 210 that will provide a default prediction 202 if no entries in the TAGE tables 204a-n match the calculated indexes 208a-n.
To generate a prediction 202 for a given branch instruction, the TAGE branch predictor 200 calculates, for each TAGE table 204a-n, a tag 216a-n. Each tag 216a-n is calculated as a function (e.g., by hashing, XOR-ing, and the like) of the PC 210 and the bits of the global branch history 206 used by the corresponding TAGE table 204a-n. Though the indexes 208a-n and tags 216a-n are both generated as a function of the PC 210, the particular functions used to calculate the indexes 208a-n and tags 216a-n are different. For example, in some implementations, tags 216a-n and indexes 208a-n are of different lengths. Accordingly, in some implementations, a tag 216a-n for a given TAGE table 204a-n is calculated by folding the bits of the global branch history 206 used by that TAGE table 204a-n using portions having a number of bits equal to the number of bits used in a given tag 216a-n.
For each TAGE table 204a-n, where an entry is found at the corresponding index 208a-n, a counter (such as counter 302 of
A processor or core including the TAGE branch predictor 200 will then speculatively fetch and execute instructions based on the provided prediction 202. For example, where the prediction 202 indicates that a branch is taken, instructions will be fetched and executed from the target of the branch. As another example, where the prediction 202 indicates that a branch is not taken, instructions will be fetched and executed as if the branch was not taken. In certain circumstances, the prediction 202 is incorrect (e.g., a misprediction). In other words, it was predicted that a branch would be taken but was not, or it was predicted that a branch would not be taken but was. Accordingly, an instruction pipeline must be flushed and instructions fetched and executed from the correct point in the instruction cycle. Pipeline flushes also occur for reasons other than mispredicts, such as serialization requirement or occurrence of some error in the instruction stream.
Part of a flush will include restoring the TAGE branch predictor to a state prior to the flush (e.g., to a state used to generate the incorrect prediction 202 for the branch instruction) and then update the state to reflect the actual action taken for the branch instruction. For example, the global branch history 206 is rolled back by a number of updates performed including and after the incorrect prediction 202. Where folded branch histories 212a-n are stored and maintained, the folded branch histories 212a-n are restored to states corresponding to the rolled back global branch history 206.
In order to resume performing branch predictions, the TAGE branch predictor 200 needs the indexes 208a-n sooner in the prediction cycle than the tags 216a-n. As described herein, a prediction cycle (e.g., a branch prediction cycle), is the process of generating a prediction 202 for a given branch instruction. Thus, each branch instruction subject to prediction by the TAGE branch predictor 200 has its own branch prediction cycle. Accordingly, in some implementations, to reduce the time required to restore folded branch histories 212a-n, the TAGE branch predictor 200 generates, in response to receiving a branch instruction for prediction (e.g., every prediction cycle), a checkpoint storing a state of each of the folded branch histories 212a-n.
For example, in some implementations, the TAGE branch predictor 200 saves checkpoints for some number of most recent prediction cycles such that, if a flush occurs, the folded branch histories 212a-n are restored from the checkpoint corresponding to the mispredicted branch instruction. The global branch history 206 and the folded branch histories 212a-n are then updated to reflect the actual branch path taken instead of the previously generated prediction 202. At the next prediction cycle, the indexes 208a-n are then recalculated from the restored folded branch histories 212a-n. As the tags 216a-n are needed later in the prediction cycle, the tags 216a-n need not be saved in a checkpoint and are recalculated from the global branch history 206.
In some implementations, the TAGE branch predictor 200 of
The computer 500 of
The example computer 500 of
The exemplary computer 500 of
For further explanation,
The global branch history 206 is encoded, embodied, or implemented as a circular buffer. For example, the global branch history 206 is implemented as an array (such as the array 402 of
The method of
A folded branch history (e.g., 212a-n of
Generating 604 the folded branch history also includes applying a function to the equal length portions. In some implementations, the function includes an XOR function. Thus, to generate the folded branch history, each of the portions are XOR-ed together to generate a folded branch history having a number of bits needed to identify an entry in the TAGE table.
The method of
For further explanation,
For further explanation,
The method of
In view of the explanations set forth above, readers will recognize that the benefits of managing large TAGE histories include:
Exemplary implementations of the present disclosure are described largely in the context of a fully functional computer system for managing large TAGE histories. Readers of skill in the art will recognize, however, that the present disclosure also can be embodied in a computer program product disposed upon computer readable storage media for use with any suitable data processing system. Such computer readable storage media can be any storage medium for machine-readable information, including magnetic media, optical media, or other suitable media. Examples of such media include magnetic disks in hard drives or diskettes, compact disks for optical drives, magnetic tape, and others as will occur to those of skill in the art. Persons skilled in the art will immediately recognize that any computer system having suitable programming means will be capable of executing the steps of the method of the disclosure as embodied in a computer program product. Persons skilled in the art will recognize also that, although some of the exemplary implementations described in this specification are oriented to software installed and executing on computer hardware, nevertheless, alternative implementations implemented as firmware or as hardware are well within the scope of the present disclosure.
The present disclosure can be a system, a method, and/or a computer program product. The computer program product can include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present disclosure.
The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium can be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network can include copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present disclosure can be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider). In some implementations, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) can execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.
Aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to implementations of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
These computer readable program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions can also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein includes an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various implementations of the present disclosure. In this regard, each block in the flowchart or block diagrams can represent a module, segment, or portion of instructions, which includes one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block can occur out of the order noted in the figures. For example, two blocks shown in succession can, in fact, be executed substantially concurrently, or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
It will be understood from the foregoing description that modifications and changes can be made in various implementations of the present disclosure. The descriptions in this specification are for purposes of illustration only and are not to be construed in a limiting sense. The scope of the present disclosure is limited only by the language of the following claims.