WO2016201699A1 - Instruction processing method and device - Google Patents
Instruction processing method and device Download PDFInfo
- Publication number
- WO2016201699A1 WO2016201699A1 PCT/CN2015/081954 CN2015081954W WO2016201699A1 WO 2016201699 A1 WO2016201699 A1 WO 2016201699A1 CN 2015081954 W CN2015081954 W CN 2015081954W WO 2016201699 A1 WO2016201699 A1 WO 2016201699A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- instruction
- key
- executable
- instructions
- executed
- Prior art date
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 12
- 238000000034 method Methods 0.000 claims abstract description 45
- 238000004891 communication Methods 0.000 claims description 3
- 238000013500 data storage Methods 0.000 claims description 3
- 230000003111 delayed effect Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
Definitions
- the present invention relates to the field of computers, and in particular, to an instruction processing method and device.
- the process of the instruction processing may be: the processor included in the device fetches instructions from the instruction cache according to the instruction sequence, and obtains a plurality of instructions, where the order of the instructions is the sequence in which the application sequentially runs the multiple instructions. .
- the plurality of instructions are decoded, and the decoded plurality of instructions are executed in the order of the instructions.
- execution may be performed after the long delay instruction and independent of the long delay instruction
- the instructions are based on the target register numbers of the plurality of instructions, and the execution results of the plurality of instructions are submitted to the corresponding target registers according to the instruction sequence, thereby implementing processing of the plurality of instructions.
- an embodiment of the present invention provides an instruction processing method and device.
- the technical solution is as follows:
- an instruction processing method comprising:
- a key instruction in at least one executable instruction the key instruction being a long delay instruction or an instruction located on a critical instruction chain, the key instruction chain comprising an Nth order instruction, wherein the ith of the Nth order instructions
- the order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i th order instruction is a source register of the i+1th order instruction, and the Nth of the key instruction chain
- the order instruction is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;
- the key instructions of the at least one executable instruction are preferentially executed.
- the method before the determining the key instruction in the at least one executable instruction, the method further includes:
- At least one executable instruction is determined.
- the determining the key instruction in the at least one executable instruction includes:
- the critical instruction identification of any of the executable instructions is valid or the any executable instruction is a long delay instruction, it is determined that the any executable instruction is a key instruction.
- the method further includes:
- the key instruction identifier of the producer instruction of the key instruction is set to be valid.
- the method further includes:
- the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction
- the key instruction identifier of the long delay instruction is set to be valid.
- the method further includes:
- the identity of the critical instruction is written into the instruction cache each time a critical instruction identification of an instruction is set to be valid.
- the determining whether the any executable instruction is a long delay instruction comprises:
- the key type library contains an instruction type of any of the executable instructions, it is determined that the any executable instruction is a long delay instruction.
- the determining whether the any executable instruction is a long delay instruction comprises:
- the key address library contains an instruction address of any of the executable instructions, it is determined that the any executable instruction is a long delay instruction.
- the method further comprises:
- the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions is sequentially written into each of the The target register corresponding to the instruction to be executed.
- a computing device readable medium comprising: a computing device executing instructions that, when a processor of a computing device executes the computing device to execute an instruction, the computing device performs the first aspect to the first aspect A method as described in any of the possible implementations of the eight possible implementations.
- an instruction processing device comprising: a processor, a memory, a bus, and a communication interface;
- the memory is configured to store a computer execution instruction
- the processor is coupled to the memory via the bus, and when the data storage device is in operation, the processor executes the computer-executed instruction stored in the memory to
- the instruction processing device is caused to perform the method of any one of the first aspect to the eighth possible implementation of the first aspect.
- an instruction processing device comprising:
- an execution module configured to preferentially execute the key instruction in the at least one executable instruction.
- the device further includes an instruction fetching module
- the fetching module is configured to fetch a plurality of to-be-executed instructions from the instruction cache;
- the determining module is further configured to determine at least one executable instruction from the plurality of to-be-executed instructions.
- the determining module is configured to determine a key instruction in the at least one executable instruction, including:
- a determining unit configured to determine, according to any one of the at least one executable instructions, the determining module is configured to determine whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is A long delay instruction; when the key instruction identifier of any of the executable instructions is valid or the any executable instruction is a long delay instruction, it is also used to determine that any of the executable instructions is a key instruction.
- the device further includes:
- a first setting module configured to set a key instruction identifier of a producer instruction of the key instruction to be valid when a producer instruction is present in the key instruction, and a producer instruction of the key instruction is not marked as a key instruction .
- the device further includes:
- a second setting module configured to: when the key instruction identifier of the critical instruction is invalid and the key instruction is a long delay instruction, set a key instruction identifier of the long delay instruction to be valid.
- the device further includes:
- the first write module is configured to write an identifier of the key instruction into the instruction cache every time a key instruction identifier of an instruction is set to be valid.
- the determining, the determining, by the determining, the determining, whether the any executable instruction is a long delay instruction includes:
- the determining module is configured to decode any one of the executable instructions to obtain an instruction type of the any executable instruction
- the key type library contains the instruction type of any of the executable instructions, it is also used to Any of the executable instructions is a long delay instruction.
- the determining, the determining, the determining, by the determining is a possible implementation manner of the foregoing fourth aspect.
- the determining module is configured to determine whether the stored key address library includes an instruction address of the any executable instruction
- the key address library contains an instruction address of any of the executable instructions, it is used to determine that any of the executable instructions is a long delay instruction.
- the device further includes:
- An allocation module configured to respectively allocate a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each of the to-be-executed instructions;
- the device further includes:
- a second write module configured to write an execution result of the to-be-executed instruction into a corresponding storage space every time an execution result of an instruction to be executed is obtained; and to be used after the execution of the plurality of to-be-executed instructions ends And executing, in an instruction sequence of the plurality of instructions, an execution result in a storage space corresponding to each of the plurality of to-be-executed instructions in a target register corresponding to each to-be-executed instruction.
- the key instruction in the at least one executable instruction is determined, and when the at least one executable instruction is executed, the at least one executable may be preferentially executed.
- the key instruction in the instruction because the key instruction includes the long delay instruction, the priority execution of the key instruction in the at least one executable instruction can delay the execution time of the instruction in advance, and during the execution of the long delay instruction, it can be guaranteed There are enough irrelevant instructions to execute, which reduces the processor's latency and improves the processor's processing performance.
- FIG. 1 is a flowchart of an instruction processing method according to an embodiment of the present invention.
- FIG. 2 is a flowchart of another instruction processing method according to an embodiment of the present invention.
- FIG. 3 is a schematic diagram of an instruction processing process according to an embodiment of the present invention.
- FIG. 4 is a schematic structural diagram of an instruction processing apparatus according to an embodiment of the present invention.
- FIG. 5 is a schematic structural diagram of another instruction processing apparatus according to an embodiment of the present invention.
- FIG. 6 is a schematic structural diagram of still another instruction processing apparatus according to an embodiment of the present invention.
- an embodiment of the present invention provides an instruction processing method to improve performance of a processor.
- FIG. 1 is a flowchart of an instruction processing method according to an embodiment of the present invention. Referring to Figure 1, the method includes:
- Step 101 Determine a key instruction in at least one executable instruction, where the key instruction refers to a long delay instruction or an instruction located on a key instruction chain, where the key instruction chain includes an N-th order instruction, wherein the N-th order instruction
- the i-th order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i-th order instruction is a source register of the i+1th order instruction
- the Nth order instruction on the chain is a long delay instruction
- N is a positive integer greater than 1
- i is a positive integer greater than 0 and less than N.
- Step 102 Preferential execution of the key instruction in the at least one executable instruction.
- a key instruction in the at least one executable instruction is determined, and when the at least one executable instruction is executed, the key instruction in the at least one executable instruction may be preferentially executed, because the key instruction includes a long delay instruction Therefore, preferential execution of the key instruction in the at least one executable instruction may delay the execution time of the instruction in advance, and during the execution of the long delay instruction, ensure that there are enough irrelevant instructions to be executed, thereby reducing processing. The wait time of the device, thereby improving the processing performance of the processor.
- target register of instruction 1 is the source register of instruction 2, that is, instruction 2 is to be operated using the calculation result of instruction 1, then instruction 1 is the producer instruction of instruction 2, and instruction 2 is the consumer instruction of instruction 1, indicating instruction 1 There is a logical sequential execution relationship with instruction 2, and instruction 1 is executed prior to instruction 2.
- the method further includes:
- At least one executable instruction is determined.
- determining key instructions in the at least one executable instruction including:
- the method further includes:
- the key instruction identifier of the producer instruction of the key instruction is set to be valid.
- the method further includes:
- the length is The critical instruction ID of the delayed instruction is set to be valid.
- the method further includes:
- the identity of the key instruction is written to the instruction cache each time a critical instruction flag of an instruction is set to be valid.
- determining whether the any executable instruction is a long delay instruction comprises:
- the key type library contains an instruction type of any of the executable instructions, it is determined that the executable instruction is a long delay instruction.
- determining whether the any executable instruction is a long delay instruction comprises:
- the key address library contains the instruction address of any of the executable instructions, then it is determined that the executable instruction is a long delay instruction.
- the method further includes:
- the method further comprises:
- the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions is sequentially written to each to-be-executed instruction.
- Target register After the execution of the plurality of to-be-executed instructions is ended, in accordance with the instruction sequence of the plurality of instructions, the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions is sequentially written to each to-be-executed instruction.
- the optional embodiments of the present invention may be used in any combination to form an optional embodiment of the present invention.
- FIG. 2 is a flowchart of a method for processing an instruction according to an embodiment of the present invention. See Figure 2, the party The law includes:
- Step 201 Extract a plurality of to-be-executed instructions from the instruction cache according to the instruction sequence.
- a plurality of to-be-executed instructions may be fetched from the instruction cache according to the instruction sequence.
- the order of the instructions is the order in which the application runs the multiple instructions one after another.
- the instruction cache includes seven instructions, namely an ADD instruction, a SUB instruction, an AND instruction, an XOR instruction, an LSL instruction, an LSR instruction, and a LOAD instruction, and the application sequentially runs the seven instructions.
- the instruction sequence is ADD instruction, SUB instruction, AND instruction, XOR instruction, LSL instruction, LSR instruction and LOAD instruction. Therefore, the processor fetches a plurality of to-be-executed instructions from the instruction cache into an ADD instruction, a SUB instruction, an AND instruction, an XOR instruction, an LSL instruction, an LSR instruction, and a LOAD instruction according to the instruction sequence.
- the processor may fetch the plurality of to-be-executed instructions one by one from the instruction cache according to the instruction sequence, where the embodiment of the present invention This is not specifically limited.
- the processor may also remove the multiple to-be-executed instructions from the instruction cache without following the instruction sequence, that is, the processor may fetch the instruction from the instruction cache out of order.
- the processor may also remove the multiple to-be-executed instructions from the instruction cache without following the instruction sequence, that is, the processor may fetch the instruction from the instruction cache out of order.
- the embodiment of the present invention does not specifically limit this.
- Step 202 Determine at least one executable instruction from the plurality of to-be-executed instructions.
- the processor may determine whether the operand of the any instruction to be executed is ready, and if the operand of the to-be-executed instruction is ready, determine the standby
- the execution instruction is an executable instruction, and any of the execution instructions can be executed immediately without waiting for the execution of the instruction before the execution of any of the execution instructions. If the operand of any of the to-be-executed instructions is not ready, it is determined that the any instruction to be executed is an unexecutable instruction. At this time, it is necessary to wait until the operand of any of the to-be-executed instructions is ready to execute any of the to-be-executed instruction.
- the operand of any of the to-be-executed instructions is data stored in a source register of the any instruction to be executed.
- the processor may determine whether the source register of the any to-be-executed instruction is valid, and if the source register of the any to-be-executed instruction is valid, determine the Once the execution instruction is an executable instruction, the any execution instruction can be executed immediately without waiting for the execution of the instruction before the execution of the any execution instruction. If the source register of any of the to-be-executed instructions is invalid, it is determined that any of the to-be-executed instructions is an unexecutable instruction, and at this time, it is necessary to wait until the source register of any of the to-be-executed instructions is valid, .
- a storage space may be allocated for each of the plurality of to-be-executed instructions.
- Each storage space is used to store the execution result of each instruction to be executed.
- the execution result of the instruction to be executed can be written into a corresponding storage space.
- the storage space corresponding to the instruction to be executed is set to be valid, that is, the target register of the instruction to be executed is set to be valid.
- the processor may allocate a storage number to each of the plurality of to-be-executed instructions, respectively, when a storage space is allocated for each of the plurality of to-be-executed instructions, the storage number The number corresponding to the storage space. Since the plurality of storage spaces include a pointer, the initial position of the pointer points to the first storage space. Therefore, when a storage number is respectively assigned to the plurality of to-be-executed instructions, the storage number pointed to by the pointer may be assigned to the storage space. a plurality of instructions to be executed, and each time a memory number is assigned, the pointer is shifted down by one bit, thereby obtaining the plurality of to-be-executed instructions Storage number. That is, in the embodiment of the present invention, a plurality of memory numbers may be allocated to the plurality of instructions to be executed in the order of instructions.
- the initial position of the pointer points to the first storage space. Therefore, the number 1 of the first storage space is assigned to the ADD instruction. At this time, the pointer moves down one bit, that is, the pointer points to the second Storage space, therefore, assign the number 2 of the second storage space to the SUB instruction. Similarly, assign the number 3 of the third storage space to the AND instruction, and assign the number 4 of the fourth storage space to the XOR instruction.
- the fifth storage space number 5 is assigned to the LSL instruction
- the sixth storage space number 6 is assigned to the LSR instruction
- the seventh storage space number 7 is assigned to the LOAD instruction.
- the storage number may be a Re-Order Buffer (ROB) number, and the storage space may be each entry in the ROB, which is not specifically limited in this embodiment of the present invention.
- ROB Re-Order Buffer
- Step 203 Determine a key instruction in the at least one executable instruction, where the key instruction refers to a long delay instruction or an instruction located in a key instruction chain, where the key instruction chain includes an Nth order instruction, wherein the ith order in the Nth order instruction
- the instruction is a producer instruction of the i+1th order instruction, and the producer instruction is that the target register of the i th order instruction is a source register of the i+1th order instruction, and the Nth order instruction on the key instruction chain is a long delay
- the instruction, N is a positive integer greater than 1
- i is a positive integer greater than 0 and less than N.
- a certain order key instruction on a key instruction chain may have a positive integer number greater than one.
- the addition instruction may have N A producer instruction, so there are N upper-order key instructions of the addition instruction.
- any executable instruction of the at least one executable instruction determining whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction; When the key instruction identifier of the instruction is valid or the executable instruction is a long delay instruction, determining that the executable instruction is a key instruction, thus determining a key instruction in the at least one executable instruction.
- the instruction to be executed and the producer instruction of the instruction to be executed constitute an instruction. a chain, and when the instruction to be executed is a key instruction, and the producer instruction of the key instruction is not marked as a key instruction, setting the key instruction identifier of the producer instruction of the key instruction to be valid, that is, executing After a key instruction, the producer instruction of the key instruction can be marked as a key instruction. If the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction, the key instruction identifier of the long delay instruction is set to be valid, that is, the long delay instruction is marked as a key instruction.
- next instruction to be executed when the next instruction to be executed is executed, if the producer instruction of the next instruction to be executed is the last instruction in the chain, the next instruction to be executed is added to the end of the chain until the traversal A number of pending instructions.
- the instruction chain is referred to as a key instruction chain.
- the to-be-executed instruction located on the same instruction chain has a relationship between the producer instruction and the consumer instruction, that is, when the target register of the i-th to-be-executed instruction on the instruction chain is the (i+1)th.
- the i-th order to-be-executed instruction may be referred to as the producer instruction of the i+1th-order to-be-executed instruction, and the i-th order-to-be-executed instruction is referred to as the i-th order to-be-executed instruction.
- Consumer instruction is referred to as the producer instruction of the i+1th-order to-be-executed instruction.
- the key instruction identifier is used to identify whether the instruction to be executed is a key instruction or a non-key instruction, that is, when the key instruction identifier of an instruction to be executed is valid, it may be determined that the instruction to be executed is a key instruction, and when When the key instruction identifier of the instruction to be executed is invalid, it may be determined that the instruction to be executed is a non-critical instruction.
- the key operation identifier can be set to a valid operation by setting the key instruction identifier to the first value. When the key instruction identifier is invalid, the key instruction identifier can be set to the second value.
- the first value and the second value may be set in advance. For example, the first value may be 1 and the second value may be 0, which is not specifically limited in the embodiment of the present invention.
- each critical instruction identification can be stored in the instruction cache whenever a critical instruction identification of an instruction to be executed is set to be valid. In this way, when the instruction to be executed is taken out from the instruction cache next time, the key instruction can be directly learned, and the efficiency of the instruction processing is improved.
- whether the executable instruction is a long delay instruction may be determined in two ways, including:
- the first way is to decode the executable instruction to obtain the instruction type of the executable instruction; determine whether the stored key type library contains the instruction type of the executable instruction; if the key type The library contains the type of instruction for any of the executable instructions, and then determines that any of the executable instructions is a long delayed instruction. If the type of the instruction of the executable instruction is not included in the key type library, it is determined that the executable instruction is a long delay instruction.
- the executable instruction is a LOAD instruction, and the executable instruction is decoded, and the instruction type of the executable instruction is the memory access instruction.
- the executable instruction may be The instruction type is compared with the instruction type included in the key type library shown in Table 2 below, and the instruction type of the executable instruction is determined in the key type library. At this time, it is determined that the executable instruction is a long delay. instruction.
- the key type library may be set to include an instruction type, but also whether the any executable instruction is a long delay instruction based on the foregoing method.
- the processor decodes any of the executable instructions to obtain the type of instruction for any of the executable instructions. Then, based on the instruction type of the executable instruction, the corresponding identification value is obtained from the stored key type library, and if the acquired identification value is the first value, determining that the executable instruction is a long delay instruction, if Obtaining the identifier value as the second value, determining that the executable instruction is not a long delay instruction.
- the key type library may include a correspondence between the instruction type and the identifier value.
- the instruction type corresponding to each identifier value in the key type library may be agreed in advance.
- the key The value of the identifier may be included in the type library, which is not specifically limited in the embodiment of the present invention.
- the correspondence between the key type library including the instruction type and the identification value is taken as an example for description.
- the executable instruction is a LOAD instruction, and the executable instruction is decoded, and the instruction type of the executable instruction is the memory access instruction.
- the corresponding identification value is 1 from the correspondence between the stored instruction type and the identification value shown in Table 3 below. At this time, the executable instruction is determined. For long delay instructions.
- the second method determines whether the stored address address of the executable instruction is included in the stored key address library; if the command address of the executable instruction is included in the critical address library, determining that the executable instruction is long Delayed instruction. If the instruction address of any of the executable instructions is not included in the critical address library, it is determined that the executable instruction is not a long delay instruction.
- any of the executable instructions is a LOAD instruction
- the instruction address of the LOAD instruction is 0x1f00_0340.
- the processor compares the instruction address of the LOAD instruction with the key address library shown in Table 4 below, and determines that the instruction address of the LOAD instruction is included in the key address library, and therefore, determining that any executable instruction is long Delayed instruction.
- the instruction address of the instruction is the storage address of the instruction, which is not specifically limited in this embodiment of the present invention.
- the key type library and the key address library are configured in advance, and the key type library and the key address library can be dynamically modified, which is not specifically limited in the embodiment of the present invention.
- Step 204 Priority execution of key instructions in the at least one executable instruction.
- the processor preferentially executes the key instruction in the at least one executable instruction
- the unrelated instruction may be executed during the execution of the long delay instruction, thereby executing the multiple instruction to obtain The execution result of the multiple instructions.
- the irrelevant instruction is an instruction other than the instruction included in the key instruction chain of the long delay instruction in the plurality of instructions.
- the key instruction can include a long delay instruction
- the key instruction in the at least one executable instruction is preferentially executed, so that there are enough irrelevant instructions in the execution of the long delay instruction. Execute, reduce processor wait time, and improve processing Processing performance.
- the execution result of an instruction to be executed when the execution result of an instruction to be executed is obtained, the execution result of the instruction to be executed may be written into the corresponding storage space.
- the execution result of the AND instruction when the execution result of the AND instruction is 01110110, the execution result may be stored in the third storage space in the ROB.
- the execution result of the LSL instruction is 11101100, the execution result may be stored in the ROB.
- the fifth storage space in the same way, stores the execution result of the LOAD instruction in the seventh storage space in the ROB, stores the execution result of the ADD instruction in the first storage space in the ROB, and stores the execution result of the SUB instruction.
- the execution result of the XOR instruction is stored in the fourth storage space in the ROB, and the execution result of the LSR instruction is stored in the sixth storage space in the ROB.
- Step 205 Write, according to the target register number of the plurality of instructions, the execution result of the plurality of instructions into the corresponding target register according to the instruction sequence.
- the processor may sequentially follow the instruction sequence of the plurality of to-be-executed instructions.
- the execution result in the storage space corresponding to each to-be-executed instruction in the to-be-executed instruction is written to the target register corresponding to each instruction to be executed.
- the processor may obtain an execution result of each to-be-executed instruction from a storage space corresponding to the plurality of to-be-executed instructions; and perform an execution result according to the target register number of the plurality of to-be-executed instructions. Write to the corresponding destination register.
- the processor when the processor writes the execution result of the multiple to-be-executed instructions into the corresponding target register according to the instruction sequence, if the current pending execution instruction has not obtained the execution result, even if the current pending execution instruction is to be executed The execution instruction obtains the execution result, and then the execution result of the to-be-executed instruction after the current to-be-executed instruction cannot be written to the corresponding target register across the current to-be-executed instruction, and can only wait until the current to-be-executed instruction obtains the execution result, and the After the execution result is written into the corresponding target register, the execution result of the instruction to be executed after the current instruction to be executed can be submitted to the corresponding target register.
- the storage number corresponding to the instruction to be executed may be released, and the corresponding storage space is released.
- the process of processing an instruction may be represented by a process as shown in FIG. 3 below, that is, the processor needs to first fetch a plurality of to-be-executed instructions from the instruction cache. Thereafter, the plurality of to-be-executed instructions are decoded, and the long-delay instruction among the plurality of to-be-executed instructions is identified based on the configuration information in the decoding stage, the configuration information including a key type library or a key address library. Re-naming each instruction to be executed, that is, allocating a storage space for each instruction to be executed, then starting to execute the plurality of instructions to be executed, and storing the execution result of the plurality of instructions to be executed in Corresponding storage space. Afterwards, the processor can also store each key instruction identifier in the instruction cache to facilitate the next instruction fetching and improve the instruction processing efficiency.
- a plurality of to-be-executed instructions may be fetched from the instruction cache according to an instruction sequence, and at least one executable instruction is obtained from the plurality of to-be-executed instructions, and when the at least one executable instruction is executed
- the key instruction in the at least one executable instruction may be preferentially executed. Since the key instruction includes a long delay instruction, the key instruction in the at least one executable instruction is preferentially executed, and the execution time of the instruction may be delayed in advance, and During the execution of a long delay instruction, it is guaranteed that there are enough irrelevant instructions to execute, thereby reducing the waiting time of the processor, thereby improving the processing performance of the processor.
- Embodiments of the present invention provide a computing device readable medium, including a computing device executing instructions, when the processor of the computing device executes the computing device to execute an instruction, the computing device may perform the instruction processing method described above.
- an embodiment of the present invention provides an instruction processing device, which includes: a processor 401, a memory 402, a bus 403, and a communication interface 404;
- the memory 402 is used to store computer execution instructions 4021 through which the processor 401 and the memory 402 are connected.
- the processor 401 executes the memory 402.
- the computer executes the instructions to cause the instruction processing device to perform the instruction processing method described above.
- FIG. 5 is a schematic structural diagram of an instruction processing apparatus according to an embodiment of the present invention. Referring to Figure 5, the device includes:
- the determining module 501 is configured to determine a key instruction in the at least one executable instruction, where the key instruction refers to a long delay instruction or an instruction located on a key instruction chain, where the key instruction chain includes an N-th order instruction, wherein the N-th order instruction
- the i-th order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i-th order instruction is a source register of the i+1th order instruction, and the Nth order of the key instruction chain
- the instruction is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;
- the execution module 502 is configured to preferentially execute the key instructions in the at least one executable instruction.
- the device further includes:
- the fetch module 503 is configured to fetch a plurality of to-be-executed instructions from the instruction cache.
- the determining module 501 is further configured to determine at least one executable instruction from the plurality of to-be-executed instructions.
- the determining module 401 is configured to determine key instructions in the at least one executable instruction, including:
- the determining module 401 is configured to determine whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction; When the key instruction identifier of the executable instruction is valid or the executable instruction is a long delay instruction, it is also used to determine that the executable instruction is a key instruction.
- the device further includes:
- the first setting module is configured to set a key instruction identifier of the producer instruction of the key instruction to be valid when the manufacturer instruction is present in the key instruction, and the producer instruction of the key instruction is not marked as the key instruction.
- the device further includes:
- the second setting module is configured to set the key instruction identifier of the long delay instruction to be valid when the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction.
- the device further includes:
- the first write module is configured to write the identifier of the critical instruction into the instruction cache every time the critical instruction identifier of an instruction is set to be valid.
- the determining module 501 is configured to determine whether the any executable instruction is a long delay instruction, including:
- a determining module 501 configured to decode the executable instruction to obtain an instruction type of the executable instruction
- the key type library contains an instruction type of any of the executable instructions, it is also used to determine that any of the executable instructions is a long delay instruction.
- the determining module 501 is configured to determine whether the any executable instruction is a long delay instruction, including:
- a determining module 501 configured to determine whether the stored key address library includes an instruction address of the executable instruction
- the key address library contains the instruction address of any of the executable instructions, it is used to determine that any of the executable instructions is a long delay instruction.
- the device further includes:
- An allocation module configured to respectively allocate a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each to-be-executed instruction;
- the device further includes:
- a second write module configured to write an execution result of the to-be-executed instruction into a corresponding storage space every time an execution result of the to-be-executed instruction is obtained; and, after the execution of the plurality of to-be-executed instructions ends, follow
- the instruction sequence of the plurality of to-be-executed instructions sequentially writes the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions to the target register corresponding to each instruction to be executed.
- determining a key instruction in the at least one executable instruction while performing the When at least one executable instruction is executed the key instruction in the at least one executable instruction may be preferentially executed. Since the key instruction includes a long delay instruction, the key instruction in the at least one executable instruction is preferentially executed, and the instruction may be delayed in advance. Execution time, and during the execution of the long delay instruction, it can be ensured that there are enough irrelevant instructions to be executed, thereby reducing the waiting time of the processor, thereby improving the processing performance of the processor.
- a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
- the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Advance Control (AREA)
Abstract
An embodiment of the present invention provides an instruction processing method and device, and relates to the field of computers. The method comprises: determining at least one key instruction in executable instructions, the key instruction being a long-delay instruction or an instruction located in a key instruction chain, the key instruction chain comprising N steps of instructions, wherein, an i-th step instruction of the N steps of instructions is a producer instruction of an i + 1 step instruction. In the producer instruction, a target register of an i-th-step instruction is a source register of an i + 1 step instruction, and an N-th step instruction of the key instruction chain is a long-delay instruction, where N is a positive integer greater than 1, and i is a positive integer greater than 0 but less than N; and prioritizing execution of the at least one key instruction in the executable instructions. The present invention advances an execution time of a long delay instruction, further improving a processing function of a processor.
Description
本发明涉及计算机领域,特别涉及一种指令处理方法及设备。The present invention relates to the field of computers, and in particular, to an instruction processing method and device.
在计算机领域,为了使设备实现某个功能,需要在该设备上安装一个应用程序。而为了运行该应用程序,需要对该应用程序包括的指令进行处理。In the computer world, in order for a device to implement a certain function, an application needs to be installed on the device. In order to run the application, the instructions included in the application need to be processed.
目前,指令处理的过程可以为:该设备包括的处理器按照指令顺序,从指令缓存包括的指令中进行取指,得到多个指令,该指令顺序为该应用程序先后运行该多个指令的顺序。对该多个指令进行译码,并按照该指令顺序,执行译码后的多个指令。在执行译码后的多个指令的过程中,如果执行到引起长延迟操作的长延迟指令时,可以在该长延迟指令执行过程中,执行位于该长延迟指令之后且与该长延迟指令无关的指令,从而基于该多个指令的目标寄存器编号,按照该指令顺序,将该多个指令的执行结果提交给对应的目标寄存器,进而实现该多个指令的处理。At present, the process of the instruction processing may be: the processor included in the device fetches instructions from the instruction cache according to the instruction sequence, and obtains a plurality of instructions, where the order of the instructions is the sequence in which the application sequentially runs the multiple instructions. . The plurality of instructions are decoded, and the decoded plurality of instructions are executed in the order of the instructions. During execution of the decoded plurality of instructions, if a long delay instruction causing a long delay operation is executed, during execution of the long delay instruction, execution may be performed after the long delay instruction and independent of the long delay instruction The instructions are based on the target register numbers of the plurality of instructions, and the execution results of the plurality of instructions are submitted to the corresponding target registers according to the instruction sequence, thereby implementing processing of the plurality of instructions.
在该长延迟操作的指令执行过程中,当位于该长延迟指令之后且与该长延迟指令无关的所有指令执行完之后,如果该长延迟指令还未执行完,此时,该处理器仍需要等待该长延迟指令执行完成之后,才能处理其他的操作,降低了处理器的处理性能。During the execution of the instruction of the long delay operation, after all the instructions after the long delay instruction and not related to the long delay instruction are executed, if the long delay instruction has not been executed, the processor still needs to be executed. Waiting for the execution of the long delay instruction is completed before other operations can be processed, reducing the processing performance of the processor.
发明内容Summary of the invention
为了提高处理器的处理性能,本发明实施例提供了一种指令处理方法及设备。所述技术方案如下:
In order to improve the processing performance of the processor, an embodiment of the present invention provides an instruction processing method and device. The technical solution is as follows:
第一方面,提供了一种指令处理方法,所述方法包括:In a first aspect, an instruction processing method is provided, the method comprising:
确定至少一个可执行指令中的关键指令,所述关键指令是指长延迟指令或位于关键指令链上的指令,所述关键指令链包含N阶指令,其中,所述N阶指令中的第i阶指令为第i+1阶指令的生产者指令,所述生产者指令是指所述第i阶指令的目标寄存器是第i+1阶指令的源寄存器,所述关键指令链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数;Determining a key instruction in at least one executable instruction, the key instruction being a long delay instruction or an instruction located on a critical instruction chain, the key instruction chain comprising an Nth order instruction, wherein the ith of the Nth order instructions The order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i th order instruction is a source register of the i+1th order instruction, and the Nth of the key instruction chain The order instruction is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;
优先执行所述至少一个可执行指令中的所述关键指令。The key instructions of the at least one executable instruction are preferentially executed.
结合第一方面,在上述第一方面的第一种可能的实现方式中,所述确定至少一个可执行指令中的关键指令之前,还包括:In conjunction with the first aspect, in the first possible implementation manner of the foregoing first aspect, before the determining the key instruction in the at least one executable instruction, the method further includes:
从指令缓存中取出多个待执行指令;Extracting a plurality of to-be-executed instructions from the instruction cache;
从所述多个待执行指令中,确定至少一个可执行指令。From the plurality of to-be-executed instructions, at least one executable instruction is determined.
结合第一方面,在上述第一方面的第二种可能的实现方式中,所述确定至少一个可执行指令中的关键指令,包括:With reference to the first aspect, in the second possible implementation manner of the foregoing first aspect, the determining the key instruction in the at least one executable instruction includes:
对于所述至少一个可执行指令中的任一可执行指令,判断所述任一可执行指令的关键指令标识是否有效或所述任一可执行指令是否为长延迟指令;Determining, for any executable instruction of the at least one executable instruction, whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction;
当所述任一可执行指令的关键指令标识有效或者所述任一可执行指令为长延迟指令时,确定所述任一可执行指令为关键指令。When the critical instruction identification of any of the executable instructions is valid or the any executable instruction is a long delay instruction, it is determined that the any executable instruction is a key instruction.
结合第一方面至第一方面的第二种可能的实现方式中的任一可能的实现方式,在上述第一方面的第三种可能的实现方式中,所述方法还包括:With reference to the first aspect to the second possible implementation of the first aspect, in a third possible implementation manner of the foregoing first aspect, the method further includes:
在所述关键指令存在生产者指令,且所述关键指令的生产者指令没有被标记为关键指令时,将所述关键指令的生产者指令的关键指令标识设置为有效。When there is a producer instruction in the key instruction, and the producer instruction of the key instruction is not marked as a key instruction, the key instruction identifier of the producer instruction of the key instruction is set to be valid.
结合第一方面至第一方面的第三种可能的实现方式中的任一可能的实现方式,在上述第一方面的第四种可能的实现方式中,所述方法还包括:In a fourth possible implementation manner of the foregoing first aspect, the method further includes:
在所述关键指令的关键指令标识无效且所述关键指令为长延迟指令时,将所述长延迟指令的关键指令标识设置为有效。When the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction, the key instruction identifier of the long delay instruction is set to be valid.
结合第一方面的第三种可能的实现方式或者第一方面的第四种可能的实
现方式,在上述第一方面的第五种可能的实现方式中,所述方法还包括:Combining the third possible implementation of the first aspect or the fourth possible implementation of the first aspect
In a fifth possible implementation manner of the foregoing first aspect, the method further includes:
在每将一个指令的关键指令标识设置为有效时,将所述关键指令的标识写入所述指令缓存中。The identity of the critical instruction is written into the instruction cache each time a critical instruction identification of an instruction is set to be valid.
结合第一方面的第二种可能的实现方式,在上述第一方面的第六种可能的实现方式,所述判断所述任一可执行指令是否为长延迟指令,包括:With reference to the second possible implementation of the first aspect, in the sixth possible implementation manner of the foregoing first aspect, the determining whether the any executable instruction is a long delay instruction comprises:
对所述任一可执行指令进行译码,得到所述任一可执行指令的指令类型;Decoding any of the executable instructions to obtain an instruction type of any of the executable instructions;
判断存储的关键类型库中是否包含所述任一可执行指令的指令类型;Determining whether the stored key type library contains the instruction type of any of the executable instructions;
如果所述关键类型库中包含所述任一可执行指令的指令类型,则确定所述任一可执行指令为长延迟指令。If the key type library contains an instruction type of any of the executable instructions, it is determined that the any executable instruction is a long delay instruction.
结合第一方面的第二种可能的实现方式,在上述第一方面的第七种可能的实现方式中,所述判断所述任一可执行指令是否为长延迟指令,包括:In conjunction with the second possible implementation of the first aspect, in the seventh possible implementation manner of the foregoing first aspect, the determining whether the any executable instruction is a long delay instruction comprises:
判断存储的关键地址库中是否包含所述任一可执行指令的指令地址;Determining whether the stored key address library contains the instruction address of any of the executable instructions;
如果所述关键地址库中包含所述任一可执行指令的指令地址,则确定所述任一可执行指令为长延迟指令。If the key address library contains an instruction address of any of the executable instructions, it is determined that the any executable instruction is a long delay instruction.
结合第一方面至第一方面的第七种可能的实现方式中的任一可能的实现方式,在上述第一方面的第八种可能的实现方式中,所述从指令缓存中取出多个待执行指令之后,还包括:With reference to the first aspect to any one of the possible implementations of the seventh possible implementation of the first aspect, in an eighth possible implementation manner of the foregoing first aspect, After executing the instructions, it also includes:
为所述多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储所述每个待执行指令的执行结果;Allocating a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each of the to-be-executed instructions;
相应地,所述方法还包括:Correspondingly, the method further comprises:
当每得到一个待执行指令的执行结果时,将所述待执行指令的执行结果写入对应的存储空间中;When the execution result of the instruction to be executed is obtained, the execution result of the instruction to be executed is written into the corresponding storage space;
在所述多个待执行指令结束执行之后,按照所述多个指令的指令顺序,依次将所述多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入所述每个待执行指令对应的目标寄存器。
After the execution of the plurality of to-be-executed instructions is ended, in accordance with the instruction sequence of the plurality of instructions, the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions is sequentially written into each of the The target register corresponding to the instruction to be executed.
第二方面,提供了一种计算设备可读介质,包括计算设备执行指令,当计算设备的处理器执行所述计算设备执行指令时,所述计算设备执行上述第一方面至第一方面的第八种可能的实现方式中的任一可能的实现方式所述的方法。In a second aspect, a computing device readable medium is provided, comprising: a computing device executing instructions that, when a processor of a computing device executes the computing device to execute an instruction, the computing device performs the first aspect to the first aspect A method as described in any of the possible implementations of the eight possible implementations.
第三方面,提供了一种指令处理设备,所述设备包括:处理器、存储器、总线和通信接口;In a third aspect, an instruction processing device is provided, the device comprising: a processor, a memory, a bus, and a communication interface;
所述存储器用于存储计算机执行指令,所述处理器与所述存储器通过所述总线连接,当所述数据存储装置运行时,所述处理器执行所述存储器存储的所述计算机执行指令,以使所述指令处理设备执行上述第一方面至第一方面的第八种可能的实现方式中的任一可能的实现方式所述的方法。The memory is configured to store a computer execution instruction, the processor is coupled to the memory via the bus, and when the data storage device is in operation, the processor executes the computer-executed instruction stored in the memory to The instruction processing device is caused to perform the method of any one of the first aspect to the eighth possible implementation of the first aspect.
第四方面,提供了一种指令处理设备,所述设备包括:In a fourth aspect, an instruction processing device is provided, the device comprising:
确定模块,用于确定至少一个可执行指令中的关键指令,所述关键指令是指长延迟指令或位于关键指令链上的指令,所述关键指令链包含N阶指令,其中,所述N阶指令中的第i阶指令为第i+1阶指令的生产者指令,所述生产者指令是指所述第i阶指令的目标寄存器是第i+1阶指令的源寄存器,所述关键指令链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数;Determining a module for determining a key instruction in the at least one executable instruction, the key instruction being a long delay instruction or an instruction located on a key instruction chain, the key instruction chain comprising an Nth order instruction, wherein the Nth order The i-th order instruction in the instruction is a producer instruction of the (i+1)th instruction, and the producer instruction is that the target register of the i-th order instruction is a source register of the (i+1)th instruction, the key instruction The Nth order instruction on the chain is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;
执行模块,用于优先执行所述至少一个可执行指令中的所述关键指令。And an execution module, configured to preferentially execute the key instruction in the at least one executable instruction.
结合第四方面,在上述第四方面的第一种可能的实现方式中,所述设备还包括取指模块,With reference to the fourth aspect, in a first possible implementation manner of the foregoing fourth aspect, the device further includes an instruction fetching module,
所述取指模块,用于从指令缓存中取出多个待执行指令;The fetching module is configured to fetch a plurality of to-be-executed instructions from the instruction cache;
所述确定模块,还用于从所述多个待执行指令中,确定至少一个可执行指令。The determining module is further configured to determine at least one executable instruction from the plurality of to-be-executed instructions.
结合第四方面,在上述第四方面的第二种可能的实现方式中,所述确定模块用于确定至少一个可执行指令中的关键指令,包括:
With reference to the fourth aspect, in a second possible implementation manner of the foregoing fourth aspect, the determining module is configured to determine a key instruction in the at least one executable instruction, including:
判断单元,用于对于所述至少一个可执行指令中的任一可执行指令,所述确定模块用于判断所述任一可执行指令的关键指令标识是否有效或所述任一可执行指令是否为长延迟指令;当所述任一可执行指令的关键指令标识有效或者所述任一可执行指令为长延迟指令时,还用于确定所述任一可执行指令为关键指令。a determining unit, configured to determine, according to any one of the at least one executable instructions, the determining module is configured to determine whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is A long delay instruction; when the key instruction identifier of any of the executable instructions is valid or the any executable instruction is a long delay instruction, it is also used to determine that any of the executable instructions is a key instruction.
结合第四方面至第四方面的第二种可能的实现方式中的任一可能的实现方式,在上述第四方面的第三种可能的实现方式中,所述设备还包括:With reference to any of the possible implementations of the fourth aspect to the second possible implementation of the fourth aspect, in a third possible implementation manner of the foregoing fourth aspect, the device further includes:
第一设置模块,用于在所述关键指令存在生产者指令,且所述关键指令的生产者指令没有被标记为关键指令时,将所述关键指令的生产者指令的关键指令标识设置为有效。a first setting module, configured to set a key instruction identifier of a producer instruction of the key instruction to be valid when a producer instruction is present in the key instruction, and a producer instruction of the key instruction is not marked as a key instruction .
结合第四方面至第四方面的第三种可能的实现方式,在上述第四方面的第四种可能的实现方式中,所述设备还包括:With reference to the third aspect, the third possible implementation manner of the fourth aspect, in the fourth possible implementation manner of the foregoing fourth aspect, the device further includes:
第二设置模块,用于在所述关键指令的关键指令标识无效且所述关键指令为长延迟指令时,将所述长延迟指令的关键指令标识设置为有效。And a second setting module, configured to: when the key instruction identifier of the critical instruction is invalid and the key instruction is a long delay instruction, set a key instruction identifier of the long delay instruction to be valid.
结合第四方面的第三种可能的实现方式或者第四方面的第四种可能的实现方式,在上述第四方面的第五种可能的实现方式中,所述设备还包括:In conjunction with the third possible implementation of the fourth aspect, or the fourth possible implementation of the fourth aspect, in a fifth possible implementation manner of the foregoing fourth aspect, the device further includes:
第一写入模块,用于在每将一个指令的关键指令标识设置为有效时,将所述关键指令的标识写入所述指令缓存中。The first write module is configured to write an identifier of the key instruction into the instruction cache every time a key instruction identifier of an instruction is set to be valid.
结合第四方面的第二种可能的实现方式,在上述第四方面的第六种可能的实现方式中,所述确定模块用于判断所述任一可执行指令是否为长延迟指令,包括:In conjunction with the second possible implementation of the fourth aspect, in the sixth possible implementation manner of the foregoing fourth aspect, the determining, the determining, by the determining, the determining, whether the any executable instruction is a long delay instruction, includes:
所述确定模块,用于对所述任一可执行指令进行译码,得到所述任一可执行指令的指令类型;The determining module is configured to decode any one of the executable instructions to obtain an instruction type of the any executable instruction;
并用于判断存储的关键类型库中是否包含所述任一可执行指令的指令类型;And used to determine whether the stored key type library contains the instruction type of any of the executable instructions;
如果所述关键类型库中包含所述任一可执行指令的指令类型,则还用于确
定所述任一可执行指令为长延迟指令。If the key type library contains the instruction type of any of the executable instructions, it is also used to
Any of the executable instructions is a long delay instruction.
结合第四方面的第二种可能的实现方式,在上述第四方面的第七种可能的实现方式中,所述确定模块用于判断所述任一可执行指令是否为长延迟指令,包括:With reference to the second possible implementation of the fourth aspect, in the seventh possible implementation manner of the foregoing fourth aspect, the determining, the determining, the determining, by the determining,
所述确定模块,用于判断存储的关键地址库中是否包含所述任一可执行指令的指令地址;The determining module is configured to determine whether the stored key address library includes an instruction address of the any executable instruction;
如果所述关键地址库中包含所述任一可执行指令的指令地址,则用于确定所述任一可执行指令为长延迟指令。If the key address library contains an instruction address of any of the executable instructions, it is used to determine that any of the executable instructions is a long delay instruction.
结合第四方面至第四方面的第七种可能的实现方式中的任一可能的实现方式中,在上述第四方面的第八种可能的实现方式中,所述设备还包括:With reference to any of the possible implementations of the fourth aspect to the seventh possible implementation manner of the fourth aspect, in the eighth possible implementation manner of the foregoing fourth aspect, the device further includes:
分配模块,用于为所述多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储所述每个待执行指令的执行结果;An allocation module, configured to respectively allocate a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each of the to-be-executed instructions;
相应地,所述设备还包括:Correspondingly, the device further includes:
第二写入模块,用于当每得到一个待执行指令的执行结果时,将所述待执行指令的执行结果写入对应的存储空间中;并用于在所述多个待执行指令结束执行之后,按照所述多个指令的指令顺序,依次将所述多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入所述每个待执行指令对应的目标寄存器。a second write module, configured to write an execution result of the to-be-executed instruction into a corresponding storage space every time an execution result of an instruction to be executed is obtained; and to be used after the execution of the plurality of to-be-executed instructions ends And executing, in an instruction sequence of the plurality of instructions, an execution result in a storage space corresponding to each of the plurality of to-be-executed instructions in a target register corresponding to each to-be-executed instruction.
本发明实施例提供的技术方案的有益效果是:在本发明实施例中,确定至少一个可执行指令中的关键指令,而在执行该至少一个可执行指令时,可以优先执行该至少一个可执行指令中的关键指令,由于关键指令包括长延迟指令,因此,优先执行该至少一个可执行指令中的关键指令,可以提前长延迟指令的执行时间,并在该长延迟指令执行过程中,可以保证有足够多的无关指令可以执行,进而减小处理器的等待时间,从而提高处理器的处理性能。The technical solution provided by the embodiment of the present invention has the beneficial effects that: in the embodiment of the present invention, the key instruction in the at least one executable instruction is determined, and when the at least one executable instruction is executed, the at least one executable may be preferentially executed. The key instruction in the instruction, because the key instruction includes the long delay instruction, the priority execution of the key instruction in the at least one executable instruction can delay the execution time of the instruction in advance, and during the execution of the long delay instruction, it can be guaranteed There are enough irrelevant instructions to execute, which reduces the processor's latency and improves the processor's processing performance.
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other drawings may also be obtained from those of ordinary skill in the art in light of the inventive work.
图1是本发明实施例提供的一种指令处理方法的流程图。FIG. 1 is a flowchart of an instruction processing method according to an embodiment of the present invention.
图2是本发明实施例提供的另一种指令处理方法的流程图。FIG. 2 is a flowchart of another instruction processing method according to an embodiment of the present invention.
图3是本发明实施例提供的一种指令处理过程示意图。FIG. 3 is a schematic diagram of an instruction processing process according to an embodiment of the present invention.
图4是本发明实施例提供的一种指令处理设备的结构示意图。FIG. 4 is a schematic structural diagram of an instruction processing apparatus according to an embodiment of the present invention.
图5是本发明实施例提供的另一种指令处理设备的结构示意图。FIG. 5 is a schematic structural diagram of another instruction processing apparatus according to an embodiment of the present invention.
图6是本发明实施例提供的又一种指令处理设备的结构示意图。FIG. 6 is a schematic structural diagram of still another instruction processing apparatus according to an embodiment of the present invention.
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
在对本发明实施例进行详细地解释说明之前,先对本发明实施例的应用场景予以介绍。设备在运行应用程序的过程中,该设备的处理器需要对该应用程序包括的多个指令进行处理。而在处理指令的过程中,有些指令会引起长延迟操作,比如,除法指令、超越函数指令等,当处理器遇到这些长延迟操作时,可能需要等待该长延迟操作完成,才能执行其他的操作,降低了处理器的性能。因此,本发明实施例提供了一种指令处理方法,来提高处理器的性能。Before the embodiments of the present invention are explained in detail, the application scenarios of the embodiments of the present invention are first introduced. While the device is running the application, the processor of the device needs to process the multiple instructions included in the application. In the process of processing instructions, some instructions will cause long delay operations, such as division instructions, transcendental instructions, etc. When the processor encounters these long delay operations, it may need to wait for the long delay operation to complete before executing other Operation reduces the performance of the processor. Therefore, an embodiment of the present invention provides an instruction processing method to improve performance of a processor.
图1是本发明实施例提供的一种指令处理方法的流程图。参见图1,该方法包括:FIG. 1 is a flowchart of an instruction processing method according to an embodiment of the present invention. Referring to Figure 1, the method includes:
步骤101:确定至少一个可执行指令中的关键指令,所述关键指令是指长延迟指令或位于关键指令链上的指令,所述关键指令链包含N阶指令,其中,所述N阶指令中的第i阶指令为第i+1阶指令的生产者指令,所述生产者指令是指所述第i阶指令的目标寄存器是第i+1阶指令的源寄存器,所述关键指令
链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数。Step 101: Determine a key instruction in at least one executable instruction, where the key instruction refers to a long delay instruction or an instruction located on a key instruction chain, where the key instruction chain includes an N-th order instruction, wherein the N-th order instruction The i-th order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i-th order instruction is a source register of the i+1th order instruction, the key instruction
The Nth order instruction on the chain is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N.
步骤102:优先执行所述至少一个可执行指令中的所述关键指令。Step 102: Preferential execution of the key instruction in the at least one executable instruction.
在本发明实施例中,确定至少一个可执行指令中的关键指令,而在执行该至少一个可执行指令时,可以优先执行该至少一个可执行指令中的关键指令,由于关键指令包括长延迟指令,因此,优先执行该至少一个可执行指令中的关键指令,可以提前长延迟指令的执行时间,并在该长延迟指令执行过程中,可以保证有足够多的无关指令可以执行,进而减小处理器的等待时间,从而提高处理器的处理性能。In the embodiment of the present invention, a key instruction in the at least one executable instruction is determined, and when the at least one executable instruction is executed, the key instruction in the at least one executable instruction may be preferentially executed, because the key instruction includes a long delay instruction Therefore, preferential execution of the key instruction in the at least one executable instruction may delay the execution time of the instruction in advance, and during the execution of the long delay instruction, ensure that there are enough irrelevant instructions to be executed, thereby reducing processing. The wait time of the device, thereby improving the processing performance of the processor.
如果指令1的目标寄存器是指令2的源寄存器,即指令2要使用指令1的计算结果进行运算,则指令1是指令2的生产者指令,指令2为指令1的消费者指令,表示指令1与指令2有逻辑上的先后执行关系,指令1要先于指令2执行。If the target register of instruction 1 is the source register of instruction 2, that is, instruction 2 is to be operated using the calculation result of instruction 1, then instruction 1 is the producer instruction of instruction 2, and instruction 2 is the consumer instruction of instruction 1, indicating instruction 1 There is a logical sequential execution relationship with instruction 2, and instruction 1 is executed prior to instruction 2.
可选地,确定至少一个可执行指令中的关键指令之前,还包括:Optionally, before determining the key instructions in the at least one executable instruction, the method further includes:
从指令缓存中取出多个待执行指令;Extracting a plurality of to-be-executed instructions from the instruction cache;
从该多个待执行指令中,确定至少一个可执行指令。From the plurality of to-be-executed instructions, at least one executable instruction is determined.
可选地,确定至少一个可执行指令中的关键指令,包括:Optionally, determining key instructions in the at least one executable instruction, including:
对于该至少一个可执行指令中的任一可执行指令,判断该任一可执行指令的关键指令标识是否有效或该任一可执行指令是否为长延迟指令;Determining, for any executable instruction of the at least one executable instruction, whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction;
当该任一可执行指令的关键指令标识有效或者该任一可执行指令为长延迟指令时,确定该任一可执行指令为关键指令。When the key instruction identifier of any of the executable instructions is valid or the executable instruction is a long delay instruction, it is determined that the executable instruction is a key instruction.
可选地,该方法还包括:Optionally, the method further includes:
在该关键指令存在生产者指令,且该关键指令的生产者指令没有被标记为关键指令时,将该关键指令的生产者指令的关键指令标识设置为有效。When there is a producer instruction in the key instruction, and the producer instruction of the key instruction is not marked as a key instruction, the key instruction identifier of the producer instruction of the key instruction is set to be valid.
可选地,该方法还包括:Optionally, the method further includes:
在该关键指令的关键指令标识无效且该关键指令为长延迟指令时,将该长
延迟指令的关键指令标识设置为有效。When the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction, the length is
The critical instruction ID of the delayed instruction is set to be valid.
可选地,该方法还包括:Optionally, the method further includes:
在每将一个指令的关键指令标识设置为有效时,将该关键指令的标识写入指令缓存中。The identity of the key instruction is written to the instruction cache each time a critical instruction flag of an instruction is set to be valid.
可选地,判断该任一可执行指令是否为长延迟指令,包括:Optionally, determining whether the any executable instruction is a long delay instruction comprises:
对该任一可执行指令进行译码,得到该任一可执行指令的指令类型;Decoding any executable instruction to obtain an instruction type of any executable instruction;
判断存储的关键类型库中是否包含该任一可执行指令的指令类型;Determining whether the stored key type library contains the instruction type of any executable instruction;
如果该关键类型库中包含该任一可执行指令的指令类型,则确定该任一可执行指令为长延迟指令。If the key type library contains an instruction type of any of the executable instructions, it is determined that the executable instruction is a long delay instruction.
可选地,判断该任一可执行指令是否为长延迟指令,包括:Optionally, determining whether the any executable instruction is a long delay instruction comprises:
判断存储的关键地址库中是否包含该任一可执行指令的指令地址;Determining whether the stored key address library contains an instruction address of any executable instruction;
如果该关键地址库中包含该任一可执行指令的指令地址,则确定该任一可执行指令为长延迟指令。If the key address library contains the instruction address of any of the executable instructions, then it is determined that the executable instruction is a long delay instruction.
可选地,从指令缓存中取出多个待执行指令之后,还包括:Optionally, after the multiple execution instructions are taken from the instruction cache, the method further includes:
为该多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储每个待执行指令的执行结果;Allocating a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each to-be-executed instruction;
相应地,该方法还包括:Correspondingly, the method further comprises:
当每得到一个待执行指令的执行结果时,将该待执行指令的执行结果写入对应的存储空间中;When the execution result of an instruction to be executed is obtained, the execution result of the instruction to be executed is written into the corresponding storage space;
在该多个待执行指令结束执行之后,按照该多个指令的指令顺序,依次将该多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入每个待执行指令对应的目标寄存器。After the execution of the plurality of to-be-executed instructions is ended, in accordance with the instruction sequence of the plurality of instructions, the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions is sequentially written to each to-be-executed instruction. Target register.
上述所有可选技术方案,均可按照任意结合形成本发明的可选实施例,本发明实施例对此不再一一赘述。The optional embodiments of the present invention may be used in any combination to form an optional embodiment of the present invention.
图2是本发明实施例提供的一种指令处理方法的流程图。参见图2,该方
法包括:FIG. 2 is a flowchart of a method for processing an instruction according to an embodiment of the present invention. See Figure 2, the party
The law includes:
步骤201:按照指令顺序,从指令缓存中取出多个待执行指令。Step 201: Extract a plurality of to-be-executed instructions from the instruction cache according to the instruction sequence.
在本发明实施例中,当处理器对指令进行处理时,可以按照指令顺序,从指令缓存中取出多个待执行指令。其中,指令顺序为应用程序先后运行该多个指令的顺序。In the embodiment of the present invention, when the processor processes the instruction, a plurality of to-be-executed instructions may be fetched from the instruction cache according to the instruction sequence. The order of the instructions is the order in which the application runs the multiple instructions one after another.
比如,如下表1所示,该指令缓存中包括7个指令,分别为ADD指令、SUB指令、AND指令、XOR指令、LSL指令、LSR指令和LOAD指令,且该应用程序先后运行该7个指令的指令顺序为ADD指令、SUB指令、AND指令、XOR指令、LSL指令、LSR指令和LOAD指令。因此,该处理器按照该指令顺序,从该指令缓存中取出多个待执行指令分别为ADD指令、SUB指令、AND指令、XOR指令、LSL指令、LSR指令和LOAD指令。For example, as shown in Table 1 below, the instruction cache includes seven instructions, namely an ADD instruction, a SUB instruction, an AND instruction, an XOR instruction, an LSL instruction, an LSR instruction, and a LOAD instruction, and the application sequentially runs the seven instructions. The instruction sequence is ADD instruction, SUB instruction, AND instruction, XOR instruction, LSL instruction, LSR instruction and LOAD instruction. Therefore, the processor fetches a plurality of to-be-executed instructions from the instruction cache into an ADD instruction, a SUB instruction, an AND instruction, an XOR instruction, an LSL instruction, an LSR instruction, and a LOAD instruction according to the instruction sequence.
表1Table 1
其中,在本发明实施例中,对于该多个待执行指令中的每个待执行指令,该处理器可以按照指令顺序,从该指令缓存中逐一取出该多个待执行指令,本发明实施例对此不做具体限定。In the embodiment of the present invention, for each of the plurality of to-be-executed instructions, the processor may fetch the plurality of to-be-executed instructions one by one from the instruction cache according to the instruction sequence, where the embodiment of the present invention This is not specifically limited.
可选地,在本发明实施例中,处理器也可以不用按照指令顺序,从该指令缓存中取出该多个待执行指令,也即是,处理器可以乱序地从该指令缓存中取出该多个待执行指令,本发明实施例对此不做具体限定。
Optionally, in the embodiment of the present invention, the processor may also remove the multiple to-be-executed instructions from the instruction cache without following the instruction sequence, that is, the processor may fetch the instruction from the instruction cache out of order. The embodiment of the present invention does not specifically limit this.
步骤202:从该多个待执行指令中,确定至少一个可执行指令。Step 202: Determine at least one executable instruction from the plurality of to-be-executed instructions.
对于该多个待执行指令中的任一待执行指令,该处理器可以判断该任一待执行指令的操作数是否就绪,如果该任一待执行指令的操作数就绪,则确定该任一待执行指令为可执行指令,可以立即执行该任一待执行指令,无需等待该任一待执行指令之前的指令执行完成。如果该任一待执行指令的操作数未就绪,则确定该任一待执行指令为不可执行指令,此时,需要等到该任一待执行指令的操作数就绪时,才能执行该任一待执行指令。其中,该任一待执行指令的操作数为该任一待执行指令的源寄存器中存储的数据。For any one of the plurality of to-be-executed instructions, the processor may determine whether the operand of the any instruction to be executed is ready, and if the operand of the to-be-executed instruction is ready, determine the standby The execution instruction is an executable instruction, and any of the execution instructions can be executed immediately without waiting for the execution of the instruction before the execution of any of the execution instructions. If the operand of any of the to-be-executed instructions is not ready, it is determined that the any instruction to be executed is an unexecutable instruction. At this time, it is necessary to wait until the operand of any of the to-be-executed instructions is ready to execute any of the to-be-executed instruction. The operand of any of the to-be-executed instructions is data stored in a source register of the any instruction to be executed.
或者,对于该多个待执行指令中的任一待执行指令,该处理器可以判断该任一待执行指令的源寄存器是否有效,如果该任一待执行指令的源寄存器有效,则确定该任一待执行指令为可执行指令,可以立即执行该任一待执行指令,无需等待该任一待执行指令之前的指令执行完成。如果该任一待执行指令的源寄存器无效,则确定该任一待执行指令为不可执行指令,此时,需要等到该任一待执行指令的源寄存器有效时,才能执行该任一待执行指令。Alternatively, for any of the plurality of to-be-executed instructions, the processor may determine whether the source register of the any to-be-executed instruction is valid, and if the source register of the any to-be-executed instruction is valid, determine the Once the execution instruction is an executable instruction, the any execution instruction can be executed immediately without waiting for the execution of the instruction before the execution of the any execution instruction. If the source register of any of the to-be-executed instructions is invalid, it is determined that any of the to-be-executed instructions is an unexecutable instruction, and at this time, it is necessary to wait until the source register of any of the to-be-executed instructions is valid, .
其中,为了将长延迟指令的执行时间提前,也即是,优先执行长延迟指令,提高处理器的处理性能,可以为该多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储每个待执行指令的执行结果。相应地,当每得到一个待执行指令的执行结果时,可以将该待执行指令的执行结果写入对应的存储空间中。进而将该待执行指令对应的存储空间设置为有效,也即是,将该待执行指令的目标寄存器设置为有效。In order to advance the execution time of the long delay instruction, that is, to preferentially execute the long delay instruction and improve the processing performance of the processor, a storage space may be allocated for each of the plurality of to-be-executed instructions. Each storage space is used to store the execution result of each instruction to be executed. Correspondingly, each time an execution result of an instruction to be executed is obtained, the execution result of the instruction to be executed can be written into a corresponding storage space. Further, the storage space corresponding to the instruction to be executed is set to be valid, that is, the target register of the instruction to be executed is set to be valid.
其中,为该多个待执行指令中的每个待执行指令分别分配一个存储空间时,该处理器可以为该多个待执行指令中的每个待执行指令分别分配一个存储编号,该存储编号为存储空间对应的编号。而由于该多个存储空间包括一个指针,该指针的初始位置指向第一个存储空间,因此,对该多个待执行指令分别分配一个存储编号时,可以将该指针指向的存储编号分配给该多个待执行指令,且每分配一个存储编号,该指针下移一位,从而得到该多个待执行指令的
存储编号。也即是,在本发明实施例中,可以按照指令顺序,对该多个待执行指令分别分配一个存储编号。The processor may allocate a storage number to each of the plurality of to-be-executed instructions, respectively, when a storage space is allocated for each of the plurality of to-be-executed instructions, the storage number The number corresponding to the storage space. Since the plurality of storage spaces include a pointer, the initial position of the pointer points to the first storage space. Therefore, when a storage number is respectively assigned to the plurality of to-be-executed instructions, the storage number pointed to by the pointer may be assigned to the storage space. a plurality of instructions to be executed, and each time a memory number is assigned, the pointer is shifted down by one bit, thereby obtaining the plurality of to-be-executed instructions
Storage number. That is, in the embodiment of the present invention, a plurality of memory numbers may be allocated to the plurality of instructions to be executed in the order of instructions.
比如,该指针的初始位置指向第一个存储空间,因此,将第一个存储空间的编号1分配给ADD指令,此时,该指针下移一位,也即是,该指针指向第二个存储空间,因此,将第二个存储空间的编号2分配给SUB指令,同理,将第三个存储空间的编号3分配给AND指令,将第四个存储空间的编号4分配给XOR指令,将第五个存储空间的编号5分配给LSL指令,将第六个存储空间的编号6分配给LSR指令,以及将第七个存储空间的编号7分配给LOAD指令。For example, the initial position of the pointer points to the first storage space. Therefore, the number 1 of the first storage space is assigned to the ADD instruction. At this time, the pointer moves down one bit, that is, the pointer points to the second Storage space, therefore, assign the number 2 of the second storage space to the SUB instruction. Similarly, assign the number 3 of the third storage space to the AND instruction, and assign the number 4 of the fourth storage space to the XOR instruction. The fifth storage space number 5 is assigned to the LSL instruction, the sixth storage space number 6 is assigned to the LSR instruction, and the seventh storage space number 7 is assigned to the LOAD instruction.
需要说明的是,存储编号可以为ROB(Re-Order Buffer,重排序缓冲区)编号,存储空间可以为ROB中的每个表项,本发明实施例对此不做具体限定。It should be noted that the storage number may be a Re-Order Buffer (ROB) number, and the storage space may be each entry in the ROB, which is not specifically limited in this embodiment of the present invention.
步骤203:确定该至少一个可执行指令中的关键指令,该关键指令是指长延迟指令或位于关键指令链上的指令,关键指令链包含N阶指令,其中,N阶指令中的第i阶指令为第i+1阶指令的生产者指令,该生产者指令是指第i阶指令的目标寄存器是第i+1阶指令的源寄存器,该关键指令链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数。Step 203: Determine a key instruction in the at least one executable instruction, where the key instruction refers to a long delay instruction or an instruction located in a key instruction chain, where the key instruction chain includes an Nth order instruction, wherein the ith order in the Nth order instruction The instruction is a producer instruction of the i+1th order instruction, and the producer instruction is that the target register of the i th order instruction is a source register of the i+1th order instruction, and the Nth order instruction on the key instruction chain is a long delay The instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N.
应了解,关键指令链上的某一阶关键指令可以有一条和大于1的正整数条,例如某一条加法指令是关键指令,且该加法指令有N个源寄存器,则该加法指令可以有N个生产者指令,所以该加法指令的上一阶关键指令有N个。It should be understood that a certain order key instruction on a key instruction chain may have a positive integer number greater than one. For example, if an addition instruction is a key instruction, and the addition instruction has N source registers, the addition instruction may have N A producer instruction, so there are N upper-order key instructions of the addition instruction.
具体地,对于该至少一个可执行指令中的任一可执行指令,判断该任一可执行指令的关键指令标识是否有效或该任一可执行指令是否为长延迟指令;当该任一可执行指令的关键指令标识有效或者该任一可执行指令为长延迟指令时,确定该任一可执行指令为关键指令,如此确定该至少一个可执行指令中的关键指令。Specifically, for any executable instruction of the at least one executable instruction, determining whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction; When the key instruction identifier of the instruction is valid or the executable instruction is a long delay instruction, determining that the executable instruction is a key instruction, thus determining a key instruction in the at least one executable instruction.
在本发明实施例中,当每执行一个待执行指令时,如果该待执行指令存在生产者指令,则将该待执行指令和该待执行指令的生产者指令构成一条指令
链,并且当该待执行指令为关键指令,且该关键指令的生产者指令没有被标记为关键指令时,则将该关键指令的生产者指令的关键指令标识设置为有效,也即是,执行一个关键指令之后,可以将该关键指令的生产者指令标记为关键指令。而如果该关键指令的关键指令标识无效且该关键指令为长延迟指令,则将该长延迟指令的关键指令标识设置为有效,也即是,将该长延迟指令标记为关键指令。之后,再执行下一个待执行指令时,如果下一个待执行指令的生产者指令为该指令链中的最后一阶指令,则将下一个待执行指令添加到该指令链的最后,直至遍历该多个待执行指令为止。另外,当该指令链上包括长延迟指令时,将该指令链称为关键指令链。In the embodiment of the present invention, when each instruction to be executed is executed, if the instruction to be executed has a producer instruction, the instruction to be executed and the producer instruction of the instruction to be executed constitute an instruction.
a chain, and when the instruction to be executed is a key instruction, and the producer instruction of the key instruction is not marked as a key instruction, setting the key instruction identifier of the producer instruction of the key instruction to be valid, that is, executing After a key instruction, the producer instruction of the key instruction can be marked as a key instruction. If the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction, the key instruction identifier of the long delay instruction is set to be valid, that is, the long delay instruction is marked as a key instruction. Then, when the next instruction to be executed is executed, if the producer instruction of the next instruction to be executed is the last instruction in the chain, the next instruction to be executed is added to the end of the chain until the traversal A number of pending instructions. In addition, when a long delay instruction is included in the instruction chain, the instruction chain is referred to as a key instruction chain.
需要说明的是,位于同一条指令链上的待执行指令存在生产者指令与消费者指令的关系,也即是,当该指令链上的第i阶待执行指令的目标寄存器为第i+1阶待执行指令的源寄存器时,可以将第i阶待执行指令称为第i+1阶待执行指令的生产者指令,并将第i+1阶待执行指令称为第i阶待执行指令的消费者指令。It should be noted that the to-be-executed instruction located on the same instruction chain has a relationship between the producer instruction and the consumer instruction, that is, when the target register of the i-th to-be-executed instruction on the instruction chain is the (i+1)th. When the source register of the instruction is to be executed, the i-th order to-be-executed instruction may be referred to as the producer instruction of the i+1th-order to-be-executed instruction, and the i-th order-to-be-executed instruction is referred to as the i-th order to-be-executed instruction. Consumer instruction.
进一步地,关键指令标识用于标识该待执行指令为关键指令还是非关键指令,也即是,当一个待执行指令的关键指令标识有效时,可以确定该待执行指令为关键指令,而当一个待执行指令的关键指令标识无效时,可以确定该待执行指令为非关键指令。而将关键指令标识设置为有效的操作可以为:将关键指令标识设置为第一数值。而关键指令标识无效时,可以将该关键指令标识设置为第二数值。其中,第一数值和第二数值可以是事先设置的,比如,第一数值可以为1,第二数值可以0,本发明实施例对此不做具体限定。Further, the key instruction identifier is used to identify whether the instruction to be executed is a key instruction or a non-key instruction, that is, when the key instruction identifier of an instruction to be executed is valid, it may be determined that the instruction to be executed is a key instruction, and when When the key instruction identifier of the instruction to be executed is invalid, it may be determined that the instruction to be executed is a non-critical instruction. The key operation identifier can be set to a valid operation by setting the key instruction identifier to the first value. When the key instruction identifier is invalid, the key instruction identifier can be set to the second value. The first value and the second value may be set in advance. For example, the first value may be 1 and the second value may be 0, which is not specifically limited in the embodiment of the present invention.
另外,每将一个待执行指令的关键指令标识设置为有效时,可以将该关键指令标识存储在指令缓存中。如此,当下次从该指令缓存中取出待执行指令时,可以直接获知关键指令,提高了指令处理的效率。In addition, each critical instruction identification can be stored in the instruction cache whenever a critical instruction identification of an instruction to be executed is set to be valid. In this way, when the instruction to be executed is taken out from the instruction cache next time, the key instruction can be directly learned, and the efficiency of the instruction processing is improved.
在本发明实施例中,可以通过两种方式,判断该任一可执行指令是否为长延迟指令,包括:
In the embodiment of the present invention, whether the executable instruction is a long delay instruction may be determined in two ways, including:
第一种方式,对该任一可执行指令进行译码,得到该任一可执行指令的指令类型;判断存储的关键类型库中是否包含该任一可执行指令的指令类型;如果该关键类型库中包含该任一可执行指令的指令类型,则确定该任一可执行指令为长延迟指令。如果该关键类型库中不包含该任一可执行指令的指令类型,则确定该任一可执行指令为长延迟指令。The first way is to decode the executable instruction to obtain the instruction type of the executable instruction; determine whether the stored key type library contains the instruction type of the executable instruction; if the key type The library contains the type of instruction for any of the executable instructions, and then determines that any of the executable instructions is a long delayed instruction. If the type of the instruction of the executable instruction is not included in the key type library, it is determined that the executable instruction is a long delay instruction.
比如,该任一可执行指令为LOAD指令,对该任一可执行指令进行译码,得到该任一可执行指令的指令类型为访存指令,此时,可以将该任一可执行指令的指令类型与如下表2所示的关键类型库中包含的指令类型进行比较,确定该关键类型库中包含该任一可执行指令的指令类型,此时,确定该任一可执行指令为长延迟指令。For example, the executable instruction is a LOAD instruction, and the executable instruction is decoded, and the instruction type of the executable instruction is the memory access instruction. In this case, the executable instruction may be The instruction type is compared with the instruction type included in the key type library shown in Table 2 below, and the instruction type of the executable instruction is determined in the key type library. At this time, it is determined that the executable instruction is a long delay. instruction.
表2Table 2
指令类型Instruction type |
除法指令Division instruction |
访存指令Fetch instruction |
超越函数指令Transcendental function instruction |
加解密指令Encryption instruction |
……...... |
可选地,在发明实施例中,不仅可以设置关键类型库包括指令类型,并基于上述方法来判断该任一可执行指令是否为长延迟指令。当然,实际应用中,还可以通过其他的方式来判断该任一可执行指令是否为长延迟指令。比如,该处理器对该任一可执行指令进行译码,得到该任一可执行指令的指令类型。之后,基于该任一可执行指令的指令类型,从存储的关键类型库中获取对应的标识数值,如果获取的标识数值为第一数值,则确定该任一可执行指令为长延迟指令,如果获取的标识数值为第二数值,则确定该任一可执行指令不是长延迟
指令。其中,该关键类型库可以包括指令类型与标识数值之间的对应关系,当然,实际应用中,还可以事先约定该关键类型库中的每个标识数值所对应的指令类型,此时,该关键类型库中可以只包括标识数值,本发明实施例对此不做具体限定。Optionally, in the embodiment of the invention, not only the key type library may be set to include an instruction type, but also whether the any executable instruction is a long delay instruction based on the foregoing method. Of course, in practical applications, it is also possible to determine whether any of the executable instructions is a long delay instruction by other means. For example, the processor decodes any of the executable instructions to obtain the type of instruction for any of the executable instructions. Then, based on the instruction type of the executable instruction, the corresponding identification value is obtained from the stored key type library, and if the acquired identification value is the first value, determining that the executable instruction is a long delay instruction, if Obtaining the identifier value as the second value, determining that the executable instruction is not a long delay
instruction. The key type library may include a correspondence between the instruction type and the identifier value. Of course, in an actual application, the instruction type corresponding to each identifier value in the key type library may be agreed in advance. At this time, the key The value of the identifier may be included in the type library, which is not specifically limited in the embodiment of the present invention.
需要说明的是,处理器对该任一可执行指令进行译码的过程可以参考相关技术,本发明实施例对此不做详细阐述。It should be noted that the process of decoding the executable instruction by the processor may be referred to the related art, which is not described in detail in the embodiment of the present invention.
为了便于描述,在本发明实施例中,以关键类型库包括指令类型与标识数值之间的对应关系为例进行说明。比如,第一数值为1,该任一可执行指令为LOAD指令,对该任一可执行指令进行译码,得到该任一可执行指令的指令类型为访存指令。基于该任一可执行指令的指令类型,从如下表3所示的存储的指令类型与标识数值之间的对应关系中,获取对应的标识数值为1,此时,确定该任一可执行指令为长延迟指令。For convenience of description, in the embodiment of the present invention, the correspondence between the key type library including the instruction type and the identification value is taken as an example for description. For example, if the first value is 1, the executable instruction is a LOAD instruction, and the executable instruction is decoded, and the instruction type of the executable instruction is the memory access instruction. Based on the instruction type of the executable instruction, the corresponding identification value is 1 from the correspondence between the stored instruction type and the identification value shown in Table 3 below. At this time, the executable instruction is determined. For long delay instructions.
表3table 3
指令类型Instruction type |
标识数值Identification |
加法指令Addition instruction | 00 |
减法指令 |
00 |
逻辑与指令Logic and |
00 |
异或指令 |
00 |
移位指令 |
00 |
左移指令 |
00 |
访存指令Fetch |
11 |
除法指令 |
11 |
加解密指令 |
00 |
超越函数指令 |
11 |
……...... | ……...... |
第二种方式,判断存储的关键地址库中是否包括该任一可执行指令的指令地址;如果关键地址库中包括该任一可执行指令的指令地址,则确定该任一可执行指令为长延迟指令。如果该关键地址库中不包括该任一可执行指令的指令地址,则确定该任一可执行指令不为长延迟指令。The second method determines whether the stored address address of the executable instruction is included in the stored key address library; if the command address of the executable instruction is included in the critical address library, determining that the executable instruction is long Delayed instruction. If the instruction address of any of the executable instructions is not included in the critical address library, it is determined that the executable instruction is not a long delay instruction.
比如,该任一可执行指令为LOAD指令,且该LOAD指令的指令地址为0x1f00_0340。此时,该处理器将该LOAD指令的指令地址与如下表4所示的关键地址库进行比较,确定该关键地址库中包含LOAD指令的指令地址,因此,确定该任一可执行指令为长延迟指令。For example, any of the executable instructions is a LOAD instruction, and the instruction address of the LOAD instruction is 0x1f00_0340. At this time, the processor compares the instruction address of the LOAD instruction with the key address library shown in Table 4 below, and determines that the instruction address of the LOAD instruction is included in the key address library, and therefore, determining that any executable instruction is long Delayed instruction.
表4Table 4
指令地址Instruction address |
0x1f00_00000x1f00_0000 |
0x1f00_02000x1f00_0200 |
0x1f00_02800x1f00_0280 |
0x1f00_03400x1f00_0340 |
……...... |
需要说明的是,指令的指令地址为该指令的存储地址,本发明实施例对此不做具体限定。另外,关键类型库和关键地址库是事先进行配置的,且关键类型库和关键地址库还可以动态地进行修改,本发明实施例对此不做具体限定。It should be noted that the instruction address of the instruction is the storage address of the instruction, which is not specifically limited in this embodiment of the present invention. In addition, the key type library and the key address library are configured in advance, and the key type library and the key address library can be dynamically modified, which is not specifically limited in the embodiment of the present invention.
步骤204:优先执行该至少一个可执行指令中的关键指令。Step 204: Priority execution of key instructions in the at least one executable instruction.
其中,该处理器优先执行该至少一个可执行指令中的关键指令时,如果执行到长延迟指令时,可以在该长延迟指令执行过程中,执行无关指令,从而执行该多个指令,以得到该多个指令的执行结果。其中,该无关指令为该多个指令中除该长延迟指令所在关键指令链包括的指令之外的指令。Wherein, when the processor preferentially executes the key instruction in the at least one executable instruction, if the long delay instruction is executed, the unrelated instruction may be executed during the execution of the long delay instruction, thereby executing the multiple instruction to obtain The execution result of the multiple instructions. The irrelevant instruction is an instruction other than the instruction included in the key instruction chain of the long delay instruction in the plurality of instructions.
由于关键指令中可以包括长延迟指令,因此,在执行该多个指令时,优先执行该至少一个可执行指令中的关键指令,如此,可以保证有足够多的无关指令在长延迟指令执行过程中进行执行,减少处理器的等待时间,进而提高处理
器的处理性能。Since the key instruction can include a long delay instruction, when executing the multiple instruction, the key instruction in the at least one executable instruction is preferentially executed, so that there are enough irrelevant instructions in the execution of the long delay instruction. Execute, reduce processor wait time, and improve processing
Processing performance.
进一步地,在本发明实施例中,当每得到一个待执行指令的执行结果时,可以将该待执行指令的执行结果写入对应的存储空间中。Further, in the embodiment of the present invention, when the execution result of an instruction to be executed is obtained, the execution result of the instruction to be executed may be written into the corresponding storage space.
比如,当得到AND指令的执行结果为01110110时,可以将该执行结果存储在ROB中的第三个存储空间,当得到LSL指令的执行结果为11101100时,可以将该执行结果存储在ROB中的第五个存储空间,同理,将LOAD指令的执行结果存储在ROB中的第七个存储空间,将ADD指令的执行结果存储在ROB中的第一个存储空间,将SUB指令的执行结果存储在ROB中的第二个存储空间,将XOR指令的执行结果存储在ROB中的第四个存储空间,将LSR指令的执行结果存储在ROB中的第六个存储空间。For example, when the execution result of the AND instruction is 01110110, the execution result may be stored in the third storage space in the ROB. When the execution result of the LSL instruction is 11101100, the execution result may be stored in the ROB. The fifth storage space, in the same way, stores the execution result of the LOAD instruction in the seventh storage space in the ROB, stores the execution result of the ADD instruction in the first storage space in the ROB, and stores the execution result of the SUB instruction. In the second storage space in the ROB, the execution result of the XOR instruction is stored in the fourth storage space in the ROB, and the execution result of the LSR instruction is stored in the sixth storage space in the ROB.
步骤205:基于该多个指令的目标寄存器编号,按照该指令顺序,将该多个指令的执行结果写入对应的目标寄存器。Step 205: Write, according to the target register number of the plurality of instructions, the execution result of the plurality of instructions into the corresponding target register according to the instruction sequence.
由于每个指令的执行结果都存储在处理器包括的存储空间中,因此,在该多个待执行指令结束执行之后,该处理器可以按照该多个待执行指令的指令顺序,依次将该多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入每个待执行指令对应的目标寄存器。而具体地,该处理器可以从该多个待执行指令对应的存储空间中,获取每个待执行指令的执行结果;并基于该多个待执行指令的目标寄存器编号,将获取的执行结果依次写入对应的目标寄存器。Since the execution result of each instruction is stored in the storage space included in the processor, after the execution of the plurality of to-be-executed instructions ends, the processor may sequentially follow the instruction sequence of the plurality of to-be-executed instructions. The execution result in the storage space corresponding to each to-be-executed instruction in the to-be-executed instruction is written to the target register corresponding to each instruction to be executed. Specifically, the processor may obtain an execution result of each to-be-executed instruction from a storage space corresponding to the plurality of to-be-executed instructions; and perform an execution result according to the target register number of the plurality of to-be-executed instructions. Write to the corresponding destination register.
需要说明的是,当处理器按照该指令顺序,将该多个待执行指令的执行结果写入对应的目标寄存器时,如果当前待执行指令还未得到执行结果,即使当前待执行指令之后的待执行指令得到执行结果,那么也不能跨过当前待执行指令而将当前待执行指令之后的待执行指令的执行结果写入对应的目标寄存器,只能等到当前待执行指令得到执行结果,并将该执行结果写入对应的目标寄存器之后,才能将当前待执行指令之后的待执行指令的执行结果提交至对应的目标寄存器。
It should be noted that, when the processor writes the execution result of the multiple to-be-executed instructions into the corresponding target register according to the instruction sequence, if the current pending execution instruction has not obtained the execution result, even if the current pending execution instruction is to be executed The execution instruction obtains the execution result, and then the execution result of the to-be-executed instruction after the current to-be-executed instruction cannot be written to the corresponding target register across the current to-be-executed instruction, and can only wait until the current to-be-executed instruction obtains the execution result, and the After the execution result is written into the corresponding target register, the execution result of the instruction to be executed after the current instruction to be executed can be submitted to the corresponding target register.
另外,当该处理器将待执行指令的执行结果写入对应的目标寄存器之后,可以将该待执行指令对应的存储编号释放,以及将对应的存储空间释放。In addition, after the processor writes the execution result of the instruction to be executed into the corresponding target register, the storage number corresponding to the instruction to be executed may be released, and the corresponding storage space is released.
综上所述,对指令进行处理的过程可以通过如下图3所示的过程来表示,也即是,该处理器需要先从指令缓存中取出多个待执行指令。之后,对该多个待执行指令进行译码,并在译码阶段基于配置信息识别该多个待执行指令中的长延迟指令,该配置信息包括关键类型库或者关键地址库。再对每个待执行指令进行重命名,也即是,为每个待执行指令分配一个存储空间,然后就开始执行该多个待执行指令,并将该多个待执行指令的执行结果存储在对应的存储空间中。之后,该处理器还可以将每个关键指令标识存储在指令缓存中,方便下次取指,提高指令处理效率。In summary, the process of processing an instruction may be represented by a process as shown in FIG. 3 below, that is, the processor needs to first fetch a plurality of to-be-executed instructions from the instruction cache. Thereafter, the plurality of to-be-executed instructions are decoded, and the long-delay instruction among the plurality of to-be-executed instructions is identified based on the configuration information in the decoding stage, the configuration information including a key type library or a key address library. Re-naming each instruction to be executed, that is, allocating a storage space for each instruction to be executed, then starting to execute the plurality of instructions to be executed, and storing the execution result of the plurality of instructions to be executed in Corresponding storage space. Afterwards, the processor can also store each key instruction identifier in the instruction cache to facilitate the next instruction fetching and improve the instruction processing efficiency.
在本发明实施例中,可以按照指令顺序,从指令缓存中取出多个待执行指令,并从该多个待执行指令中,获取至少一个可执行指令,而在执行该至少一个可执行指令时,可以优先执行该至少一个可执行指令中的关键指令,由于关键指令包括长延迟指令,因此,优先执行该至少一个可执行指令中的关键指令,可以提前长延迟指令的执行时间,并在该长延迟指令执行过程中,可以保证有足够多的无关指令可以执行,进而减小处理器的等待时间,从而提高处理器的处理性能。In the embodiment of the present invention, a plurality of to-be-executed instructions may be fetched from the instruction cache according to an instruction sequence, and at least one executable instruction is obtained from the plurality of to-be-executed instructions, and when the at least one executable instruction is executed The key instruction in the at least one executable instruction may be preferentially executed. Since the key instruction includes a long delay instruction, the key instruction in the at least one executable instruction is preferentially executed, and the execution time of the instruction may be delayed in advance, and During the execution of a long delay instruction, it is guaranteed that there are enough irrelevant instructions to execute, thereby reducing the waiting time of the processor, thereby improving the processing performance of the processor.
本发明实施例提供了一种计算设备可读介质,包括计算设备执行指令,当计算设备的处理器执行该计算设备执行指令时,该计算设备可以执行上述所述的指令处理方法。Embodiments of the present invention provide a computing device readable medium, including a computing device executing instructions, when the processor of the computing device executes the computing device to execute an instruction, the computing device may perform the instruction processing method described above.
参见图4,本发明实施例提供了一种指令处理设备,该设备包括:处理器401、存储器402、总线403和通信接口404;Referring to FIG. 4, an embodiment of the present invention provides an instruction processing device, which includes: a processor 401, a memory 402, a bus 403, and a communication interface 404;
存储器402用于存储计算机执行指令4021,处理器401与存储器402通过该总线403连接,当数据存储装置运行时,处理器401执行存储器402存储的
计算机执行指令,以使指令处理设备执行上述所述的指令处理方法。The memory 402 is used to store computer execution instructions 4021 through which the processor 401 and the memory 402 are connected. When the data storage device is in operation, the processor 401 executes the memory 402.
The computer executes the instructions to cause the instruction processing device to perform the instruction processing method described above.
图5是本发明实施例提供的一种指令处理设备的结构示意图。参见图5,该设备包括:FIG. 5 is a schematic structural diagram of an instruction processing apparatus according to an embodiment of the present invention. Referring to Figure 5, the device includes:
确定模块501,用于确定至少一个可执行指令中的关键指令,该关键指令是指长延迟指令或位于关键指令链上的指令,该关键指令链包含N阶指令,其中,该N阶指令中的第i阶指令为第i+1阶指令的生产者指令,该生产者指令是指第i阶指令的目标寄存器是第i+1阶指令的源寄存器,该关键指令链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数;The determining module 501 is configured to determine a key instruction in the at least one executable instruction, where the key instruction refers to a long delay instruction or an instruction located on a key instruction chain, where the key instruction chain includes an N-th order instruction, wherein the N-th order instruction The i-th order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i-th order instruction is a source register of the i+1th order instruction, and the Nth order of the key instruction chain The instruction is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;
执行模块502,用于优先执行该至少一个可执行指令中的关键指令。The execution module 502 is configured to preferentially execute the key instructions in the at least one executable instruction.
可选地,参见图6,该设备还包括:Optionally, referring to FIG. 6, the device further includes:
取指模块503,用于从指令缓存中取出多个待执行指令;The fetch module 503 is configured to fetch a plurality of to-be-executed instructions from the instruction cache.
确定模块501,还用于从该多个待执行指令中,确定至少一个可执行指令。The determining module 501 is further configured to determine at least one executable instruction from the plurality of to-be-executed instructions.
可选地,确定模块401用于确定至少一个可执行指令中的关键指令,包括:Optionally, the determining module 401 is configured to determine key instructions in the at least one executable instruction, including:
对于该至少一个可执行指令中的任一可执行指令,确定模块401用于判断该任一可执行指令的关键指令标识是否有效或该任一可执行指令是否为长延迟指令;当该任一可执行指令的关键指令标识有效或者该任一可执行指令为长延迟指令时,还用于确定该任一可执行指令为关键指令。For any executable instruction of the at least one executable instruction, the determining module 401 is configured to determine whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction; When the key instruction identifier of the executable instruction is valid or the executable instruction is a long delay instruction, it is also used to determine that the executable instruction is a key instruction.
可选地,该设备还包括:Optionally, the device further includes:
第一设置模块,用于在该关键指令存在生产者指令,且该关键指令的生产者指令没有被标记为关键指令时,将该关键指令的生产者指令的关键指令标识设置为有效。The first setting module is configured to set a key instruction identifier of the producer instruction of the key instruction to be valid when the manufacturer instruction is present in the key instruction, and the producer instruction of the key instruction is not marked as the key instruction.
可选地,该设备还包括:Optionally, the device further includes:
第二设置模块,用于在该关键指令的关键指令标识无效且该关键指令为长延迟指令时,将该长延迟指令的关键指令标识设置为有效。
The second setting module is configured to set the key instruction identifier of the long delay instruction to be valid when the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction.
可选地,该设备还包括:Optionally, the device further includes:
第一写入模块,用于在每将一个指令的关键指令标识设置为有效时,将该关键指令的标识写入该指令缓存中。The first write module is configured to write the identifier of the critical instruction into the instruction cache every time the critical instruction identifier of an instruction is set to be valid.
可选地,确定模块501用于判断该任一可执行指令是否为长延迟指令,包括:Optionally, the determining module 501 is configured to determine whether the any executable instruction is a long delay instruction, including:
确定模块501,用于对该任一可执行指令进行译码,得到该任一可执行指令的指令类型;a determining module 501, configured to decode the executable instruction to obtain an instruction type of the executable instruction;
并用于判断存储的关键类型库中是否包含该任一可执行指令的指令类型;And used to determine whether the stored key type library contains the instruction type of any executable instruction;
如果该关键类型库中包含该任一可执行指令的指令类型,则还用于确定该任一可执行指令为长延迟指令。If the key type library contains an instruction type of any of the executable instructions, it is also used to determine that any of the executable instructions is a long delay instruction.
可选地,确定模块501用于判断所述任一可执行指令是否为长延迟指令,包括:Optionally, the determining module 501 is configured to determine whether the any executable instruction is a long delay instruction, including:
确定模块501,用于判断存储的关键地址库中是否包含该任一可执行指令的指令地址;a determining module 501, configured to determine whether the stored key address library includes an instruction address of the executable instruction;
如果该关键地址库中包含该任一可执行指令的指令地址,则用于确定该任一可执行指令为长延迟指令。If the key address library contains the instruction address of any of the executable instructions, it is used to determine that any of the executable instructions is a long delay instruction.
可选地,该设备还包括:Optionally, the device further includes:
分配模块,用于为该多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储每个待执行指令的执行结果;An allocation module, configured to respectively allocate a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each to-be-executed instruction;
相应地,该设备还包括:Accordingly, the device further includes:
第二写入模块,用于当每得到一个待执行指令的执行结果时,将该待执行指令的执行结果写入对应的存储空间中;并用于在该多个待执行指令结束执行之后,按照该多个待执行指令的指令顺序,依次将该多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入每个待执行指令对应的目标寄存器。a second write module, configured to write an execution result of the to-be-executed instruction into a corresponding storage space every time an execution result of the to-be-executed instruction is obtained; and, after the execution of the plurality of to-be-executed instructions ends, follow The instruction sequence of the plurality of to-be-executed instructions sequentially writes the execution result in the storage space corresponding to each of the plurality of to-be-executed instructions to the target register corresponding to each instruction to be executed.
在本发明实施例中,确定至少一个可执行指令中的关键指令,而在执行该
至少一个可执行指令时,可以优先执行该至少一个可执行指令中的关键指令,由于关键指令包括长延迟指令,因此,优先执行该至少一个可执行指令中的关键指令,可以提前长延迟指令的执行时间,并在该长延迟指令执行过程中,可以保证有足够多的无关指令可以执行,进而减小处理器的等待时间,从而提高处理器的处理性能。In an embodiment of the present invention, determining a key instruction in the at least one executable instruction while performing the
When at least one executable instruction is executed, the key instruction in the at least one executable instruction may be preferentially executed. Since the key instruction includes a long delay instruction, the key instruction in the at least one executable instruction is preferentially executed, and the instruction may be delayed in advance. Execution time, and during the execution of the long delay instruction, it can be ensured that there are enough irrelevant instructions to be executed, thereby reducing the waiting time of the processor, thereby improving the processing performance of the processor.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。A person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium. The storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。
The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalents, improvements, etc., which are within the spirit and scope of the present invention, should be included in the protection of the present invention. Within the scope.
Claims (20)
- 一种指令处理方法,其特征在于,所述方法包括:An instruction processing method, characterized in that the method comprises:确定至少一个可执行指令中的关键指令,所述关键指令是指长延迟指令或位于关键指令链上的指令,所述关键指令链包含N阶指令,其中,所述N阶指令中的第i阶指令为第i+1阶指令的生产者指令,所述生产者指令是指所述第i阶指令的目标寄存器是第i+1阶指令的源寄存器,所述关键指令链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数;Determining a key instruction in at least one executable instruction, the key instruction being a long delay instruction or an instruction located on a critical instruction chain, the key instruction chain comprising an Nth order instruction, wherein the ith of the Nth order instructions The order instruction is a producer instruction of the i+1th order instruction, and the producer instruction means that the target register of the i th order instruction is a source register of the i+1th order instruction, and the Nth of the key instruction chain The order instruction is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;优先执行所述至少一个可执行指令中的所述关键指令。The key instructions of the at least one executable instruction are preferentially executed.
- 根据权利要求1所述的方法,其特征在于,所述确定至少一个可执行指令中的关键指令之前,还包括:The method of claim 1, wherein before the determining the key instructions in the at least one executable instruction, the method further comprises:从指令缓存中取出多个待执行指令;Extracting a plurality of to-be-executed instructions from the instruction cache;从所述多个待执行指令中,确定至少一个可执行指令。From the plurality of to-be-executed instructions, at least one executable instruction is determined.
- 根据权利要求1所述的方法,其特征在于,所述确定至少一个可执行指令中的关键指令,包括:The method of claim 1 wherein said determining a key instruction in the at least one executable instruction comprises:对于所述至少一个可执行指令中的任一可执行指令,判断所述任一可执行指令的关键指令标识是否有效或所述任一可执行指令是否为长延迟指令;Determining, for any executable instruction of the at least one executable instruction, whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction;当所述任一可执行指令的关键指令标识有效或者所述任一可执行指令为长延迟指令时,确定所述任一可执行指令为关键指令。When the critical instruction identification of any of the executable instructions is valid or the any executable instruction is a long delay instruction, it is determined that the any executable instruction is a key instruction.
- 根据权利要求1-3任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 3, wherein the method further comprises:在所述关键指令存在生产者指令,且所述关键指令的生产者指令没有被标记为关键指令时,将所述关键指令的生产者指令的关键指令标识设置为有效。When there is a producer instruction in the key instruction, and the producer instruction of the key instruction is not marked as a key instruction, the key instruction identifier of the producer instruction of the key instruction is set to be valid.
- 根据权利要求1-4任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, wherein the method further comprises:在所述关键指令的关键指令标识无效且所述关键指令为长延迟指令时,将所述长延迟指令的关键指令标识设置为有效。When the key instruction identifier of the key instruction is invalid and the key instruction is a long delay instruction, the key instruction identifier of the long delay instruction is set to be valid.
- 根据权利要求4或5所述的方法,其特征在于,所述方法还包括: The method according to claim 4 or 5, wherein the method further comprises:在每将一个指令的关键指令标识设置为有效时,将所述关键指令的标识写入所述指令缓存中。The identity of the critical instruction is written into the instruction cache each time a critical instruction identification of an instruction is set to be valid.
- 根据权利要求3所述的方法,其特征在于,所述判断所述任一可执行指令是否为长延迟指令,包括:The method according to claim 3, wherein the determining whether the any executable instruction is a long delay instruction comprises:对所述任一可执行指令进行译码,得到所述任一可执行指令的指令类型;Decoding any of the executable instructions to obtain an instruction type of any of the executable instructions;判断存储的关键类型库中是否包含所述任一可执行指令的指令类型;Determining whether the stored key type library contains the instruction type of any of the executable instructions;如果所述关键类型库中包含所述任一可执行指令的指令类型,则确定所述任一可执行指令为长延迟指令。If the key type library contains an instruction type of any of the executable instructions, it is determined that the any executable instruction is a long delay instruction.
- 根据权利要求3所述的方法,其特征在于,所述判断所述任一可执行指令是否为长延迟指令,包括:The method according to claim 3, wherein the determining whether the any executable instruction is a long delay instruction comprises:判断存储的关键地址库中是否包含所述任一可执行指令的指令地址;Determining whether the stored key address library contains the instruction address of any of the executable instructions;如果所述关键地址库中包含所述任一可执行指令的指令地址,则确定所述任一可执行指令为长延迟指令。If the key address library contains an instruction address of any of the executable instructions, it is determined that the any executable instruction is a long delay instruction.
- 根据权利要求1-8任一项所述的方法,其特征在于,所述从指令缓存中取出多个待执行指令之后,还包括:The method according to any one of claims 1-8, wherein after the fetching a plurality of to-be-executed instructions from the instruction cache, the method further comprises:为所述多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储所述每个待执行指令的执行结果;Allocating a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each of the to-be-executed instructions;相应地,所述方法还包括:Correspondingly, the method further comprises:当每得到一个待执行指令的执行结果时,将所述待执行指令的执行结果写入对应的存储空间中;When the execution result of the instruction to be executed is obtained, the execution result of the instruction to be executed is written into the corresponding storage space;在所述多个待执行指令结束执行之后,按照所述多个待执行指令的指令顺序,依次将所述多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入所述每个待执行指令对应的目标寄存器。After the execution of the plurality of to-be-executed instructions is ended, the execution results in the storage space corresponding to each of the plurality of to-be-executed instructions are sequentially written in accordance with the instruction sequence of the plurality of to-be-executed instructions. The target register corresponding to each instruction to be executed is described.
- 一种计算设备可读介质,其特征在于,包括计算设备执行指令,当计算设备的处理器执行所述计算设备执行指令时,所述计算设备执行权利要求1-9任一项所述的方法。 A computing device readable medium, comprising: a computing device executing instructions, when the processor of the computing device executes the computing device to execute an instruction, the computing device performing the method of any one of claims 1-9 .
- 一种指令处理设备,其特征在于,所述设备包括:处理器、存储器、总线和通信接口;An instruction processing device, characterized in that the device comprises: a processor, a memory, a bus and a communication interface;所述存储器用于存储计算机执行指令,所述处理器与所述存储器通过所述总线连接,当所述数据存储装置运行时,所述处理器执行所述存储器存储的所述计算机执行指令,以使所述指令处理设备执行权利要求1-9任一项所述的方法。The memory is configured to store a computer execution instruction, the processor is coupled to the memory via the bus, and when the data storage device is in operation, the processor executes the computer-executed instruction stored in the memory to The instruction processing device is caused to perform the method of any of claims 1-9.
- 一种指令处理设备,其特征在于,所述设备包括:An instruction processing device, characterized in that the device comprises:确定模块,用于确定至少一个可执行指令中的关键指令,所述关键指令是指长延迟指令或位于关键指令链上的指令,所述关键指令链包含N阶指令,其中,所述N阶指令中的第i阶指令为第i+1阶指令的生产者指令,所述生产者指令是指所述第i阶指令的目标寄存器是第i+1阶指令的源寄存器,所述关键指令链上的第N阶指令为长延迟指令,N为大于1的正整数,i为大于0并小于N的正整数;Determining a module for determining a key instruction in the at least one executable instruction, the key instruction being a long delay instruction or an instruction located on a key instruction chain, the key instruction chain comprising an Nth order instruction, wherein the Nth order The i-th order instruction in the instruction is a producer instruction of the (i+1)th instruction, and the producer instruction is that the target register of the i-th order instruction is a source register of the (i+1)th instruction, the key instruction The Nth order instruction on the chain is a long delay instruction, N is a positive integer greater than 1, and i is a positive integer greater than 0 and less than N;执行模块,用于优先执行所述至少一个可执行指令中的所述关键指令。And an execution module, configured to preferentially execute the key instruction in the at least one executable instruction.
- 根据权利要求12所述的设备,其特征在于,所述设备还包括取指模块,The device according to claim 12, wherein the device further comprises an instruction fetching module,所述取指模块,用于从指令缓存中取出多个待执行指令;The fetching module is configured to fetch a plurality of to-be-executed instructions from the instruction cache;所述确定模块,还用于从所述多个待执行指令中,确定至少一个可执行指令。The determining module is further configured to determine at least one executable instruction from the plurality of to-be-executed instructions.
- 根据权利要求12所述的设备,其特征在于,所述确定模块用于确定至少一个可执行指令中的关键指令,包括:The device according to claim 12, wherein the determining module is configured to determine key instructions in the at least one executable instruction, including:对于所述至少一个可执行指令中的任一可执行指令,所述确定模块用于判断所述任一可执行指令的关键指令标识是否有效或所述任一可执行指令是否为长延迟指令;当所述任一可执行指令的关键指令标识有效或者所述任一可执行指令为长延迟指令时,还用于确定所述任一可执行指令为关键指令。For any executable instruction of the at least one executable instruction, the determining module is configured to determine whether the key instruction identifier of the any executable instruction is valid or whether the any executable instruction is a long delay instruction; When the key instruction identifier of any of the executable instructions is valid or the any executable instruction is a long delay instruction, it is further used to determine that the any executable instruction is a key instruction.
- 根据权利要求12-14任一项所述的设备,其特征在于,所述设备还包括:The device according to any one of claims 12 to 14, wherein the device further comprises:第一设置模块,用于在所述关键指令存在生产者指令,且所述关键指令的 生产者指令没有被标记为关键指令时,将所述关键指令的生产者指令的关键指令标识设置为有效。a first setting module, configured to have a producer instruction in the key instruction, and the key instruction When the producer instruction is not marked as a critical instruction, the key instruction identifier of the producer instruction of the key instruction is set to be valid.
- 根据权利要求12-15任一项所述的设备,其特征在于,所述设备还包括:The device according to any one of claims 12-15, wherein the device further comprises:第二设置模块,用于在所述关键指令的关键指令标识无效且所述关键指令为长延迟指令时,将所述长延迟指令的关键指令标识设置为有效。And a second setting module, configured to: when the key instruction identifier of the critical instruction is invalid and the key instruction is a long delay instruction, set a key instruction identifier of the long delay instruction to be valid.
- 根据权利要求15或16所述的设备,其特征在于,所述设备还包括:The device according to claim 15 or 16, wherein the device further comprises:第一写入模块,用于在每将一个指令的关键指令标识设置为有效时,将所述关键指令的标识写入所述指令缓存中。The first write module is configured to write an identifier of the key instruction into the instruction cache every time a key instruction identifier of an instruction is set to be valid.
- 根据权利要求14所述的设备,其特征在于,所述确定模块用于判断所述任一可执行指令是否为长延迟指令,包括:The device according to claim 14, wherein the determining module is configured to determine whether the any executable instruction is a long delay instruction, including:所述确定模块,用于对所述任一可执行指令进行译码,得到所述任一可执行指令的指令类型;The determining module is configured to decode any one of the executable instructions to obtain an instruction type of the any executable instruction;并用于判断存储的关键类型库中是否包含所述任一可执行指令的指令类型;And used to determine whether the stored key type library contains the instruction type of any of the executable instructions;如果所述关键类型库中包含所述任一可执行指令的指令类型,则还用于确定所述任一可执行指令为长延迟指令。If the key type library contains the instruction type of any of the executable instructions, it is further used to determine that the any executable instruction is a long delay instruction.
- 根据权利要求14所述的设备,其特征在于,所述确定模块用于判断所述任一可执行指令是否为长延迟指令,包括:The device according to claim 14, wherein the determining module is configured to determine whether the any executable instruction is a long delay instruction, including:所述确定模块,用于判断存储的关键地址库中是否包含所述任一可执行指令的指令地址;The determining module is configured to determine whether the stored key address library includes an instruction address of the any executable instruction;如果所述关键地址库中包含所述任一可执行指令的指令地址,则用于确定所述任一可执行指令为长延迟指令。If the key address library contains an instruction address of any of the executable instructions, it is used to determine that any of the executable instructions is a long delay instruction.
- 根据权利要求12-19任一项所述的设备,其特征在于,所述设备还包括:The device according to any one of claims 12 to 19, wherein the device further comprises:分配模块,用于为所述多个待执行指令中的每个待执行指令分别分配一个存储空间,每个存储空间分别用于存储所述每个待执行指令的执行结果;An allocation module, configured to respectively allocate a storage space for each of the plurality of to-be-executed instructions, where each storage space is used to store an execution result of each of the to-be-executed instructions;相应地,所述设备还包括: Correspondingly, the device further includes:第二写入模块,用于当每得到一个待执行指令的执行结果时,将所述待执行指令的执行结果写入对应的存储空间中;并用于在所述多个待执行指令结束执行之后,按照所述多个待执行指令的指令顺序,依次将所述多个待执行指令中每个待执行指令对应的存储空间中的执行结果写入所述每个待执行指令对应的目标寄存器。 a second write module, configured to write an execution result of the to-be-executed instruction into a corresponding storage space every time an execution result of an instruction to be executed is obtained; and to be used after the execution of the plurality of to-be-executed instructions ends And executing, in an instruction sequence of the plurality of to-be-executed instructions, an execution result in a storage space corresponding to each of the plurality of to-be-executed instructions in a target register corresponding to each to-be-executed instruction.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2015/081954 WO2016201699A1 (en) | 2015-06-19 | 2015-06-19 | Instruction processing method and device |
CN201580001167.2A CN106537331B (en) | 2015-06-19 | 2015-06-19 | Command processing method and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2015/081954 WO2016201699A1 (en) | 2015-06-19 | 2015-06-19 | Instruction processing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2016201699A1 true WO2016201699A1 (en) | 2016-12-22 |
Family
ID=57544746
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2015/081954 WO2016201699A1 (en) | 2015-06-19 | 2015-06-19 | Instruction processing method and device |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106537331B (en) |
WO (1) | WO2016201699A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114461278A (en) * | 2022-04-13 | 2022-05-10 | 海光信息技术股份有限公司 | Method for operating instruction scheduling queue, operating device and electronic device |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112214241B (en) * | 2020-09-23 | 2023-11-24 | 上海赛昉科技有限公司 | Method and system for distributed instruction execution unit |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1504873A (en) * | 2002-12-05 | 2004-06-16 | �Ҵ���˾ | Multithreading recycle and dispatch system and method thereof |
CN1550978A (en) * | 2003-05-08 | 2004-12-01 | �Ҵ���˾ | Method and system for implementing queue instruction in multi-threaded microprocessor |
CN1790256A (en) * | 2004-12-17 | 2006-06-21 | 国际商业机器公司 | Branch lookahead prefetch for microprocessors |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE4237417C2 (en) * | 1992-03-25 | 1997-01-30 | Hewlett Packard Co | Data processing system |
US6385715B1 (en) * | 1996-11-13 | 2002-05-07 | Intel Corporation | Multi-threading for a processor utilizing a replay queue |
CN101263452A (en) * | 2004-03-31 | 2008-09-10 | 太阳微系统公司 | Method and structure for explicit software control of execution of a thread including a helper subthread |
US7900023B2 (en) * | 2004-12-16 | 2011-03-01 | Intel Corporation | Technique to enable store forwarding during long latency instruction execution |
US8099586B2 (en) * | 2008-12-30 | 2012-01-17 | Oracle America, Inc. | Branch misprediction recovery mechanism for microprocessors |
CN102799419B (en) * | 2012-09-05 | 2014-10-22 | 无锡江南计算技术研究所 | Register writing conflict detection method and device, and processor |
US9645802B2 (en) * | 2013-08-07 | 2017-05-09 | Nvidia Corporation | Technique for grouping instructions into independent strands |
-
2015
- 2015-06-19 WO PCT/CN2015/081954 patent/WO2016201699A1/en active Application Filing
- 2015-06-19 CN CN201580001167.2A patent/CN106537331B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1504873A (en) * | 2002-12-05 | 2004-06-16 | �Ҵ���˾ | Multithreading recycle and dispatch system and method thereof |
CN1550978A (en) * | 2003-05-08 | 2004-12-01 | �Ҵ���˾ | Method and system for implementing queue instruction in multi-threaded microprocessor |
CN1790256A (en) * | 2004-12-17 | 2006-06-21 | 国际商业机器公司 | Branch lookahead prefetch for microprocessors |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114461278A (en) * | 2022-04-13 | 2022-05-10 | 海光信息技术股份有限公司 | Method for operating instruction scheduling queue, operating device and electronic device |
CN114461278B (en) * | 2022-04-13 | 2022-06-21 | 海光信息技术股份有限公司 | Method for operating instruction scheduling queue, operating device and electronic device |
Also Published As
Publication number | Publication date |
---|---|
CN106537331A (en) | 2017-03-22 |
CN106537331B (en) | 2019-07-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI644208B (en) | Backward compatibility by restriction of hardware resources | |
US10127043B2 (en) | Implementing conflict-free instructions for concurrent operation on a processor | |
US20200336421A1 (en) | Optimized function assignment in a multi-core processor | |
JP7118984B2 (en) | Computer-implemented method, system, and computer program for avoiding memory access of load instructions | |
US10355975B2 (en) | Latency guaranteed network on chip | |
US11416256B2 (en) | Selectively performing ahead branch prediction based on types of branch instructions | |
US11868780B2 (en) | Central processor-coprocessor synchronization | |
US20190369999A1 (en) | Storing incidental branch predictions to reduce latency of misprediction recovery | |
EP2609500B1 (en) | Obtaining and releasing hardware threads without hypervisor involvement | |
RU2375768C2 (en) | Processor and method of indirect reading and recording into register | |
WO2015171862A1 (en) | Detecting data dependencies of instructions associated with threads in a simultaneous multithreading scheme | |
US20140095814A1 (en) | Memory Renaming Mechanism in Microarchitecture | |
WO2018107331A1 (en) | Computer system and memory access technology | |
WO2016201699A1 (en) | Instruction processing method and device | |
US20210165654A1 (en) | Eliminating execution of instructions that produce a constant result | |
US20230401060A1 (en) | Processing unit, computing device and instruction processing method | |
KR100837400B1 (en) | Method and apparatus for processing according to multi-threading/out-of-order merged scheme | |
WO2023142524A1 (en) | Instruction processing method and apparatus, chip, electronic device, and storage medium | |
US11481250B2 (en) | Cooperative workgroup scheduling and context prefetching based on predicted modification of signal values | |
JP5238876B2 (en) | Information processing apparatus and information processing method | |
EP3497558B1 (en) | System and method for load and store queue allocations at address generation time | |
JP6344022B2 (en) | Arithmetic processing device and control method of arithmetic processing device | |
CN112579481B (en) | Data processing method, data processing device and computing device | |
US11403098B2 (en) | Fast descriptor access for virtual network devices | |
KR20220100067A (en) | Register write suppression |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15895272 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 15895272 Country of ref document: EP Kind code of ref document: A1 |