Space allocation method and device for dual-port transmission, equipment and medium
Through the space allocation method of dual-port emission, the dispatched instruction sequence relationship table is used to realize out-of-order allocation and recycling of instructions in the processor, which solves the instruction waiting problem in multi-port allocation scenarios and improves the execution performance of the processor.
Patent Information
- Application Number
- CN202410726675.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-10-08
AI Technical Summary
In the multi-port allocation scenario of existing processors, the instruction allocation and recycling mechanism causes a large number of invalid instructions to wait, affecting the processor execution performance.
The space allocation method of dual-port emission is used to maintain the sequence of instructions through the dispatched instruction sequence relationship table. After the dual-port dispatches the instruction, free space is searched from both ends of the available list at the same time, and the dependency of the instruction is determined and updated, allowing Allocate and reclaim space out of order.
The waiting period for instruction distribution is shortened, the impact of the operating frequency of the processor is reduced, and the execution efficiency of the processor and the operating frequency of the logic circuit are improved.
Smart Images

Figure CN118747086A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for spatial allocation of dual-port transmission. Background Art
[0002] With the rapid development of computer technology, the processing speed of computers is required to be higher and higher.
[0003] Generally, processors execute instructions according to the order of program flow. For example, the classic five-stage pipeline processor architecture includes five pipeline stages: IF (Instruction Fetch), ID (Instruction Decode), EX (Execute), MEM (Memory Access), and WB (Write Back). Among them, the processor executes instructions in a fixed order at the IF, ID, and EX pipeline stages; the processor executes instructions out of order at the EX and MEM pipeline stages. The order of instructions determines the judgment of dependencies, which include resource dependencies and data dependencies. At present, ROB (Re-Order Buffer) is used to maintain the order of instructions or judge dependencies, that is, it is implemented using a first-in-first-out mechanism. Instructions are allocated ROB space in the order of allocation, and recycling is also linear recycling, that is, recycling is carried out in the order of allocation.
[0004] However, in the current order preservation and dependency judgment mechanism, for instructions assigned to multiple ports, if the above mechanism is still followed, for example, multiple instructions are assigned in one cycle, it is necessary to search for available space for the first instruction in order from the available list. After the search for the first instruction is completed, free space is searched for the second instruction based on the search result of the first instruction, and free space is searched for the third instruction based on the space search result of the second instruction. With the increasing use of dual-issue and multi-issue mechanisms, this situation will become more and more common, resulting in a large number of instructions in the pipeline stage waiting ineffectively, which will greatly affect the execution performance of the processor. Therefore, a new order preservation and dependency judgment mechanism is urgently needed. Summary of the invention
[0005] Embodiments of the present application provide a method, apparatus, device, and medium for spatial allocation of dual-port transmission.
[0006] In a first aspect of an embodiment of the present application, a space allocation method for dual-port transmission is provided, the method comprising: after the dual-port dispatches an instruction, searching for the index numbers of two free spaces simultaneously from both ends of an available list; the available list is used to indicate the index of the free space in the information stack, and the information stack is used to store the relevant information of the dispatched instruction; according to the relevant information of the instruction and the dispatched instruction sequence table, the RAW (Readafter Write) dependency relationship between the current dispatched instruction and the dispatched instruction is determined; the dispatched instruction sequence table is used to store the logical execution sequence of each dispatched instruction and other dispatched instructions; according to the index numbers of the two free spaces, the relevant information of the current dispatched instruction is updated into the information stack; according to the indexes of the two free spaces, the sequence relationship between the current dispatched instruction and the dispatched instruction is updated into the dispatched instruction sequence table.
[0007] In an optional embodiment of the present application, the RAW dependency between the current dispatched instruction and the dispatched instruction is determined based on the relevant information of the instruction and the dispatched instruction sequence table, including: determining a first set of instructions in the dispatched instruction whose target register index is the same as the operand of the current dispatched instruction; determining a second set of instructions in the first set whose logical execution order is earlier than the logical order of the current dispatched instruction based on the dispatched instruction sequence table; determining the instruction in the second set that is closest to the logical execution order of the current dispatched instruction as the instruction with which the current dispatched instruction has a RAW dependency, otherwise the current dispatched instruction does not have a RAW dependency.
[0008] In an optional embodiment of the present application, the index values of the two free spaces are different; the current dispatch instruction includes a first instruction and a second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; according to the index of the two free spaces, the relevant information of the current dispatch instruction is updated to the information stack, including: storing the relevant information of the first instruction in the space corresponding to the first number in the information stack, and storing the relevant information of the second instruction in the space corresponding to the second number in the information stack; wherein the first number is the number of the first free space in the available list with a value from small to large, and the second number is the number of the first free space in the available list with a value from large to small.
[0009] In an optional embodiment of the present application, the index values of two free spaces are different, and the current dispatch instruction includes a first instruction; the relevant information of the first instruction is stored in the space corresponding to the first number in the information stack, the flag bit corresponding to the first number in the available list is updated, and the flag bit corresponding to the second number is kept unchanged; wherein the first number is the number of the first free space in the available list with a value from small to large, and the second number is the number of the first free space in the available list with a value from large to small.
[0010] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatched instruction includes the first instruction and the second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; according to the index of the two free spaces, the relevant information of the current dispatched instruction is updated to the information stack, including: storing the relevant information of the first instruction in the space corresponding to the first number in the information stack; suspending the allocation of space for the second instruction in this cycle.
[0011] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction; according to the index of the two free spaces, the relevant information of the current dispatch instruction is updated to the information stack, including: storing the relevant information of the first instruction in the space corresponding to the first number in the information stack.
[0012] In an optional embodiment of the present application, the dispatched instruction sequence table is an N-level table, which can store the logical execution sequence of N dispatched instructions, each row corresponds to the sequence of a dispatched instruction and other dispatched instructions, and N is a positive integer.
[0013] According to a second aspect of an embodiment of the present application, a space allocation device for dual-port transmission is provided, which includes: a search module, a judgment module and an update module; the search module is used to search for the index numbers of two free spaces from both ends of an available list at the same time after the dual-port dispatches an instruction; the available list is used to indicate the index of the free space in the information stack, and the information stack is used to store the relevant information of the dispatched instruction; the judgment module is used to judge the RAW dependency relationship between the current dispatched instruction and the dispatched instruction according to the relevant information of the instruction and the dispatched instruction sequence table; the dispatched instruction sequence table is used to store the logical execution sequence of each dispatched instruction and other dispatched instructions; the update module is used to update the relevant information of the current dispatched instruction into the information stack according to the index number of the two free spaces; the update module is also used to update the sequence relationship between the current dispatched instruction and the dispatched instruction into the dispatched instruction sequence table according to the index of the two free spaces.
[0014] In an optional embodiment of the present application, the judgment module is specifically used to: determine a first set of instructions in the dispatched instructions whose target register index is the same as the operand of the currently dispatched instruction; determine a second set of instructions in the first set whose logical execution order is earlier than the logical order of the currently dispatched instruction based on the dispatched instruction sequence table; determine the instruction in the second set that is closest to the logical execution order of the currently dispatched instruction as the instruction with which the currently dispatched instruction has a RAW dependency, otherwise the currently dispatched instruction does not have a RAW dependency.
[0015] In an optional embodiment of the present application, the index values of the two free spaces are different; the current dispatch instruction includes a first instruction and a second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; the update module is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack, and store the relevant information of the second instruction in the space corresponding to the second number in the information stack; wherein the first number is the number of the first free space in the available list with a value from small to large, and the second number is the number of the first free space in the available list with a value from large to small.
[0016] In an optional embodiment of the present application, the index values of two free spaces are different, and the current dispatch instruction includes a first instruction; the update module is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack, update the flag corresponding to the first number in the available list, and keep the flag corresponding to the second number unchanged; wherein the first number is the number of the first free space in the available list with a value from small to large, and the second number is the number of the first free space in the available list with a value from large to small.
[0017] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction and the second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; the update module is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack; and suspend the allocation of space for the second instruction in this cycle.
[0018] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction; the update module is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack.
[0019] In an optional embodiment of the present application, the dispatched instruction sequence table is an N-level table that can store the logical execution sequence of N dispatched instructions, and each row corresponds to the sequence between a dispatched instruction and other dispatched instructions.
[0020] According to a third aspect of an embodiment of the present application, a computer device is provided, including: a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.
[0021] According to a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0022] In the space allocation method for dual-port transmission provided in the embodiment of the present application, the order of dispatched instructions is maintained through the dispatched instruction order relationship table. After the dual-port dispatches the instruction, the index numbers of the two free spaces are searched from both ends of the available list at the same time, and then the RAW dependency relationship between the current dispatched instruction and the dispatched instruction is determined based on the relevant information of the instruction and the dispatched instruction order relationship table; finally, based on the index numbers of the two free spaces found, the relevant information of the current dispatched instruction is updated to the information stack, and the order relationship between the current dispatched instruction and the dispatched instruction is updated to the dispatched instruction order relationship table. In the scenario of dual-port transmission in the related art, if the space is allocated according to the original first-in-first-out method for a single port, it is necessary to first search the table to allocate space for the first instruction, and then search the table again to allocate space for the second instruction based on the table updated after the allocation for the first instruction. That is, at least two cycles are required in the related art to allocate space for instructions. However, in the present application, under the dual-port transmission mechanism, the order of instructions is maintained through a dispatched instruction order relationship table. When allocating space in the information stack for the instruction after the instruction is dispatched, the first-in-first-out mechanism is no longer used. Instead, the free space is searched from both ends of the available list at the same time, and the first free space is found respectively, that is, out-of-order allocation of space is allowed. Therefore, the allocation demand of the instruction free space can be responded quickly, and two free spaces can be found to allocate to the instruction, shortening the waiting cycle caused by the search, reducing the waiting in the linear allocation mechanism, thereby reducing the impact on the operating frequency of the processor, and can increase the operating frequency of the logic circuit in the processor. While ensuring the order of instructions, the execution efficiency of the processor for instructions can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0024] Figure 1 is a schematic diagram of a five-stage pipeline processor architecture in a related art;
[0025] Figure 2 A schematic diagram of the principle of space allocation and order preservation in a related technology;
[0026] Figure 3 A flowchart of a spatial allocation method for dual-port transmission provided by an embodiment of the present application;
[0027] Figure 4 A logical diagram of spatial allocation / recycling of dual-port transmission provided for one embodiment of the present application;
[0028] Figure 5A flowchart of a spatial allocation method for dual-port transmission provided by an embodiment of the present application;
[0029] Figure 6 A flowchart of a spatial allocation method for dual-port transmission provided by an embodiment of the present application;
[0030] Figure 7 A schematic diagram of the structure of a spatial allocation device for dual-port transmission provided by an embodiment of the present application;
[0031] Figure 8 A schematic diagram of the computer device structure provided for one embodiment of the present application. DETAILED DESCRIPTION
[0032] In the process of implementing the present application, the inventors discovered that the current way of allocating space in a processor has a significant impact on processor performance.
[0033] First, let's introduce the technical terms in the relevant technologies in detail here:
[0034] 1. Classic five-stage pipeline processor architecture
[0035] Figure 1 FIG. 1 is a schematic diagram of a five-stage pipeline processor architecture in a related art. Figure 1 As shown in , it includes the following five pipeline stages. Among them: IF pipeline stage, responsible for reading instructions from memory. ID pipeline stage, responsible for identifying the type of instruction. EX pipeline stage, responsible for the operation of instructions; operation instructions are operated at this pipeline stage to obtain the result of the operation. MEM pipeline stage, responsible for accessing the memory; reading data from internal or external memory, or writing the execution result to the memory. WB pipeline stage, responsible for writing back the result; writing the result of instruction execution back to the register stack of the processor for quick access next time.
[0036] like Figure 1As shown in the figure, it is a classic five-stage pipeline workflow. The life cycle of some instructions will go through the above five-stage pipeline, or four of the five-stage pipeline (for example, some instructions do not need the WB pipeline stage, and some instructions do not need the MEM pipeline stage). If the instruction does not obtain all the data when entering the EX pipeline stage, or if any operand of the instruction does not get the correct data when entering the EX pipeline stage, then the instruction can only wait in the EX pipeline stage until the operand gets the data. This kind of dependency between operands is called data dependency. Among them, resource dependency is common in different instructions of the same type preempting the same processing unit, or different memory access instructions accessing the same address. Data dependency is in the program order, including RAW dependency and WAW (Write after Write) dependency. Among them, RAW dependency indicates that the execution of subsequent instructions requires the results of the previous instructions that have not been executed, and both WAW instructions must be written back to the same register.
[0037] It should be noted that the method in the embodiments of the present application can be applied to a multi-stage pipeline processor architecture, such as the instruction execution of a processor with a five-stage or nine-stage pipeline.
[0038] 2. Based on ROB order preservation and dependency judgment
[0039] In the related art, ROB is usually used to judge the order preservation and dependency relationship of instructions. The principle is to use a FIFO (First In First Out) to achieve the order preservation between instructions. For dual-issue, it is a two-write, one-read or multi-read FIFO.
[0040] Figure 2 A schematic diagram of the principle of space allocation and order preservation in a related technology is shown in FIG. Figure 2 As shown in , the entire ROB has 8 spaces, each numbered in sequence. Every time a new instruction is allocated, the allocation pointer increases by a corresponding value, pointing to the index of the next free space. Similarly, every time an old instruction is executed, the release pointer increases by a corresponding value, pointing to the index of the next space to be released. Therefore, these 8 spaces will have 3 different states: space that has been executed and released, such as space 0; space that has been occupied but not yet released, such as space 1 to space 4; and space that is completely unused, such as space 5 to 7. Among them, the space that is completely unused will eventually be converted into the first type of space.
[0041] Due to the logic of the FIFO structure used, the instructions that are allocated first must be earlier instructions. Such instructions are also the first to be executed and released. Figure 2 In the example, the instruction represented by space 2 must be later than the instruction in space 1, but must be earlier than the instruction represented by space 3. This linear allocation-release mechanism automatically completes the order preservation work between instructions in principle. In this way, the resource dependency between instructions is also guaranteed. On this basis, it is also simple to check the dependency between data. Take the RAW dependency of the instruction represented by space 3 as an example. Since the order between instructions has been guaranteed by FIFO, the instruction only needs to check whether its operand rsidx is the same as all instructions earlier than it, that is, the destination rdidx of space 1 and 2. If the two are equal, then which space's rdidx is equal to indicates which space space 3 will depend on. At that time, you only need to check that instruction. If they are all equal, then select the instruction closer to 3, that is, the youngest instruction for the instruction in space 3, that is, instruction 2, as the destination instruction it depends on. For WAW dependencies, since the executed instructions release space linearly in FIFO order, that is, the order in which instructions are allocated, when the instructions in space 1 are not released, the instructions in space 2 are not allowed to be released, ensuring that the order in which instructions are executed is as expected.
[0042] As mentioned above, since the instructions in the above mechanism are recycled linearly, and in the processor pipeline, the execution cycles of different types of instructions are uncertain, such as single-cycle addition and subtraction instructions and multi-cycle multiplication and division instructions, which are completely dependent on the implementation of the microarchitecture. In this case, it is possible that the earlier multi-cycle instructions have not been executed, but the later single-cycle instructions have been executed and are waiting for write-back and space recycling. For dual-issue or even multi-issue processors, this situation will become more and more common. If the single-cycle instruction, regardless of whether it has WAW dependency, still needs to wait in sequence for the multi-cycle instruction to complete before it can be written back, then the subsequent single-cycle instructions will consume a lot of invalid waiting time. This will greatly affect the execution performance of the processor.
[0043] In view of the above problems, embodiments of the present application provide a method for allocating space for dual-port transmission and a method for recovering space for dual-port transmission.
[0044] On the one hand, in the space allocation method for dual-port transmission, the order of dispatched instructions is maintained through the dispatched instruction order table. After the dual-port dispatches the instruction, the index numbers of the two free spaces are searched from both ends of the available list at the same time, and then the RAW dependency between the current dispatched instruction and the dispatched instruction is determined based on the relevant information of the instruction and the dispatched instruction order table; finally, based on the index numbers of the two free spaces found, the relevant information of the current dispatched instruction is updated to the information stack, and the order relationship between the current dispatched instruction and the dispatched instruction is updated to the dispatched instruction order table. In the related art, in the scenario of dual-port transmission, if the space is allocated according to the original first-in-first-out method for a single port, it is necessary to first search the table to allocate space for the first instruction, and then search the table again based on the updated table after the allocation for the first instruction to allocate space for the second instruction. That is, at least two cycles are required in the related art to allocate space for instructions. However, in the dual-port transmission mechanism, the present application maintains the order of instructions through the dispatched instruction order relationship table. When allocating space for the information stack for the instruction after the instruction is dispatched, the first-in-first-out mechanism is no longer used. Instead, the free space is searched from both ends of the available list at the same time, and the first free space is found respectively, that is, the space is allowed to be allocated in a disorderly order. Therefore, the allocation demand of the instruction free space can be quickly responded to, and two free spaces are found to allocate for the instruction, which shortens the waiting cycle caused by the search, reduces the waiting in the linear allocation mechanism, and thus reduces the impact on the operating frequency of the processor, and can increase the operating frequency of the logic circuit in the processor. While ensuring the order of the instructions, the execution efficiency of the processor for the instructions can be improved. Therefore, the space allocation method of the dual-port transmission of the present application is suitable for dual-transmission high-performance processors.
[0045] Secondly, in the space recovery method of dual-port transmission, the logical execution order of the dispatched instructions is maintained through a dispatched instruction order relationship table, and for the first instruction that has been executed, according to the relevant information of the instructions stored in the information stack, a third set of instructions in the dispatched instructions whose destination register index is the same as the destination register index of the first instruction is determined; then, according to the dispatched instruction order relationship table, it is determined whether there is a fourth set of instructions in the third set that are earlier in logical order than the first instruction. If there are no instructions in the third set that are earlier in logical execution order than the first instruction, there are no instructions that have a WAW dependency relationship with the first instruction, and the processor immediately reclaims the space number occupied by the first instruction and the space in the information stack occupied by the first instruction. That is, after detecting that an instruction has been executed, the processor can complete the judgment of the WAW dependency between the instruction and other instructions based on the dispatched instruction sequence table and instruction-related information within a single cycle. If the instruction does not have a WAW dependency with the dispatched instruction, it can be released immediately. In other words, the space in the information stack occupied by the instruction is no longer released in first-in-first-out order, that is, the release is out of order. Compared with the linear recovery mechanism used in related technologies, there is no need to wait for the first-dispatched instruction to be released first, so the invalid waiting time can be reduced. Therefore, the execution efficiency of the instruction can be improved while ensuring the sequence of instructions, with less logical delay, higher circuit operating frequency, and better processing efficiency of dual-issue high-performance processors.
[0046] The solutions in the embodiments of the present application can be implemented using various computer languages, for example, the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0047] In order to make the technical solutions and advantages in the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0048] Spatial allocation of dual-port launch
[0049] See also Figure 3 , Figure 3 This is a flowchart of a spatial allocation method for dual-port transmission provided by an embodiment of the present application. The following embodiments use a processor as the execution subject and apply the method provided by the embodiment of the present application to an electronic device to specifically illustrate a spatial allocation method for dual-port transmission provided by the present application. A spatial allocation method for dual-port transmission provided by an embodiment of the present application includes the following steps 301-304:
[0050] Step 301: After the dual-port dispatch instruction, the processor starts to search for index numbers of two free spaces from both ends of the available list at the same time.
[0051] In an embodiment of the present application, an available list of free space indexes of an information stack is maintained in the processor, the available list includes an index for indicating free space of the information stack, and the information stack is used to store relevant information of dispatched instructions.
[0052] It should be noted that in the embodiment of the present application, the currently dispatched instruction includes one or two instructions. The dispatched instruction indicates an instruction for which space of the information stack has been allocated and the relevant information of the instruction is stored in the allocated space. The dispatched instruction indicates an instruction in a pipeline stage.
[0053] Exemplarily, the relevant information of the instruction may include at least one of the following:
[0054] (1) Whether the instruction requires the source operand register rsen;
[0055] Among them, if an instruction read register is enabled and requires n source operand registers, then the relevant information of the instruction includes n rsens, where n is a positive integer.
[0056] (2) the index of the instruction source operand register rsidx;
[0057] The read register index indicates the number of the source operand register.
[0058] (3) Whether the instruction needs to write to the destination register rdwen;
[0059] Among them, a field in the information stack is used to write register enable information.
[0060] (4) The instruction writes the index rdidx of the destination register.
[0061] Among them, a field in the information stack is used for writing the register index of the destination.
[0062] (5) Other relevant information, such as if the architecture supports floating-point instructions, a flag indicating whether the instruction needs to read or write a floating-point register, etc.
[0063] Step 302: The processor determines the RAW dependency relationship between the currently dispatched instruction and the dispatched instruction according to the relevant information of the instruction and the dispatched instruction sequence table.
[0064] The dispatched instruction sequence table is used to store the logical execution sequence of each dispatched instruction and other dispatched instructions. The dispatched instruction sequence table is updated when the dual port dispatches a new instruction.
[0065] It should be noted that in the embodiment of the present application, after the dual-port dispatch instruction, there is no necessary order of execution for searching the index of the free space and judging the RAW dependency. They can be executed in parallel or one after the other. The embodiment of the present application does not make any specific limitation on this.
[0066] For example, in the embodiment of the present application, an Age Matrix module (age matrix) is provided in the processor to implement the dispatched instruction priority table, and the order of the dispatched instruction priority table can be updated with the update of the number of dispatched instructions, or can be the sum of the number of spaces. For example, in a certain cycle, the pipeline includes N dispatched instructions, then the dispatched instruction priority table is an N-order table, and each table entry is 1 bit.
[0067] For example, in a certain cycle, the pipeline includes 4 dispatched instructions, then the dispatched instruction sequence relationship table is a 4-level table (4*4), indicating the logical execution sequence relationship between the 4 instructions, and each table entry is 1 bit. In the next cycle, the pipeline includes 5 dispatched instructions, then the dispatched instruction sequence relationship table is updated to a 5-level table (5*5), indicating the logical execution sequence relationship between the 5 instructions.
[0068] For example, if the maximum number of instructions in the pipeline stage is 8, the dispatched instruction sequence table is an 8-stage table (8*8).
[0069] In a possible example of the present application, the dispatched instruction sequence table is an N-level table that can store the logical execution sequence of N dispatched instructions, each row corresponds to the sequence of a dispatched instruction and other dispatched instructions, and N is a positive integer.
[0070] For example, Table 1 is an exemplary table of a dispatched instruction sequence table provided in an embodiment of the present application, wherein N=4, with A [i][j] =1 means that the instructions in space i are older than the instructions in space j (it can also be defined as younger, which can be customized according to needs).
[0071] Table 1
[0072] <![CDATA[I0]]> <![CDATA[I1]]> <![CDATA[I2]]> <![CDATA[I3]]> <![CDATA[I0]]> 0 1 1 1 <![CDATA[I1]]> 0 0 0 0 <![CDATA[I2]]> 0 1 0 1 <![CDATA[I3]]> 0 1 0 0
[0073] Exemplarily, in conjunction with Table 1, the first row in the age matrix (i.e., the order relationship table of dispatched instructions) stores the order relationship between the instructions in space 0 and other dispatched instructions. The instructions in space 0 are older than the instructions in space 1, the instructions in space 0 are older than the instructions in space 2, and the instructions in space 0 are older than the instructions in space 3, which means that among the four spaces, the instructions in space 0 are the oldest instructions among the dispatched instructions. The second row stores the order relationship between the instructions in space 1 and other dispatched instructions. The instructions in space 1 are younger than the instructions in space 0, the instructions in space 1 are younger than the instructions in space 2, and the instructions in space 1 are younger than the instructions in space 3, which means that among the four spaces, the instructions in space 1 are the youngest instructions among the dispatched instructions. The third row stores the order of the instructions in space 2 and other dispatched instructions. The instructions in space 2 are younger than the instructions in space 0, older than the instructions in space 1, and younger than the instructions in space 3. The fourth row stores the order of the instructions in space 3 and other dispatched instructions. The instructions in space 3 are younger than the instructions in space 0, older than the instructions in space 1, and older than the instructions in space 2. That is, the first logical execution order is: space 0 is the youngest, space 2 is younger than space 3, and space 3 is younger than space 1. That is, as shown in Table 1, the logical execution order of the four instructions is: I0, I2, I3, I1. That is, I0 is executed first, I2 is second, I3 is third, and I1 is the latest.
[0074] It should be noted that the table entry is updated only when a new instruction is allocated, and the updated address is the number of the allocated free address.
[0075] Step 303: The processor updates the information related to the current dispatched instruction into the information stack according to the index numbers of the two free spaces.
[0076] The relevant information of the currently dispatched instruction includes all information required for determining the RAW dependency relationship between the currently dispatched instruction and all dispatched instructions.
[0077] Step 304: The processor updates the order of the currently dispatched instruction and the dispatched instructions into the dispatched instruction order table according to the index numbers of the two free spaces.
[0078] For ease of explanation, in an embodiment of the present application, an example is taken in which the logical execution order of the first instruction comes first, the logical execution order of the second instruction comes later, the first number is the number of the first free space in the available list from small to large, and the second number is the number of the first free space in the available list from large to small.
[0079] Specifically, the processor stores the relevant information of the first instruction in the space corresponding to the first number in the information stack, and stores the relevant information of the second instruction in the space corresponding to the second number in the information stack.
[0080] Specifically, the processor updates the order of the first instruction and other dispatched instructions in the row with the first number in the dispatched instruction order table, and updates the order of the second instruction and other dispatched instructions in the row with the second number in the dispatched instruction order table.
[0081] Figure 4 A logical diagram of spatial allocation / recycling of dual-port transmission provided by an embodiment of the present application. Figure 4 As shown in , the available information list includes the index numbers of 8 spaces of the information stack, wherein the flag bit vld (Valid, valid flag bit) corresponding to the index number of the free space is set to 1, and the flag bit vld corresponding to the index number of the occupied space is set to 0. An index number corresponds to a space in the information stack, wherein a column in the information stack corresponds to a space, and a space may include multiple bits for storing different information of instructions. In the process of space allocation, the relevant information of the instructions stored in each space can be compared with the relevant information of the currently dispatched instruction, combined with the age matrix, to determine whether there are instructions in all allocated instructions that have a RAW dependency relationship with the currently dispatched instruction.
[0082] When free space is allocated, relevant information used for dependency judgment can be saved in the space of the information stack, and the relevant information can be kept unchanged at other times, thereby saving power consumption and improving the processing performance of the processor.
[0083] The embodiment of the present application provides a space allocation method based on dual-port transmission, which maintains the order of dispatched instructions through a dispatched instruction order table. After the dual-port dispatches an instruction, the index numbers of two free spaces are searched from both ends of the available list at the same time, and then the RAW dependency between the current dispatched instruction and the dispatched instruction is determined based on the relevant information of the instruction and the dispatched instruction order table; finally, based on the index numbers of the two free spaces found, the relevant information of the current dispatched instruction is updated into the information stack, and the order relationship between the current dispatched instruction and the dispatched instruction is updated into the dispatched instruction order table. In the scenario of dual-port transmission in the related art, if the space is allocated according to the original first-in-first-out method for a single port, it is necessary to first search the table to allocate space for the first instruction, and then search the table again to allocate space for the second instruction based on the table updated after the allocation for the first instruction. That is, at least two cycles are required in the related art to allocate space for instructions. However, in the present application, under the dual-port transmission mechanism, the order of instructions is maintained through a dispatched instruction order relationship table. When allocating space in the information stack for the instruction after the instruction is dispatched, the first-in-first-out mechanism is no longer used. Instead, the free space is searched from both ends of the available list at the same time, and the first free space is found respectively, that is, out-of-order allocation of space is allowed. Therefore, the allocation demand of the instruction free space can be responded quickly, and two free spaces can be found to allocate to the instruction, shortening the waiting cycle caused by the search, reducing the waiting in the linear allocation mechanism, thereby reducing the impact on the operating frequency of the processor, and can increase the operating frequency of the logic circuit in the processor. While ensuring the order of instructions, the execution efficiency of the processor for instructions can be improved.
[0084] In an optional embodiment of the present application, Figure 5 This is a flow chart of a spatial allocation method for dual-port transmission provided by an embodiment of the present application. The above step 302 may specifically include the following steps 302a to 302c:
[0085] Step 302a: The processor determines a first set of dispatched instructions whose target register index is the same as an operand of the currently dispatched instruction.
[0086] The operands of the currently dispatched instruction may include at least one operand.
[0087] For example, if the first instruction includes a first operand and a second operand, the processor needs to determine a set of instructions whose target register is the same as the first operand in the dispatched instructions (referred to as a first subset), and a set of instructions whose target register is the same as the second operand (referred to as a second subset). The following operation steps need to be performed for both the first subset and the second subset.
[0088] It can be understood that if there is no instruction in the dispatched instructions whose target register number is the same as the operand of the currently dispatched instruction, it is determined that there is no RAW dependency relationship between the currently dispatched instruction and all the dispatched instructions.
[0089] Step 302b: The processor determines, according to the dispatched instruction sequence table, a second set of instructions in the first set whose logical execution order is earlier than the logical order of the currently dispatched instruction.
[0090] It can be understood that if there is no instruction in the first set whose logical execution order is earlier than the logical execution order of the currently dispatched instruction, it is determined that there is no RAW dependency relationship between the currently dispatched instruction and all the dispatched instructions.
[0091] Step 302c: The processor determines that the instruction in the second set that is closest in logical execution order to the currently dispatched instruction is the instruction with which the currently dispatched instruction has a RAW dependency; otherwise, the currently dispatched instruction does not have a RAW dependency.
[0092] It can be understood that the processor determines, based on the dispatched instruction sequence table, that the youngest instruction in the second set has a RAW dependency relationship with the currently dispatched instruction.
[0093] Based on this scheme, the processor can perform RAW dependency detection according to the dispatched instruction sequence table, the target register index of the dispatched instruction and the operand of the currently dispatched instruction. Specifically, the processor can first determine the first set of instructions whose index value of the target register in the dispatched instruction is the same as the operand of the currently dispatched instruction, and then determine whether there are instructions in the first set whose logical execution order is earlier than the logical execution order of the currently dispatched instruction. If the logical execution order of the instructions in the second set is earlier than the logical execution order of the currently dispatched instruction, and the index value of the target register is the same as the operand of the currently dispatched instruction, then based on the dispatched instruction sequence table, it is determined that the youngest instruction in the second set (i.e., the instruction in the second set whose logical execution order is closest to the currently dispatched instruction) has a RAW dependency with the currently dispatched instruction.
[0094] In an optional embodiment of the present application, the index values of the two free spaces are different; the current dispatch instruction includes a first instruction and a second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; further, Figure 6 As shown in , the above step 303 may specifically include the following step 303a:
[0095] Step 303a: The processor stores the relevant information of the first instruction in the space corresponding to the first number in the information stack, and stores the relevant information of the second instruction in the space corresponding to the second number in the information stack.
[0096] The first number is the number of the first free space in the available list from the smallest value to the largest value, and the second number is the number of the first free space in the available list from the largest value to the smallest value.
[0097] It should be noted that in the embodiment of the present disclosure, if the dual port dispatches two instructions and two different free numbers are found, after the relevant information of the two instructions is stored in the information stack, the flag bits corresponding to the two numbers in the available list can be updated to indicate that the information stack space corresponding to the two numbers has been used.
[0098] Based on this scheme, in the case of dual-port transmission, two instructions are dispatched in one cycle, and the indexes of two free spaces with different values are found from the two ends of the available list. The processor stores the relevant information of the first instruction with an earlier logical execution order in the space corresponding to the first number with a smaller index value in the information stack, and stores the relevant information of the second instruction with a later logical execution order in the space corresponding to the second number with a larger index value in the information stack, so that space can be quickly allocated for the currently dispatched instruction. Compared with the method in the related art that the space allocation of the second instruction needs to be based on the allocation result of the first instruction, free space can be searched for the currently dispatched instructions transmitted by the two ports in parallel, thereby improving the allocation efficiency of the instruction space in the case of dual-port transmission.
[0099] In an optional embodiment of the present application, the index values of the two free spaces are different, and the currently dispatched instruction includes the first instruction; that is, the dual port only dispatches one instruction in this cycle. Furthermore, the above step 303 may specifically include the following step 303b:
[0100] Step 303b: The processor stores the relevant information of the first instruction in the space corresponding to the first number in the information stack, updates the flag bit corresponding to the first number in the available list, and keeps the flag bit of the second number unchanged.
[0101] The first number is the number of the first free space in the available list from the smallest value to the largest value, and the second number is the number of the first free space in the available list from the largest value to the smallest value.
[0102] It can be understood that keeping the flag bit of the second number unchanged indicates that the second number is not used and can be found when the processor searches for free space next time.
[0103] Based on this scheme, if one of the dual ports dispatches an instruction (i.e., the first instruction) and the other port does not dispatch an instruction, the processor stores the relevant information of the instruction in the free space corresponding to the smaller index value of the two index values, and no longer takes out the index number with the larger index value. The index number of the unused free space can be found again in the next cycle in time, avoiding the decrease in the utilization of the free space caused by the existence of free space in the information stack and the failure to update the available list in time.
[0104] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction and the second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; furthermore, the above step 303 may specifically include the following step 303c:
[0105] Step 303c: The processor stores the relevant information of the first instruction in the space corresponding to the first number in the information stack; and suspends allocating space for the second instruction in this cycle.
[0106] Exemplarily, the processor searches for the index of the available free space for the second instruction again in the next cycle.
[0107] It can be understood that if the space is allocated to the second instruction first in the next cycle, the dual ports may not dispatch instructions in the next cycle, or only one port dispatches the second instruction, or dispatches the second instruction and the third instruction. In the case that two instructions are dispatched in the next cycle, the index of the free space is searched for the second instruction and the third instruction from the available list in the next cycle, wherein the third instruction is the instruction dispatched later.
[0108] Based on this scheme, when two instructions are dispatched by the dual ports, if there is only an index of free space in the available list of the current cycle, the processor will prioritize allocating space for instructions with an earlier logical execution order in this cycle, and will not allocate space for instructions with a later logical execution order in this cycle. In the next cycle, space will be reallocated for the instruction. This can enable priority allocation of resources to instructions that are executed first when space resources are insufficient, thereby reducing the situation where other instructions that are dependent on instructions have to wait at the same time due to unnecessary waiting for instructions with urgent time limits, thereby improving the processing efficiency of the processor in this scenario.
[0109] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction, that is, only one port dispatches an instruction in this cycle of the dual port; furthermore, the above step 303 may specifically include the following step 303d:
[0110] Step 303d: The processor stores the relevant information of the first instruction in the space corresponding to the first number in the information stack.
[0111] It should be noted that in the embodiment of the present application, regardless of whether the allocated instruction is one instruction or two instructions, the search for the first free space starts from both ends of the available list at the same time, and the number of search spaces is not determined based on the number of instructions. This can simplify the processing logic of the processor, and there is no need to determine the number of instructions each time before searching, which can improve the space allocation efficiency of dual-port transmission.
[0112] Based on this solution, only an index of a free space is found in this cycle, and only one of the dual ports dispatches an instruction in this cycle. The processor then stores the relevant information of the instruction in the free space. There is no need to find the indexes of two free spaces. The allocation method is flexible, and space can be flexibly allocated for different scenarios.
[0113] Example 1:
[0114] Step 1: Compare the operands rs1idx and rs2idx of instruction 1 with the destination register indexes rdidx of all dispatched instructions (including instruction 2, instruction 3, instruction 4, and instruction 5) to obtain a set A of all instructions that may have a RAW dependency with instruction 1.
[0115] A-Instruction 1: {Instruction 2, Instruction 3, Instruction 5}.
[0116] Step 2: For each instruction among all the assigned instructions, its own rdidx is compared with the rdidx of other dispatched instructions, and each instruction obtains an instruction set B having the same rdidx as the instruction.
[0117] Among them, B includes:
[0118] B1-instruction 2: {instruction 3, instruction 5};
[0119] B2-Instruction 3: {Instruction 2 and Instruction 5};
[0120] B3-Instruction 4: Empty set;
[0121] B4-Instruction 5: {Instruction 2, Instruction 3}.
[0122] Obtain the logical execution order relationship 1 between each instruction and other dispatched instructions from the age matrix. Instruction 5 is earlier than instruction 4, instruction 4 is earlier than instruction 3, and instruction 3 is earlier than instruction 2. According to the order relationship 1 and instruction set B, query whether there is an instruction that is later than the logical execution order of each instruction and has the same destination register as instruction 1, and obtain the set C corresponding to each dispatched instruction.
[0123] Among them, C includes:
[0124] C1-Instruction 2: Empty set;
[0125] C2-instruction 3: {instruction 2};
[0126] C3-Instruction 4: Empty set;
[0127] C5 - Instruction 5: {instruction 2, instruction 3}.
[0128] Step 3: Based on Set A and Set C, determine whether there is an allocated instruction whose rdidx is the same as the rsidx of Instruction 1 and there is no dispatched instruction younger than the dispatched instruction with the same rdidx. Determine that Instruction 2 exists and there is a RAW dependency between Instruction 1 and Instruction 2.
[0129] It should be noted that rs1idx and rs2idx of instruction 1 may have dependencies on different instructions at the same time. For example, rs1idx may depend on the result of instruction 3, and rs2 may depend on the result of instruction 5. Here, only rs1idx is used as an example. The judgment logic of rs2idx is exactly the same as that of rs1idx. It will not be repeated here.
[0130] It should be noted that, in the disclosed embodiment, logically, the first set is searched first, and then the youngest instruction in the logical execution order of the instructions in the first set is searched for, and the first instruction has a RAW dependency relationship. In practical applications, the actual execution steps caused by the hardware mechanism include the following steps: determining the first set of instructions whose destination register index is the same as the operand of the first instruction; determining whether there is an instruction with the same destination register index value for each dispatched instruction, and then determining whether each dispatched instruction is the youngest instruction in the execution order among the instructions with the same destination register based on the sequence table of dispatched instructions, and recording the result as the fifth set. Then, based on the first set and the fifth set, determine the instructions that have a RAW dependency relationship with the first instruction.
[0131] Spatial recycling for dual-port launch
[0132] After the dispatched first instruction is executed, it can be recycled according to the following recycling method.
[0133] The following embodiments use the above-mentioned processor as the execution subject, and apply the method provided in the embodiments of the present application to a computer device supporting dual-port transmission, so as to provide a specific description by taking the processor supporting dual transmission as an example.
[0134] The space recovery method for dual-port transmission provided in the embodiment of the present application includes the following steps: the processor determines, for the first instruction that has been executed, a third set of instructions whose destination register index is the same as the destination register index of the first instruction in the dispatched instructions according to the relevant information of the instructions stored in the information stack. The processor has dispatched the instruction sequence table to determine whether there is a fourth set of instructions in the third set that are earlier in the logical execution order than the first instruction. If there are no instructions in the third set that are earlier in the logical execution order than the first instruction, the processor determines that there is no WAW dependency between the dispatched instructions and the first instruction, and immediately reclaims the space number occupied by the first instruction and the space in the information stack occupied by the first instruction.
[0135] Among them, the instructions that have been executed are waiting to be recycled.
[0136] It can be understood that if there is no instruction in the dispatched instructions whose destination register is the same as the destination register of the first instruction, it is determined that there is no WAW dependency relationship between the first instruction and other dispatched instructions.
[0137] Combination Figure 4 ,During the space recovery process, the relevant information of the ,instructions stored in each space can be compared with the relevant information of the ,currently executed instructions, combined with the age matrix, it can be determined ,whether among all the dispatched instructions there are instructions that have a WAW dependency ,relationship with the instructions to be recovered.
[0138] An embodiment of the present application provides a space recovery method based on dual-port transmission, which maintains the logical execution order of dispatched instructions through a dispatched instruction order relationship table, and for a first instruction that has been executed, determines a third set of instructions in the dispatched instructions whose destination register index is the same as the destination register index of the first instruction based on relevant information of the instructions stored in an information stack; then determines whether there is a fourth set of instructions in the third set that are earlier in logical order than the first instruction based on the dispatched instruction order relationship table; if there are no instructions in the third set that are earlier in logical execution order than the first instruction, there are no instructions that have a WAW dependency relationship with the first instruction, and the processor immediately recovers the space number occupied by the first instruction and the space in the information stack occupied by the first instruction. That is, after detecting that an instruction has been executed, the processor can complete the judgment of the WAW dependency between the instruction and other instructions based on the dispatched instruction sequence table and instruction-related information within a single cycle. If the instruction does not have a WAW dependency with the dispatched instruction, it can be released immediately. In other words, the space in the information stack occupied by the instruction is no longer released in first-in-first-out order, that is, the release is out of order. Compared with the linear recovery mechanism used in related technologies, there is no need to wait for the first-dispatched instruction to be released first, so the invalid waiting time can be reduced. Therefore, the execution efficiency of the instruction can be improved while ensuring the sequence of instructions, with less logical delay, higher circuit operating frequency, and better processing efficiency of dual-issue high-performance processors.
[0139] In an optional embodiment of the present application, the above step of "the processor has dispatched the instruction sequence table, and determines whether there is a fourth set of instructions in the third set that is earlier in the logical execution order than the first instruction" can be specifically performed by the following steps:
[0140] The processor obtains a first logical execution order relationship between the first instruction and all other dispatched instructions from the dispatched instruction order relationship table. The processor determines whether there is a fourth set of instructions in the third set whose logical execution order is earlier than that of the first instruction based on the third set and the first logical execution order relationship.
[0141] Furthermore, if the fourth set exists, the processor determines that there is an instruction that has a WAW dependency relationship with the first instruction; if the fourth set does not exist, the processor determines that there is no instruction that has a WAW dependency relationship with the first instruction.
[0142] Based on this scheme, a dispatched instruction sequence relationship table is maintained in the processor, for example, it can be in the form of an age matrix or an age table. The dispatched instruction sequence relationship table maintains the logical execution sequence relationship between each dispatched instruction and all other dispatched instructions. When performing WAW dependency judgment, the logical execution order between instructions can be accurately obtained based on the dispatched instruction sequence relationship table, and then combined with the dispatched instructions with the same destination register as the first instruction and the logical execution order between instructions, it can be accurately determined whether there is an instruction that has a WAW dependency relationship with the first instruction, so that after the instruction is executed, it can be quickly determined whether the instruction can be released.
[0143] In an optional embodiment of the present application, the step of "if there are no instructions in the third set that are earlier in the logical execution order than the first instruction, the processor determines that there is no WAW dependency between the dispatched instructions and the first instruction, and immediately reclaims the space number occupied by the first instruction and the space in the information stack occupied by the first instruction" can be specifically executed through the following steps: after reclaiming the space occupied by the first instruction, write the index number of the space occupied by the first instruction to the end of the available list.
[0144] It can be understood that in the embodiment of the present application, the index number of the free space maintained in the available list is updated as the instructions are dispatched and recycled.
[0145] The first processing method: after the processor updates the relevant information of the first instruction to the first space of the information stack, the processor deletes the first index number corresponding to the first space in the available list; after the processor releases the relevant information of the first instruction from the first space of the information stack, the processor adds the first index number of the first space to the end of the available list.
[0146] The second processing method: after the processor updates the relevant information of the first instruction to the first space of the information stack, the processor sets the flag vld (Valid, valid flag) corresponding to the first index number corresponding to the first space in the available list to 0 (it can also be set to 1, which can be selected as needed); after the processor releases the relevant information of the first instruction from the first space of the information stack, the processor sets the flag vld corresponding to the first index number of the first space to 1 (it can also be set to 0, which can be selected as needed).
[0147] Based on this solution, after the processor reclaims the space in the information stack occupied by the instruction, the index number of the reclaimed space can be promptly added to the available list and updated in a timely manner to facilitate the search for free space when dispatching instructions in the next cycle, thereby improving the processing efficiency of the processor that supports dual-issue.
[0148] In an optional embodiment of the present application, after the above step of "the processor has dispatched the instruction sequence table, and determines whether there is a fourth set of instructions in the third set that are earlier in the logical execution order than the first instruction", the following steps may also be included:
[0149] If it is found that there is a first instruction in the third set whose logical execution order is earlier than the first instruction, the processor determines that the first instruction has a WAW dependency relationship with other dispatched instructions, stops searching, and controls the first instruction to continue waiting for release.
[0150] It can be understood that if there are instructions with the same destination register index as the first instruction, and among these instructions there are instructions whose execution order is earlier than the first instruction, it means that there is a WAW dependency relationship between the instructions and the first instruction. Therefore, although the first instruction has been executed, the space in the information stack occupied by the first instruction cannot be reclaimed.
[0151] Exemplarily, the logical execution order relationship between the first instruction and other dispatched instructions can be judged based on the value in the row corresponding to the space occupied by the first instruction in the age matrix. By combining the third set and the logical execution order relationship, it can be determined that there are instructions among the other dispatched instructions whose execution order is earlier than the first instruction and whose destination register is the same as the destination register of the first instruction. In the case of not being sure which specific instruction has a WAW dependency relationship with the first instruction, it can be quickly determined that the instruction will not be recycled.
[0152] Based on this solution, the processor can determine that there is a first instruction that is earlier than the first instruction among the instructions with the same target register as the first instruction based on querying the dispatched instruction sequence table. The processor can then determine that the first instruction has a WAW relationship with other instructions. Therefore, the processor does not need to determine which specific instruction has a WAW dependency relationship and no longer needs to continue querying. The first instruction can be controlled to continue waiting for release, thereby improving the processing efficiency of the processor.
[0153] In an optional embodiment of the present application, the instructions to be recovered include the first instruction and the fourth instruction, and the fourth instruction is an instruction executed after the first instruction. Then the above method may include the following steps: in the same recovery cycle, the processor determines whether there is an instruction with a WAW dependency relationship with the first instruction among the dispatched instructions, and determines whether there is an instruction with a WAW dependency relationship with the fourth instruction among the dispatched instructions. If the first instruction has a WAW dependency relationship with other dispatched instructions, and there is no instruction with a WAW dependency relationship with the fourth instruction, the processor will no longer continue to query for the first instruction, control the first instruction to continue to wait for release, and immediately reclaim the space number occupied by the fourth instruction and the space of the information stack occupied by the fourth instruction.
[0154] It is understandable that different instructions have different execution cycles, and an instruction that is executed earlier in the order of execution may not necessarily be completed earlier than an instruction that is executed later.
[0155] It should be noted that in an embodiment of the present application, when the processor determines that the currently executed instruction has a WAW dependency, it does not affect the recovery of other instructions. It can promptly determine whether other instructions have a WAW dependency without waiting for the instructions in the execution order to release space first, thereby reducing the waiting time for instruction release.
[0156] Specifically, the processor immediately adds the space number of the information stack occupied by the fourth instruction to the available list.
[0157] Based on this solution, when the execution of an instruction includes multiple instructions, the processor can execute the recovery process in parallel and synchronously. When the processor determines that the first instruction has a WAW dependency relationship with the instructions in the dispatched instructions, it will not affect the recovery of other instructions in the cycle. That is, the processor can simultaneously determine whether the multiple instructions that have been executed can be recovered, that is, it can simultaneously determine whether the multiple instructions that have been executed have a WAW dependency relationship with other dispatched instructions. There is no need to wait for the first instruction to be recovered before the fourth instruction is recovered, and invalid waiting for instructions can be avoided. The processor can quickly recover the space of instructions, release space in time, improve the space allocation efficiency of instructions, improve the efficiency of the processor in executing instructions, and improve the space utilization of the information stack.
[0158] In an optional embodiment of the present application, the executed instruction includes multiple instructions, and the first instruction is one of the multiple instructions. Then the above method may include the following steps: after determining that there is a fourth set of instructions in the third set that are earlier in logical execution order than the first instruction, the processor determines that the instruction with the latest logical execution order in the fourth set has a WAW dependency relationship with the first instruction. If the instruction with the latest logical execution order in the fourth set is one of the multiple instructions, the processor determines to reclaim the space number occupied by the first instruction and the space of the information stack occupied by the first instruction.
[0159] It can be understood that the instructions with the same destination register address as the first instruction may include multiple instructions that are earlier in logical execution order than the first instruction. Therefore, the youngest instruction (i.e., the latest in logical execution order) among the multiple instructions can be determined as the instruction that has a WAW dependency relationship with the first instruction.
[0160] It should be noted that, in actual applications, due to hardware mechanisms, some processors search for relevant information based on stored instructions in the information stack to determine whether the destination register of each dispatched instruction is the same as the destination register of the first instruction, and obtain a third set of instructions with the same destination register; the processor searches for the age information stream of the first instruction from the age matrix, and determines the first logical execution order of the first instruction and all dispatched instructions; then, based on the determined third set and the first logical execution order, it is determined that the destination register of an instruction is the same as the destination register of the first instruction, and the logical execution order is that the youngest instruction among the instructions with the same destination register is the instruction that has a WAW relationship with the first instruction.
[0161] Based on this scheme, when the executed instruction includes multiple instructions, the processor can execute the recycling process in parallel and synchronously. When the processor determines that the first instruction has a WAW dependency relationship with the first instruction in the dispatched instructions, the processor can determine whether the instruction that has a WAW dependency relationship with the first instruction is an instruction in the multiple instructions that have been executed within the clock cycle. If so, the first instruction can be recycled within the current clock cycle, that is, not only can it be simultaneously determined whether the multiple instructions that have been executed have a WAW dependency relationship with other dispatched instructions, but also when the dependent instructions are also executed instructions, there is no need to wait for the instructions that the first instruction depends on to be recycled before recycling the first instruction, which can avoid invalid waiting of instructions. The processor can quickly recycle the space of instructions, release space in time, improve the space allocation efficiency of instructions, improve the efficiency of processor execution of instructions, and improve the space utilization of the information stack.
[0162] Example 2:
[0163] The first step is to compare the rdidx of instruction 1 with the destination register index rdidx of all dispatched instructions (including instruction 2, instruction 3, instruction 4 and instruction 5) to obtain the set A{instruction 2, instruction 3, instruction 5} of all instructions that may have a WAW dependency with instruction 1.
[0164] Step 2: For each instruction among all dispatched instructions, its rdidx is compared with the rdidx of other dispatched instructions, and each instruction obtains the instruction set B with the same rdidx as the instruction. The logical execution order relationship 1 between each instruction and other dispatched instructions is obtained from the age matrix. According to the order relationship 1 and instruction set B, it is queried whether there is an instruction that is earlier than the logical execution order of each instruction and has the same destination register as instruction 1, and the set C corresponding to each dispatched instruction is obtained.
[0165] Step 3: Based on Set A and Set C, determine whether there is a dispatched instruction 2, the rdidx of instruction 2 is the same as the rsidx of instruction 1, and instruction 2 does not have any younger instruction with the same rdidx than instruction 1. If instruction 2 exists, then instruction 1 depends on instruction 2; if instruction 2 does not exist, then instruction 2 has no dependent instructions and there is no dependency relationship.
[0166] It should be understood that, although the various steps in the flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the figure may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0167] See also Figure 7 , Figure 7 A schematic diagram of the structure of a dual-port transmission space allocation device provided for an embodiment of the present application, the device 700 includes: a search module 701, a judgment module 702 and an update module 703; the search module 701 is used to search for the index numbers of two free spaces from both ends of the available list at the same time after the dual-port dispatches the instruction; the available list is used to indicate the index of the free space in the information stack, and the information stack is used to store the relevant information of the dispatched instruction; the judgment module 702 is used to judge the RAW dependency relationship between the current dispatched instruction and the dispatched instruction according to the relevant information of the instruction and the dispatched instruction sequence table; the dispatched instruction sequence table is used to store the logical execution sequence of each dispatched instruction and other dispatched instructions; the update module 703 is used to update the relevant information of the current dispatched instruction into the information stack according to the index number of the two free spaces; the update module 703 is also used to update the sequence relationship between the current dispatched instruction and the dispatched instruction into the dispatched instruction sequence table according to the index of the two free spaces.
[0168] In an optional embodiment of the present application, the judgment module 702 is specifically used to: determine a first set of instructions in the dispatched instructions whose target register index is the same as the operand of the currently dispatched instruction; determine a second set of instructions in the first set whose logical execution order is earlier than the logical order of the currently dispatched instruction based on the dispatched instruction sequence table; determine the instruction in the second set that is closest to the logical execution order of the currently dispatched instruction as the instruction with which the currently dispatched instruction has a RAW dependency, otherwise the currently dispatched instruction does not have a RAW dependency.
[0169] In an optional embodiment of the present application, the index values of the two free spaces are different; the current dispatch instruction includes a first instruction and a second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; the update module 703 is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack, and store the relevant information of the second instruction in the space corresponding to the second number in the information stack; wherein the first number is the number of the first free space in the available list with a value from small to large, and the second number is the number of the first free space in the available list with a value from large to small.
[0170] In an optional embodiment of the present application, the index values of the two free spaces are different, and the current dispatch instruction includes the first instruction; the update module 703 is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack, update the flag bit corresponding to the first number in the available list, and keep the flag bit of the second number unchanged; wherein the first number is the number of the first free space in the available list with a value from small to large, and the second number is the number of the first free space in the available list with a value from large to small.
[0171] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction and the second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; the update module 703 is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack; and suspend the allocation of space for the second instruction in this cycle.
[0172] In an optional embodiment of the present application, the index values of the two free spaces are both the first number, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction; the update module 703 is specifically used to: store the relevant information of the first instruction in the space corresponding to the first number in the information stack.
[0173] In an optional embodiment of the present application, the dispatched instruction sequence table is an N-level table that can store the logical execution sequence of N dispatched instructions, and each row corresponds to the sequence between a dispatched instruction and other dispatched instructions.
[0174] It should be noted that the above-mentioned dual-port transmission space allocation device can achieve the effects in the above-mentioned method embodiment, which will not be described in detail here.
[0175] For the specific definition of the spatial allocation device for dual-port transmission, please refer to the definition of the spatial allocation method for dual-port transmission mentioned above, which will not be repeated here. Each module in the spatial allocation device for dual-port transmission can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0176] In one embodiment, a computer device is provided, the internal structure diagram of which can be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a spatial allocation method for dual-port transmission as described above is implemented.
[0177] In one embodiment, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements any step in the above dual-port transmission space allocation method when executing the computer program.
[0178] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any step in the above-mentioned spatial allocation method for dual-port transmission can be implemented.
[0179] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0180] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0181] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0183] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0184] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A spatial allocation method for dual-port transmission, characterized in that: The method comprises: After the dual-port dispatches the instruction, the index numbers of two free spaces are searched simultaneously from both ends of the available list; the available list is used to indicate the index of the free space in the information stack, and the information stack is used to store the relevant information of the dispatched instruction; Determine the RAW dependency between the currently dispatched instruction and the dispatched instruction according to the instruction related information and the dispatched instruction sequence table; the dispatched instruction sequence table is used to store the logical execution sequence of each dispatched instruction and other dispatched instructions; According to the index numbers of the two free spaces, updating the relevant information of the current dispatched instruction into the information stack; According to the indexes of the two free spaces, the order relationship between the currently dispatched instruction and the dispatched instructions is updated into the dispatched instruction order relationship table.
2. The method according to claim 1, characterized in that According to the relevant information of the instruction and the order table of the dispatched instructions, the RAW dependency relationship between the currently dispatched instruction and the dispatched instructions is determined, including: determining a first set of dispatched instructions having a target register index that is the same as an operand of the currently dispatched instruction; Determine, according to the dispatched instruction sequence table, a second set of instructions in the first set whose logical execution order is earlier than the logical order of the currently dispatched instruction; The instruction in the second set that is closest in logical execution order to the currently dispatched instruction is determined to be the instruction with which the currently dispatched instruction has a RAW dependency; otherwise, the currently dispatched instruction does not have a RAW dependency.
3. The method according to claim 1, characterized in that The index values of the two free spaces are different; the currently dispatched instruction includes a first instruction and a second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; The updating of the relevant information of the current dispatched instruction into the information stack according to the indexes of the two free spaces includes: The related information of the first instruction is stored in the space corresponding to the first number in the information stack, and the related information of the second instruction is stored in the space corresponding to the second number in the information stack; The first number is the number of the first free space in the available list from the smallest value to the largest value, and the second number is the number of the first free space in the available list from the largest value to the smallest value.
4. The method according to claim 1, characterized in that: The index values of the two free spaces are different, and the current dispatch instruction includes a first instruction; storing the relevant information of the first instruction in the space corresponding to the first number in the information stack, updating the flag bit corresponding to the first number in the available list, and keeping the flag bit of the second number unchanged; The first number is the number of the first free space in the available list from the smallest value to the largest value, and the second number is the number of the first free space in the available list from the largest value to the smallest value.
5. The method according to claim 1, characterized in that The index values of the two free spaces are both first numbers, and the first number is the number of the only free space in the available list; the current dispatch instruction includes a first instruction and a second instruction, and the logical execution order of the first instruction is earlier than the logical execution order of the second instruction; The updating, according to the indexes of the two free spaces, of the relevant information of the current dispatched instruction into the information stack comprises: storing the relevant information of the first instruction in the space corresponding to the first number in the information stack; In this cycle, the allocation of space for the second instruction is suspended.
6. The method according to claim 1, characterized in that The index values of the two free spaces are both first numbers, and the first number is the number of the only free space in the available list; the current dispatch instruction includes the first instruction; The updating, according to the indexes of the two free spaces, of the relevant information of the current dispatched instruction into the information stack comprises: The relevant information of the first instruction is stored in the space corresponding to the first number in the information stack.
7. The method according to claim 1, characterized in that The dispatched instruction sequence table is an N-order table, which can store the logical execution sequence of N dispatched instructions. Each row corresponds to the sequence between a dispatched instruction and other dispatched instructions, and N is a positive integer.
8. A spatial allocation device for dual-port transmission, characterized in that: The device comprises: a search module, a judgment module and an update module; The search module is used to search for index numbers of two free spaces from both ends of the available list at the same time after the dual-port dispatches the instruction; the available list is used to indicate the index of the free space in the information stack, and the information stack is used to store the relevant information of the dispatched instruction; The judgment module is used to judge the RAW dependency relationship between the current dispatched instruction and the dispatched instructions according to the relevant information of the instruction and the dispatched instruction sequence table; the dispatched instruction sequence table is used to store the logical execution sequence of each dispatched instruction and other dispatched instructions; The updating module is used to update the relevant information of the current dispatching instruction into the information stack according to the index numbers of the two free spaces; The updating module is further used to update the order relationship between the currently dispatched instruction and the dispatched instructions into the dispatched instruction order relationship table according to the indexes of the two free spaces.
9. A computer device comprising: A memory and a processor, wherein the memory stores a computer program, wherein when the processor executes the computer program, the steps of the spatial allocation method for dual-port transmission according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the spatial allocation method for dual-port transmission according to any one of claims 1 to 7 are implemented.
