Register renaming
In computer architecture, register renaming is a technique that abstracts logical registers from physical registers. Every logical register has a set of physical registers associated with it. When a machine language instruction refers to a particular logical register, the processor transposes this name to one specific physical register on the fly. The physical registers are opaque and cannot be referenced directly but only via the canonical names. This technique is used to eliminate false data dependencies arising from the reuse of registers by successive instructions that do not have any real data dependencies between them. The elimination of these false data dependencies reveals more... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
In computer architecture, register renaming is a technique that abstracts logical registers from physical registers. Every logical register has a set of physical registers associated with it. When a machine language instruction refers to a particular logical register, the processor transposes this name to one specific physical register on the fly. The physical registers are opaque and cannot be referenced directly but only via the canonical names. This technique is used to eliminate false data dependencies arising from the reuse of registers by successive instructions that do not have any real data dependencies between them. The elimination of these false data dependencies reveals more instruction-level parallelism in an instruction stream, which can be exploited by various and complementary techniques such as superscalar and out-of-order execution for better performance. Individual registers in the file are referred to by number in the machine code. Encoding a number in the machine code requires several bits. For instance, in the Zilog Z80 there were eight general-purpose registers in the file. To select one of eight values requires three bits, as 2 3 = 8. More architectural (logical) registers of the same width and type can result in better performance, as more temporary values can be held in registers and thus avoid the expensive operations of saving or loading from memory. Similarly, wider registers that can hold more data can also improve performance, if the workload can make use of that. Generally, more modern processors and those with larger instruction words will use more registers when possible. For example, the IA-32 instruction set architecture has 8 general purpose registers, x86-64 has 16, many RISCs have 32, and IA-64 has 128. The advantages of a larger register file are offset by the need to use more bits to encode the register number. For instance, in a system using 32-bit instructions, you might wish to have three registers, such that you can perform operations of the type z = x + y . If the register file contains 32 entries, each one of the references will require 5 bits, and the set of three registers thus takes up 15 bits, leaving 17 to encode the operation and other information. Expanding the register file to 64 entries would require 6 bits, a total of 18 bits. While this may result in faster performance, it also means there are fewer bits left over for encoding the instruction. This leads to an effort to balance the size of the file with the number of possible instructions. ===Out-of-order=== Processors in early computers often worked lock-step with their main memory, which reduced the advantages of large register files. A common design note from the minicomputer market of the 1960s was to have the registers be physically implemented in main memory, in which case the performance advantage was simply that the instruction could directly refer to the location rather than having to use a second byte or two to specify a complete memory address. This made the instructions smaller, and thus faster to read. This sort of design, which maximized performance by carefully tuning the instruction set for minimal size, was common until the 1980s. An example of this approach is the MOS 6502, which had only a single register, in which case it is referred to as the accumulator, and a special "zero page" addressing mode for the first 256 bytes of memory. Placing code and data in the zero page meant the instruction was only two bytes long instead of three, greatly improving performance through avoided reads, providing similar benefits to having more registers. The widespread introduction of dynamic RAM in the 1970s changed this approach. Over time, the performance of the central processing units (CPUs) increased relative to the memory they were attached to, it was no longer reasonable to use main memory as registers. This led to increasingly large register files, internal to the CPU, to avoid referring to memory wherever possible. However, it is not possible to avoid accessing memory entirely in practice, and as the speed difference grew, every such access became more and more expensive in terms of the number of instructions that might be performed had the value been in a register. Different instructions may take different amounts of time; for example, a processor may be able to execute hundreds of register-to-register instructions while a single load from the main memory is in progress. A key advance in improving performance is to allow those fast instructions to be performed while the others are waiting for data. This means the instructions are no longer completed in the order they are specified in the machine code, they are instead performed out-of-order. Consider this piece of code running on an out-of-order CPU: r1 ≔ m[1024] ;read the value in memory location 1024 r1 ≔ r1 + 2 ;add two to the value m[1032] ≔ r1 ;save the result to location 1032 r1 ≔ m[2048] ;read value in 2048 r1 ≔ r1 + 4 ;add 4 m[2056] ≔ r1 ;save it to 2056 The instructions in the final three lines are independent of the first three instructions, but the processor cannot finish r1 ≔ m[2048] until the preceding m[1032] ≔ r1 is complete, as doing so would add four to the value of 1024, not 2048. If another register is available, this restriction can be eliminated by choosing different registers for the first three and the second three instructions: r1 ≔ m[1024] r1 ≔ r1 + 2 m[1032] ≔ r1 r2 ≔ m[2048] r2 ≔ r2 + 4 m[2056] ≔ r2 Now the last three instructions can be executed in parallel with the first three. The program will run faster than before by eliminating the data dependency caused by unnecessarily using the same register in both sequences. A compiler can detect independent instruction sequences and, if there are registers that are available for use, choose different registers during register allocation in the code generation process. However, to speed up code generated by compilers that do not perform that optimization, or code for which there were not sufficient registers to perform that optimization, many high-performance CPUs provide a register file with more registers than are specified in the instruction set, and, in hardware, rename references in instruction-set-defined registers to refer to registers in the register file, so that the original instruction sequence, using only r1, behaves as if it were: rA ≔ m[1024] rA ≔ rA + 2 m[1032] ≔ rA rB ≔ m[2048] rB ≔ rB + 4 m[2056] ≔ rB with register r1 "renamed" to the internal register rA for the first three instructions and to the internal register rB for the second three instructions. This removes the false data dependency, allowing the first three instructions to be executed in parallel with the second three instructions. === Tag-indexed register file === This is the renaming style used in the MIPS R10000, the Alpha 21264, and in the FP section of the AMD Athlon. In the renaming stage, every architectural register referenced (for read or write) is looked up in an architecturally-indexed remap file. This file returns a tag and a ready bit. The tag is non-ready if there is a queued instruction which will write to it that has not yet executed. For read operands, this tag takes the place of the architectural register in the instruction. For every register write, a new tag is pulled from a free tag FIFO, and a new mapping is written into the remap file, so that future instructions reading the architectural register will refer to this new tag. The tag is marked as unready, because the instruction has not yet executed. The previous physical register allocated for that architectural register is saved with the instruction in the reorder buffer, which is a FIFO that holds the instructions in program order between the decode and graduation stages. The instructions are then placed in various issue queues. As instructions are executed, the tags for their results are broadcast, and the issue queues match these tags against the tags of their non-ready source operands. A match means that the operand is ready. The remap file also matches these tags, so that it can mark the corresponding physical registers as ready. When all the operands of an instruction in an issue queue are ready, that instruction is ready to issue. The issue queues pick ready instructions to send to the various functional units each cycle. Non-ready instructions stay in the issue queues. This unordered removal of instructions from the issue queues can make them large and power-consuming. Issued instructions read from a tag-indexed physical register file (bypassing just-broadcast operands) and then execute. Execution results are written to tag-indexed physical register file, as well as broadcast to the bypass network preceding each functional unit. Graduation puts the previous tag for the written architectural register into the free queue so that it can be reused for a newly decoded instruction. An exception or branch misprediction causes the remap file to back up to the remap state at last valid instruction via combination of state snapshots and cycling through the previous tags in the in-order pre-graduation queue. Since this mechanism is required, and since it can recover any remap state (not just the state before the instruction currently being graduated), branch mispredictions can be handled before the branch reaches graduation, potentially hiding the branch misprediction latency.
Cite this
"Register renaming". 1783375687. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1362916434 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy