Processing device, instruction processing method, equipment and storage medium

By processing instructions according to the execution order and the order of finger fetching in the processing device, the error problem caused by out-of-order processing is solved, and processing efficiency is improved and resource consumption is reduced.

CN118963838APending Publication Date: 2024-11-15BEIJING ESWIN COMPUTING TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410969715.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

In high-performance processing devices, processing instructions indisorder may cause errors when the instructions access the same address, resulting in inaccurate processing results, and in turn, which requires flushing the pipeline, reducing processing efficiency and consuming resources.

Method used

By introducing a finger fetching unit, an execution unit and a transmission unit in the processing device, the execution information is generated according to the execution order and the finger fetching order, and the instructions carrying the mark are sent to the transmission unit, so that the execution unit processes the instructions in the finger fetching order to ensure the correctness of the instructions. Sequential processing.

Benefits of technology

It reduces the number of pipeline flushing times, improves instruction processing efficiency, reduces resource consumption, and ensures the accuracy of processing results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963838A_ABST
    Figure CN118963838A_ABST
Patent Text Reader

Abstract

The invention discloses a processing device, an instruction processing method, equipment and a storage medium. A transmitting unit in the processing device is respectively connected with an instruction fetching unit and an execution unit, the instruction fetching unit is used for acquiring a first instruction, a second instruction and execution information determined based on an execution sequence and an instruction fetching sequence, the execution sequence is a sequence for processing a third instruction and a fourth instruction, and the instruction fetching sequence is a sequence for acquiring the third instruction and the fourth instruction. The fetch address corresponding to the third instruction is the same as the fetch address corresponding to the first instruction, and the fetch address corresponding to the fourth instruction is the same as the fetch address corresponding to the second instruction; when the execution information indicates that the execution sequence and the instruction fetching sequence are different, a first instruction carrying a first mark and a second instruction carrying a second mark are sent; the transmitting unit is used for transmitting a first instruction carrying a first mark and a second instruction carrying a second mark to the execution unit according to an instruction fetching sequence; the execution unit is used for processing the first instruction carrying the first mark and the second instruction carrying the second mark according to the instruction fetching sequence, and the processing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic information technology, and in particular to a processing device, an instruction processing method, a device and a storage medium. Background Art

[0002] When a processing device processes instructions, it usually processes the instructions in the order in which they are fetched. However, when a high-performance processing device processes instructions, multiple instructions can be processed out of order. For example, when the operands of an instruction are ready, even if the instructions fetched before this instruction have not been processed, this instruction can be processed first to improve the efficiency of instruction processing.

[0003] In some cases, if the address accessed by two instructions is the same address, processing the two instructions out of order may result in incorrect processing results for the two instructions. For example, two instructions are to read data from a specified address and write data to the same address, and the correct order is to read first and then write. If the two instructions are executed out of order, and the data in the specified address is written first and then read, the read data and the written data will be inaccurate, resulting in incorrect processing results.

[0004] In this case, the processing device needs to flush the pipeline after processing the two instructions and re-process the two instructions, which reduces the efficiency of the processing device in processing instructions and consumes more resources. Summary of the invention

[0005] The present application provides a processing device, instruction processing method, equipment and storage medium, in order to reduce the number of times the processing device flushes the pipeline, reduce resource consumption, and improve instruction processing efficiency. The technical solution is as follows:

[0006] On the one hand, a processing device is provided, which includes an instruction fetch unit, an execution unit and a transmitting unit, wherein the transmitting unit is connected to the instruction fetch unit and the execution unit respectively; the instruction fetch unit is used to obtain a first instruction, a second instruction and execution information, the execution information is determined by the execution unit based on an execution order and an instruction fetch order, the execution order refers to the order in which the execution unit processes a third instruction and a fourth instruction, the instruction fetch order refers to the order in which the instruction fetch unit obtains the third instruction and the fourth instruction, the third instruction has the same instruction fetch address as the first instruction, and the fourth instruction has the same instruction fetch address as the second instruction; when the execution information indicates that the execution order and the instruction fetch order are different, a first instruction carrying a first tag and a second instruction carrying a second tag are sent to the transmitting unit; the transmitting unit is used to send the first instruction carrying the first tag and the second instruction carrying the second tag to the execution unit according to the instruction fetch order based on the first tag and the second tag; the execution unit is used to process the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction receiving order, and the instruction receiving order is the same as the instruction fetch order.

[0007] In the present application, the first instruction acquired by the instruction fetch unit and the third instruction processed by the execution unit last time are two instructions fetched according to the same instruction fetch address, and the instruction fetch address refers to the address of the unit storing each instruction in the storage space when the instruction fetch unit reads each instruction in the storage space for storing instructions. The same instruction fetch address is determined according to the PC (Program Counter) values ​​corresponding to the first instruction and the third instruction, and the contents of the first instruction and the third instruction may be the same or different.

[0008] Correspondingly, the second instruction obtained by the instruction fetch unit and the fourth instruction processed by the execution unit last time are two instructions obtained by fetching according to the same instruction fetch address. The same instruction fetch address is determined based on the PC values ​​corresponding to the second instruction and the fourth instruction. The contents of the second instruction and the fourth instruction may be the same or different.

[0009] In a possible implementation, the execution unit is further used to obtain the third instruction, the fourth instruction and the instruction fetching order; process the third instruction and the fourth instruction respectively to obtain the execution order; and generate execution information according to the execution order and the instruction fetching order.

[0010] In a possible implementation, when the execution order and the instruction fetch order are different, the execution information includes first missing information of the first tag.

[0011] In a possible implementation, when the execution order and the instruction fetch order are different and the third instruction carries a third tag, the execution information includes first information indicating that the execution unit predicts success, and the third tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0012] In a possible implementation, when the execution order and the instruction fetch order are the same and the third instruction carries a third tag, the execution information includes second information indicating that the execution unit predicts a failure, and the third tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0013] In a possible implementation, when the execution order and the instruction fetch order are different, the execution information further includes second missing information of the second tag.

[0014] In a possible implementation, when the execution order and the instruction fetch order are different and the fourth instruction carries a fourth tag, the execution information also includes third information indicating that the execution unit predicts successfully, and the fourth tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0015] In a possible implementation, when the execution order and the instruction fetch order are the same and the fourth instruction carries a fourth tag, the execution information also includes fourth information indicating that the execution unit predicts a failure, and the fourth tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0016] In a possible implementation, the instruction fetch unit is further configured to determine a first value according to the execution information; and to obtain a first instruction carrying a first tag and a second instruction carrying a second tag when the first value is greater than or equal to a threshold.

[0017] In one possible implementation, the instruction fetch unit is used to determine the second value as the threshold when the execution information indicates that the execution order is different from the processing order; when the second instruction and the first instruction access the same address, add the second value to the third value to obtain the first value, and the third value is a positive number; when the second instruction and the first instruction access different addresses, subtract the fourth value from the second value to obtain the first value, and the fourth value is a positive number.

[0018] In a possible implementation manner, the first instruction and the second instruction satisfy any one of a read-after-write relationship, a read-after-read relationship, a write-after-read relationship, or a write-after-write relationship.

[0019] On the other hand, the present application provides an instruction processing method, which is applied to a processing device, wherein the processing device includes an instruction fetch unit, an execution unit and a transmitting unit, wherein the transmitting unit is connected to the instruction fetch unit and the execution unit respectively, and the method includes: obtaining a first instruction, a second instruction and execution information through the instruction fetch unit, wherein the execution information is determined by the execution unit based on an execution order and an instruction fetch order, wherein the execution order refers to the order in which the execution unit processes a third instruction and a fourth instruction, and the instruction fetch order refers to the order in which the instruction fetch unit obtains the third instruction and the fourth instruction, wherein the instruction fetch addresses corresponding to the third instruction and the first instruction are the same, and the instruction fetch addresses corresponding to the fourth instruction and the second instruction are the same; through the instruction fetch unit, when the execution information indicates that the execution order and the instruction fetch order are different, sending a first instruction carrying a first tag and a second instruction carrying a second tag to the transmitting unit; through the transmitting unit, sending the first instruction carrying the first tag and the second instruction carrying the second tag to the execution unit according to the instruction fetch order based on the first tag and the second tag; through the execution unit, processing the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction reception order, wherein the instruction reception order is the same as the instruction fetch order.

[0020] In a possible implementation, before obtaining the first instruction, the second instruction and the execution information through the instruction fetch unit, it also includes: obtaining the third instruction, the fourth instruction and the instruction fetch order through the execution unit; processing the third instruction and the fourth instruction respectively through the execution unit to obtain the execution order; and generating the execution information through the execution unit according to the execution order and the instruction fetch order.

[0021] In a possible implementation, when the execution order and the instruction fetch order are different, the execution information includes first missing information of the first tag.

[0022] In a possible implementation, when the execution order and the instruction fetch order are different and the third instruction carries a third tag, the execution information includes first information indicating that the execution unit predicts success, and the third tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0023] In a possible implementation, when the execution order and the instruction fetch order are the same and the third instruction carries a third tag, the execution information includes second information indicating that the execution unit predicts a failure, and the third tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0024] In a possible implementation, when the execution order and the instruction fetch order are different, the execution information further includes second missing information of the second tag.

[0025] In a possible implementation, when the execution order and the instruction fetch order are different and the fourth instruction carries a fourth tag, the execution information also includes third information indicating that the execution unit predicts successfully, and the fourth tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0026] In a possible implementation, when the execution order and the instruction fetch order are the same and the fourth instruction carries a fourth tag, the execution information also includes fourth information indicating that the execution unit predicts a failure, and the fourth tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0027] In a possible implementation, through an instruction fetch unit, when execution information indicates that the execution order and the instruction fetch order are different, before sending a first instruction carrying a first tag and a second instruction carrying a second tag to a transmitting unit, it also includes: determining a first value through the instruction fetch unit according to the execution information; and obtaining the first instruction carrying the first tag and the second instruction carrying the second tag through the instruction fetch unit when the first value is greater than or equal to a threshold.

[0028] In one possible implementation, a first value is determined according to execution information by an instruction fetch unit, including: when the execution information indicates that the execution order is different from the processing order, the second value is determined as a threshold; when the address accessed by the second instruction is the same as that accessed by the first instruction, the second value is added to the third value to obtain a first value, and the third value is a positive number; when the address accessed by the second instruction is different from that accessed by the first instruction, the fourth value is subtracted from the second value to obtain the first value, and the fourth value is a positive number.

[0029] In a possible implementation manner, the first instruction and the second instruction satisfy any one of a read-after-write relationship, a read-after-read relationship, a write-after-read relationship, or a write-after-write relationship.

[0030] On the other hand, a computer device is provided, comprising a processor and a memory, wherein at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor so that the computer device implements any of the above instruction processing methods.

[0031] On the other hand, a computer-readable storage medium is provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor so that the computer implements any of the above instruction processing methods.

[0032] On the other hand, a computer program product or a computer program is also provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any of the above instruction processing methods.

[0033] The technical solution provided by this application brings at least the following beneficial effects:

[0034] In the case where the execution information indicates that the execution order and the instruction fetch order are different, a first instruction carrying a first tag and a second instruction carrying a second tag are sent to the emission unit, so that the emission unit sends the first instruction carrying the first tag and the second instruction carrying the second tag to the execution unit according to the instruction fetch order indicated by the first tag and the second tag, so that the order in which the execution unit receives the first instruction carrying the first tag and the second instruction carrying the second tag can be the same as the instruction fetch order, and the execution unit processes the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction fetch order. Therefore, in the present application, for instructions corresponding to a group of instruction fetch addresses, there will only be one execution order error, and the number of pipeline flushes based on instructions corresponding to a group of instruction fetch addresses is at most once, which reduces the possibility of flushing the pipeline, improves instruction processing efficiency and reduces resource waste caused by flushing the pipeline. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0036] Figure 1 is a structural schematic diagram of a processing device provided in an embodiment of the present application;

[0037] Figure 2 It is a flowchart of an instruction processing method provided in an embodiment of the present application;

[0038] Figure 3 is a flowchart of determining execution information according to a third instruction provided by an embodiment of the present application;

[0039] Figure 4 is a flowchart of determining execution information according to a fourth instruction provided by an embodiment of the present application;

[0040] Figure 5 is a schematic diagram of a prediction table item provided in an embodiment of the present application;

[0041] Figure 6 is a schematic diagram of an update rule provided in an embodiment of the present application;

[0042] Figure 7 is a schematic diagram of the structure of another processing device provided in an embodiment of the present application;

[0043] Figure 8 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0045] In a pipeline type processing device, the process of processing instructions is divided into IF (Instruction Fetch), ID (Instruction Decode), IR (Instruction Rename), Dispatch, Issue, RRF (Read Register File), Execute, WB (Write Back) and RT (Retire), and different parts can be executed by different units in the processing device.

[0046] In a multi-core CPU (Central Processing Unit), according to the requirements of the memory consistency model, each core needs to ensure the order of access between multiple related instructions. For example, two instructions that access the same memory (register) address are two related instructions. The two related instructions need to be executed in the correct order in the execution unit of the CPU to ensure that the CPU meets the memory consistency requirements.

[0047] Among them, the correct order is the order in which instructions are sent to the processing device or the order in which the processing device generates instructions. Since the storage unit in the processing device stores each instruction in the order in which the instructions are sent to the processing device or the order in which the processing device generates instructions, and the instruction fetch unit fetches instructions in the order in which the storage unit stores each instruction, the correct order may refer to the instruction fetch order, that is, two instructions that access the same memory address are executed in the execution unit of the CPU according to the instruction fetch order of these two instructions, which can ensure that the CPU meets the memory consistency requirements.

[0048] In a multi-core CPU that executes sequentially, the emission unit sends multiple instructions to the emission unit in the instruction fetching order of the instruction fetch unit. After receiving multiple instructions in the instruction fetching order, the emission unit will also send multiple instructions to the execution unit in the instruction fetching order. Since multiple instructions will not be transmitted out of order during the transmission from the emission unit to the execution unit, that is, the instructions emitted first will be received by the execution unit first, and the instructions emitted later will be received by the execution unit later, the order in which the execution unit receives multiple instructions is the same as the instruction fetching order of the multiple instructions. And because the execution unit will process multiple instructions separately in the order in which they are received, in a multi-core CPU that executes sequentially, multiple instructions can be executed in the execution unit in the instruction fetching order, thereby ensuring that the CPU meets the memory consistency requirements.

[0049] However, in a multi-core CPU with out-of-order execution, there is no requirement for the order in which the emission unit sends multiple instructions to the execution unit and the order in which the multiple instructions are executed in the execution unit. For example, in a multi-core CPU with out-of-order execution, when the source operand of an instruction is ready, the emission unit can send this instruction to the execution unit for calculation, regardless of whether the instruction fetched before this instruction has been sent to the execution unit. After the multiple instructions obtain the calculation results in the execution unit, they are retired sequentially according to the order in which the multiple instructions are fetched, that is, out-of-order execution and sequential retirement of multiple instructions are realized.

[0050] If two instructions that access the same memory address are executed out of order, that is, the execution order of the two instructions is different from the instruction fetch order of the two instructions, the order in which the two instructions access the same memory address may be disrupted, making it impossible to ensure memory consistency in the CPU, resulting in CPU execution errors (or speculative execution errors).

[0051] For example, two instructions that access the same memory address may be a set of load / store type instructions. Load / store type instructions play an important role in the CPU. Load / store type instructions are used to complete the data interaction between the internal registers of the CPU and the external memory or peripherals. For example, load type instructions are used to load data stored in the external memory or peripherals into the internal registers of the CPU, and store type instructions are used to store data stored in the internal registers of the CPU into the external memory or peripherals.

[0052] When processing a set of store and load type instructions with correlation, the correct processing process is to store data A at address 1 based on the store type instruction, and then load data A at address 1 into the register based on the load type instruction. If out-of-order execution occurs, the load type instruction may be processed before the store type instruction, that is, the original data B at address 1 will be loaded into the register based on the load type instruction, and then the data A will be stored at address 1 based on the store type instruction, resulting in incorrect data loaded into the register, that is, CPU execution error occurs.

[0053] After an execution error occurs in the CPU, the pipeline will be flushed. Flushing the pipeline means clearing the data stored in the registers of each stage of the pipeline in the execution unit, and returning the instructions being processed in each stage of the pipeline to the storage unit, waiting for the instruction fetch unit to fetch the returned instructions again and send them to the emission unit for subsequent processing. Flushing the pipeline will cause a loss of CPU performance and reduce the efficiency of processing instructions.

[0054] After flushing the pipeline, the related technology will send the flushed instructions in the pipeline from the instruction fetch unit to the emission unit, and then from the emission unit to the execution unit for execution. However, since the address of the memory or register accessed by the load / store type instruction is dynamically calculated during the execution of the instruction, that is, only in the execution stage of the pipeline can the processing device obtain the address that the load / store type instruction needs to access through the execution unit, and can it determine whether the addresses accessed by the two instructions are the same.

[0055] It can be seen from this that the emission unit in the related art cannot determine whether the addresses accessed by the two instructions are the same, and it cannot guarantee that the two instructions with the same access address are sent in the order of instruction fetching, so that the execution unit cannot guarantee that the two instructions with the same access address are processed in the order of instruction fetching. Therefore, in the process of re-executing the instructions after flushing the pipeline in the related art, the two instructions with the same access address will still be executed out of order, so the two instructions with the same access address in the related art may cause multiple pipeline flushes, resulting in repeated execution of multiple instructions, wasting resources of the processing device, and reducing the performance of the processing device and the efficiency of processing instructions.

[0056] An embodiment of the present application provides an instruction processing method that can predict the correlation between two instructions in the instruction fetch stage and control the order in which the emission unit sends the two instructions, thereby reducing the number of execution errors that occur, thereby reducing the number of times the processing device flushes the pipeline, improving the efficiency of the processing device in instruction processing, and reducing resource waste.

[0057] The embodiments of the present application can be applied to various processing devices, such as a pipelined CPU or a graphics processing unit (GPU). Figure 1 , showing a schematic diagram of the structure of a processing device provided by an embodiment of the present application. The processing device includes an instruction fetch unit 11, a transmitting unit 12 and an execution unit 13, and the transmitting unit 12 is connected to the instruction fetch unit 11 and the execution unit 13 respectively. Among them, the instruction fetch unit 11 is used to obtain instructions to be processed and send the instructions to be transmitted to the transmitting unit 12. The instructions to be processed wait for transmission in the transmitting unit 12. When the operands of any instruction are ready, the transmitting unit 12 sends any instruction to the execution unit 13, and the execution unit 13 processes any instruction and the operands of any instruction to obtain a processing result.

[0058] Based on the previous description, it can be known that the execution unit 13 processes the instructions in the order in which the instructions are received, and the order in which the execution unit 13 receives the instructions is the order in which the transmitting unit 12 sends the instructions to the execution unit 13. Therefore, by controlling the transmitting unit 12 to send instructions to the execution unit 13 in the correct order, it can be ensured that the execution unit 13 processes the instructions in the correct order to obtain accurate processing results.

[0059] The instruction processing method provided in the embodiment of the present application can control the emission unit 12 to send instructions to the execution unit 13 in the correct order. Figure 2 , which shows a flow chart of an instruction processing method provided in an embodiment of the present application, Figure 2 The instruction processing method shown can be applied to Figure 1 The processing device shown, Figure 2 The illustrated instruction processing method includes but is not limited to the following S201 to S204 .

[0060] S201, obtain the first instruction, the second instruction and the execution information through the instruction fetch unit, the execution information is determined by the execution unit based on the execution order and the instruction fetch order, the execution order refers to the order in which the execution unit processes the third instruction and the fourth instruction, the instruction fetch order refers to the order in which the instruction fetch unit obtains the third instruction and the fourth instruction, the third instruction has the same instruction fetch address as the first instruction, and the fourth instruction has the same instruction fetch address as the second instruction.

[0061] The embodiment of the present application does not limit the types of the first instruction and the second instruction, and the types of the first instruction and the second instruction may be the same or different. For example, in one set of the first instruction and the second instruction, the first instruction may be a store-type instruction, and the second instruction may be a load-type instruction; in another set of the first instruction and the second instruction, both the first instruction and the second instruction may be load-type instructions.

[0062] The first instruction acquired by the instruction fetch unit and the third instruction processed by the execution unit last time are two instructions fetched according to the same instruction fetch address, and the instruction fetch address refers to the address of the unit storing each instruction in the storage space when the instruction fetch unit reads each instruction in the storage space for storing instructions. The same instruction fetch address is determined according to the PC value (e.g., the first PC) corresponding to the first instruction and the third instruction, and the contents of the first instruction and the third instruction may be the same or different.

[0063] Correspondingly, the second instruction obtained by the instruction fetch unit and the fourth instruction processed by the execution unit last time are two instructions obtained by fetching according to the same instruction fetch address. The same instruction fetch address is determined based on the PC values ​​corresponding to the second instruction and the fourth instruction (for example, the second PC). The contents of the second instruction and the fourth instruction may be the same or different.

[0064] Before the instruction fetch unit obtains the first instruction, the second instruction and the execution information, the execution unit must first generate the execution information, and therefore before that it also includes: obtaining the third instruction, the fourth instruction and the instruction fetch order through the execution unit; processing the third instruction and the fourth instruction respectively to obtain the execution order; generating the execution information according to the execution order and the instruction fetch order.

[0065] After the operands of the third instruction and the fourth instruction are prepared, the emission unit sends the third instruction and the fourth instruction to the execution unit, so that the execution unit can obtain the third instruction and the fourth instruction. The execution unit processes the third instruction and the fourth instruction in the order in which the third instruction and the fourth instruction are received to obtain the execution order of the third instruction and the fourth instruction.

[0066] In a possible implementation, the third instruction carries a first instruction fetch sequence number, which is the sequence number of the third instruction read by the instruction fetch unit from the storage space storing the instructions to be processed. The fourth instruction carries a second instruction fetch sequence number, which is the sequence number of the fourth instruction read by the instruction fetch unit from the storage space storing the instructions to be processed. The first instruction fetch sequence number may be the same as the first PC, and the second instruction fetch sequence number may be the same as the second PC. For example, if the third instruction is the fifth instruction to be processed read by the instruction fetch unit from the memory, then the first instruction fetch sequence number of the third instruction is 5, and if the fourth instruction is the sixth instruction to be processed read by the instruction fetch unit from the memory, then the second instruction fetch sequence number of the fourth instruction is 6.

[0067] In the process of processing the third instruction and the fourth instruction, the execution unit can obtain the first instruction fetch number carried by the third instruction and the second instruction fetch number carried by the fourth instruction, and determine the instruction fetch order of the third instruction and the fourth instruction according to the first instruction fetch number and the second instruction fetch number. Continuing with the above example, the first instruction fetch number is 5 and the second instruction fetch number is 6, then the instruction fetch order of the third instruction and the fourth instruction is the first instruction first and the second instruction later.

[0068] After the execution unit obtains the instruction fetching order and execution order of the third instruction and the fourth instruction, the execution unit generates execution information according to the instruction fetching order and the execution order. If the instruction fetching order and the execution order of the third instruction and the fourth instruction are the same, it can be determined that no speculative execution error occurs in the process of the execution unit processing the third instruction and the fourth instruction, the processing results of the execution unit on the third instruction and the fourth instruction are correct, and the generated execution information indicates that the execution order and the instruction fetching order of the third instruction and the fourth instruction are the same.

[0069] If the execution order and instruction fetch order of the third instruction and the fourth instruction are different, a speculative execution error may have occurred when the execution unit processes the third instruction and the fourth instruction. Therefore, the execution unit can determine whether a speculative execution error has occurred by judging whether the third instruction and the fourth instruction are related.

[0070] The method for the execution unit to determine whether the third instruction and the fourth instruction are correlated may be: based on the addresses accessed by the third instruction and the fourth instruction, determine whether the third instruction and the fourth instruction are correlated. The addresses accessed by the third instruction and the fourth instruction may be obtained during the process of the execution unit processing the third instruction and the fourth instruction. If the addresses accessed by the third instruction and the fourth instruction are the same, the third instruction and the fourth instruction are correlated; if the addresses accessed by the third instruction and the fourth instruction are different, the third instruction and the fourth instruction are not correlated.

[0071] In the embodiment of the present application, the address accessed by any instruction may be an address for reading data based on any instruction or an address for writing data based on any instruction. If the third instruction and the fourth instruction are correlated, the correlation between the third instruction and the fourth instruction may be that the third instruction and the fourth instruction satisfy any one of a RAW (Read After Write) relationship, a RAR (Read After Read) relationship, a (WAR, Write After Read) relationship, or a WAW (Write After Write) relationship.

[0072] Regardless of the relationship between the third instruction and the fourth instruction, the third instruction and the fourth instruction are correlated, and the execution order of the third instruction and the fourth instruction should be the same as the instruction fetch order. If the execution order of the correlated third instruction and the fourth instruction is different from the instruction fetch order, it means that a speculative execution error occurs in the processing of the third instruction and the fourth instruction, and the processing results of the third instruction and the fourth instruction may be erroneous results. In this case, the pipeline needs to be flushed and the third instruction and the fourth instruction need to be processed again to ensure that the processing results of the third instruction and the fourth instruction are correct.

[0073] In an embodiment of the present application, if the execution order and instruction fetch order of the third instruction and the fourth instruction are different, regardless of whether a speculative execution error occurs during the processing of the third instruction and the fourth instruction by the execution unit, the generated execution information can indicate that the execution order and the instruction fetch order are different.

[0074] Optionally, the content of the execution information generated for different third instructions, fourth instructions and execution situations is different. Below, taking situations 1 to 6 as examples, different contents of different execution information are exemplarily described. In situations 1 to 6, the third instruction comes first and the fourth instruction comes later in the instruction fetching order.

[0075] Case 1: The third instruction does not carry a tag instructing the issue unit to send the third instruction in the instruction fetch order.

[0076] In this case, if the execution order and the instruction fetch order are different, the execution information includes first missing information of the first tag. The first missing information can instruct the instruction fetch unit to add the first tag to the first instruction when it obtains the first instruction, that is, when it obtains the third instruction again or the instruction with the same instruction fetch address as the third instruction, so that when the emission unit sends the first instruction to the execution unit, it sends the first instruction in accordance with the instruction fetch order.

[0077] The embodiment of the present application does not limit the content of the first missing information. If the third instruction is a store type instruction, the first missing information may be a store miss; if the third instruction and the fourth instruction are both load type instructions, the first missing information may be a first load miss.

[0078] In case 1, if the execution order and the instruction fetch order are the same, the execution information may not be generated, or the generated execution information includes first completion information, and the first completion information indicates that the execution order in which the execution unit processes the third instruction and the fourth instruction is correct.

[0079] Case 2: The execution order and the instruction fetch order are different and the third instruction carries a third tag, and the third tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0080] In this case, the execution information includes first information indicating that the execution unit predicts success.

[0081] The third tag is determined by the instruction fetch unit according to the execution information generated after the execution unit last processed the third instruction or the instruction with the same instruction fetch address as the third instruction. The third instruction carries the third tag, which means that the execution unit predicted that the execution order and the instruction fetch order may be different in the process of processing the third instruction this time when the execution unit last processed the third instruction or the instruction with the same instruction fetch address as the third instruction. Therefore, if the third instruction carries the third tag, and the execution order and the instruction fetch order are indeed different in the process of the execution unit processing the third instruction and the fourth instruction, it means that the prediction of the execution unit is successful, and the generated execution information can include the first information indicating that the prediction of the execution unit is successful.

[0082] Exemplarily, if the third instruction is a store-type instruction, the first information may be a store hit; if the third instruction and the fourth instruction are both load-type instructions, the first information may be a first load hit.

[0083] Case 3: The execution order and the instruction fetch order are the same and the third instruction carries a third tag, and the third tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0084] In this case, the execution information includes second information indicating that the execution unit predicts a failure.

[0085] The third instruction carries a third tag, which indicates that the execution unit predicted that the execution order and the instruction fetching order may be different in the process of processing the third instruction this time when the execution unit processed the third instruction or the instruction with the same instruction fetching address as the third instruction last time. Therefore, if the third instruction carries the third tag, but the execution order and the instruction fetching order are the same in the process of processing the third instruction and the fourth instruction by the execution unit this time, it indicates that the prediction of the execution unit fails, and the generated execution information may include the second information indicating that the prediction of the execution unit fails.

[0086] Exemplarily, if the third instruction is a store-type instruction, the first information may be store mispred (mispredictions); if the third instruction and the fourth instruction are both load-type instructions, the first information may be first load mispred.

[0087] After executing the process described in any one of cases 1 to 3, the execution unit then executes the process described in any one of cases 4 to 6, or the execution unit may first execute the process described in any one of cases 4 to 6, and then execute the process described in any one of cases 1 to 3. Regardless of the order in which the execution unit generates the execution information, the generated execution information includes the execution information for the third instruction and the execution information for the fourth instruction.

[0088] Case 4: The fourth instruction does not carry a tag instructing the issue unit to send the fourth instruction according to the instruction fetch order.

[0089] In this case, if the execution order and the instruction fetch order are different, the execution information also includes second missing information of the second tag. The second missing information can instruct the instruction fetch unit to add a second tag to the second instruction when it obtains the second instruction, that is, when it obtains the fourth instruction again or an instruction with the same instruction fetch address as the fourth instruction, so that the emission unit sends the second instruction to the execution unit in accordance with the instruction fetch order the next time it sends the second instruction.

[0090] The embodiment of the present application does not limit the content of the second missing information. If the third instruction is a store type instruction and the fourth instruction is a load type instruction, the second missing information may be a load miss; if the third instruction and the fourth instruction are both load type instructions, the second missing information may be a second load miss.

[0091] In case 4, if the execution order and the instruction fetch order are the same, the execution information may not be generated, or the generated execution information includes the second completion information, and the first completion information indicates that the execution order in which the execution unit processes the third instruction and the fourth instruction is correct.

[0092] In one possible implementation, before generating the second missing information, the execution unit may determine whether the third instruction is correlated with the fourth instruction. If the third instruction is correlated with the fourth instruction, the second missing information is generated; if the third instruction is not correlated with the fourth instruction, the second missing information may not be generated.

[0093] Case 5: The execution order and the instruction fetch order are different and the fourth instruction carries a fourth tag, and the fourth tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0094] In this case, the execution information further includes third information indicating that the execution unit predicts success.

[0095] The fourth tag is determined by the instruction fetch unit according to the execution information generated after the execution unit last processed the fourth instruction or the instruction with the same instruction fetch address as the fourth instruction. The fourth instruction carries the fourth tag, which means that the execution unit predicted that the execution order and the instruction fetch order may be different in the process of processing the fourth instruction this time when the fourth instruction was processed or the instruction with the same instruction fetch address as the fourth instruction last time. Therefore, if the fourth instruction carries the fourth tag, and the execution order and the instruction fetch order are indeed different in the process of the execution unit processing the third instruction and the fourth instruction this time, it means that the prediction of the execution unit is successful, and the generated execution information can include the third information indicating that the prediction of the execution unit is successful.

[0096] Exemplarily, if the third instruction is a store type instruction and the fourth instruction is a load type instruction, the third information may be a load hit; if the third instruction and the fourth instruction are both load type instructions, the third information may be a second load hit.

[0097] In one possible implementation, before generating the third information, the execution unit may determine whether the third instruction is correlated with the fourth instruction. If the third instruction is correlated with the fourth instruction, the third information is generated; if the third instruction is not correlated with the fourth instruction, the third information may not be generated.

[0098] Case 6: The execution order and the instruction fetch order are the same and the fourth instruction carries a fourth tag, and the fourth tag indicates that the execution unit predicts that the instruction fetch order and the execution order are different.

[0099] In this case, the execution information further includes fourth information indicating that the execution unit predicts failure.

[0100] The second instruction carries the fourth tag, which indicates that the execution unit predicted that the execution order and the instruction fetching order may be different in the process of processing the fourth instruction this time when the execution unit processed the fourth instruction or the instruction with the same instruction fetching address as the fourth instruction last time. Therefore, if the fourth instruction carries the fourth tag, but the execution order and the instruction fetching order are the same in the process of processing the third instruction and the fourth instruction by the execution unit this time, it indicates that the prediction of the execution unit failed, and the generated execution information may include the fourth information indicating that the execution unit failed to predict.

[0101] Exemplarily, if the third instruction is a store type instruction and the fourth instruction is a load type instruction, the fourth information may be load mispred; if the third instruction and the fourth instruction are both load type instructions, the fourth information may be second load mispred.

[0102] In one possible implementation, before generating the fourth information, the execution unit may determine whether the third instruction is correlated with the fourth instruction. If the third instruction is correlated with the fourth instruction, the fourth information is generated; if the third instruction is not correlated with the fourth instruction, the fourth information may not be generated.

[0103] For example, see Figure 3 , showing a flow chart of determining execution information according to a third instruction provided by an embodiment of the present application. The execution unit determines whether the third instruction carries a tag. If the third instruction carries a tag, it continues to determine whether a speculative execution error occurs. If so, the execution information includes first information indicating that the third instruction hits; if not, the execution information includes second information indicating that the third instruction is mispredicted. If the third instruction does not carry a tag, it continues to determine whether a speculative execution error occurs. If so, the execution information includes first missing information indicating that the first tag of the third instruction is missing; if not, the execution information includes first completion information.

[0104] For example, see Figure 4 , showing a flow chart of determining execution information according to a fourth instruction. The execution unit determines whether the fourth instruction carries a tag. If the fourth instruction carries a tag, it continues to determine whether the address is the same as the address of the third instruction in which a speculative execution error occurs. If so, the execution information includes third information indicating that the fourth instruction hits; if not, the execution information includes fourth information indicating that the fourth instruction is mispredicted. If the third instruction does not carry a tag, it continues to determine whether the address is the same as the address of the third instruction in which a speculative execution error occurs. If so, the execution information includes second missing information indicating that a second tag of the fourth instruction is missing; if not, the execution information includes second completion information.

[0105] In an exemplary embodiment, the execution information may further include the first PC of the third instruction and the second PC of the fourth instruction, as well as the type of the third instruction and the type of the fourth instruction, so that the instruction fetch unit can more accurately process the instruction with the same instruction fetch address as the third instruction and the instruction with the same instruction fetch address as the fourth instruction according to the first PC of the third instruction, the second PC of the fourth instruction, the type of the third instruction and the type of the fourth instruction.

[0106] In addition, the retirement unit may also write the third instruction and the fourth instruction back to the storage space storing the instructions to be processed.

[0107] It should be noted that the process in which the above-mentioned execution unit obtains the third instruction, the fourth instruction and the instruction fetch order, and processes the third instruction and the fourth instruction and generates execution information is the process before the instruction fetch unit obtains the third instruction, the fourth instruction and the execution information in S201, that is, the execution information obtained by the instruction fetch unit in S201 is the execution information generated after the execution unit processed the third instruction and the fourth instruction last time.

[0108] After the execution unit generates the execution information, it can send the execution information to the instruction fetch unit. Optionally, the processing device can also include a retirement unit, which is connected to the instruction fetch unit and the execution unit respectively, and the execution unit can send the execution information to the retirement unit, and the retirement unit sends the execution information to the instruction fetch unit, so that the instruction fetch unit obtains the execution information.

[0109] After the instruction fetch unit obtains the execution information, it can read the first instruction and the second instruction in the storage space storing the instructions to be processed according to the instruction fetch address of the first instruction indicated by the first PC and the instruction fetch address of the second instruction indicated by the second PC in the execution information, thereby obtaining the first instruction and the second instruction.

[0110] In another possible implementation, before the instruction fetch unit reads the first instruction and the second instruction for the first time, since the PC of each instruction to be processed is incremented (for example, the second PC of the second instruction is the first PC+1 of the first instruction), the instruction fetch unit can start from the PC of the first instruction to be processed, and read each instruction stored in the storage space in sequence according to the incremented PC until the first instruction and the second instruction are read, thereby obtaining the first instruction and the second instruction.

[0111] S202: Sending, through the instruction fetch unit, a first instruction carrying a first tag and a second instruction carrying a second tag to the emission unit when the execution information indicates that the execution order and the instruction fetch order are different.

[0112] If the execution information indicates that the execution order and the instruction fetch order are different, which means that the third instruction and the fourth instruction have experienced speculative execution errors, the instruction fetch unit can send a first instruction carrying a first tag and a second instruction carrying a second tag to the emission unit, so that the emission unit can emit the first instruction and the second instruction in the instruction fetch order according to the first tag and the second tag.

[0113] Before the instruction fetch unit sends the first instruction carrying the first tag and the second instruction carrying the second tag, the instruction fetch unit can obtain the first instruction carrying the first tag and the second instruction carrying the second tag. Exemplarily, the instruction fetch unit can determine the first value based on the execution information; when the first value is greater than or equal to the threshold, the first instruction carrying the first tag and the second instruction carrying the second tag are obtained.

[0114] The embodiment of the present application does not limit the method for determining the first value based on the execution information. Optionally, the first value is determined based on the execution information, including: when the execution information indicates that the execution order is different from the processing order, the second value is determined as the threshold; when the address accessed by the second instruction is the same as that accessed by the first instruction, the second value is added to the third value to obtain the first value, and the third value is a positive number; when the address accessed by the second instruction is different from that accessed by the first instruction, the fourth value is subtracted from the second value to obtain the first value, and the fourth value is a positive number.

[0115] If the execution information indicates that the execution order and instruction fetch order of the third instruction and the fourth instruction are different, it means that the execution unit may want the transmitting unit to send the first instruction and the second instruction according to the instruction fetch order. Therefore, the second value can be determined as the threshold, and the second value can be adjusted based on the second value to determine the final first value.

[0116] Based on the foregoing description, it can be known that the content of the execution information that can indicate different execution orders and instruction fetch orders is different, and thus the first value determined according to different execution information may also be different.

[0117] For example, see Figure 5 , showing a schematic diagram of a prediction table entry provided in an embodiment of the present application. The instruction fetch unit will complete the writing and reading of the prediction table entry according to the execution information. Writing table entries includes creating table entries and updating table entries. Creating table entries mainly creates a new table entry based on the execution information. The information in the table entry includes: a set of first PC, second PC and 2-bit (bit) saturation counter values ​​(i.e., first numerical values) where a speculative execution error occurs. Updating table entries mainly updates the saturation counter in the table entry according to the update logic and execution information. The embodiment of the present application does not limit the number of table entries, for example, it can be 12. The number of table entries can be determined based on the size of the space used by the instruction fetch unit to store table entries, or it can be set based on experience.

[0118] Reading a table entry means comparing the PC of the current instruction with the PC stored in all table entries through comparison logic. If the PC matches successfully and the counter in the table entry is saturated (greater than or equal to the threshold), the current instruction will be marked.

[0119] Among them, see Figure 6 , a possible creation and update rule of the value of a 2-bit saturation counter is as follows:

[0120] If the table entries stored in the instruction fetch unit do not include a table entry corresponding to both the first PC and the second PC, the instruction fetch unit creates a table entry corresponding to both the first PC and the second PC, and the value of the saturation counter in the table entry is an initial value, which may be 00, for example.

[0121] If the table entries stored in the instruction fetch unit include table entries corresponding to the first PC and the second PC, the instruction fetch unit determines the table entry corresponding to the first PC and the second PC in the stored table entries, and reads the value of the saturation counter in the table entry. At this time, the value of the saturation counter in the table entry is the first numerical value determined by the instruction fetch unit for the execution status of the instruction corresponding to the first PC and the second PC at the last time.

[0122] After determining the value of the saturation counter in the table entry corresponding to both the first PC and the second PC, the value of the saturation counter in the table entry is updated according to the execution information.

[0123] When judging whether the third instruction misses or hits, the value of the saturated counter (the second value) is set to 10 (set to saturation) regardless of the value of the saturated counter in the table entry; when judging whether the third instruction mispreds or is processed, the value of the saturated counter (the second value) is set to 00 regardless of the value of the saturated counter in the table entry. After determining the second value, continue to update the second value according to the execution information to determine the first value. When judging whether the fourth instruction hits or misses, and the fourth instruction is related to the third instruction, the value of the saturated counter is incremented by 1 (the third value) to obtain the first value; when judging whether the fourth instruction mispreds or is processed, the value of the saturated counter is decremented by 1 (the fourth value) to obtain the first value.

[0124] For example, for a table entry corresponding to a third instruction and a fourth instruction of a group of load types, when the table entry is created, the value of the saturation counter in the table entry is the initial value 00. If the execution information indicates that the third instruction lacks the first mark, that is, the third instruction of the load type is judged to be miss (first load miss, FMI), the value of the saturation counter is set to saturation and becomes 10. If in this case, it is judged that the fourth instruction of the load type misses (second load miss, SMI) or the fourth instruction of the load type hits (second load hit, SHI), then the value of the saturation counter is 10 and incremented by 1, and the value of the saturation counter becomes 11; and if the fourth instruction of the load type is mispred (second load mispred, SMS), then the value of the saturation counter is 10 and decremented by 1, and the value of the saturation counter becomes 01.

[0125] After determining the first numerical value, if the value of the saturation counter is in an unsaturated state, that is, the first numerical value is less than the threshold value, the first instruction and the second instruction are not marked. If the value of the saturation counter is in a saturated state, that is, the first numerical value is greater than or equal to the threshold value, the first instruction and the second instruction are marked to obtain a first instruction carrying the first mark and a second instruction carrying the second mark. The embodiment of the present application does not limit the contents of the first mark and the second mark. For example, the first mark can be the first instruction fetch number of the first instruction, and the second mark can be the second instruction fetch number of the second instruction, or the first mark can be a binary, octal or decimal number that is less than the second mark.

[0126] Optionally, the instruction fetch unit includes a prediction subunit (or predictor, dynamic predictor), and the method of writing table entries, reading table entries, and obtaining a first instruction carrying a first tag and a second instruction carrying a second tag according to execution information can be executed by the prediction subunit.

[0127] S203: Sending, through the issuing unit, the first instruction carrying the first tag and the second instruction carrying the second tag to the executing unit in the instruction fetching order based on the first tag and the second tag.

[0128] After the transmitting unit receives the first instruction carrying the first tag and the second instruction carrying the second tag, it determines that the first instruction is correlated with the second instruction according to the first tag and the second tag, and sends the first instruction carrying the first tag and the second instruction carrying the second tag to the executing unit in the instruction fetching order, so that the order in which the executing unit receives the first instruction carrying the first tag and the second instruction carrying the second tag is the same as the instruction fetching order, so that the executing unit processes the first instruction carrying the first tag and the second instruction carrying the second tag respectively in the instruction fetching order.

[0129] After processing the first instruction carrying the first tag and the second instruction carrying the second tag, the execution unit obtains a new execution order, and generates new execution information according to the new execution order and instruction fetch order.

[0130] Since the first instruction carries a first tag, the second instruction carries a second tag, and the new execution order is the same as the instruction fetch order, no speculative execution error occurs during the processing of the first instruction carrying the first tag and the second instruction carrying the second tag, and thus the new execution information includes fifth information and sixth information, and the fifth information and sixth information indicate that the execution unit failed to predict the execution status of the first instruction carrying the first tag and the second instruction carrying the second tag.

[0131] Through the instruction processing method provided in the embodiment of the present application, the execution status of the first instruction and the second instruction is predicted and marked, so that the execution unit processes the first instruction carrying the first mark and the second instruction carrying the second mark in the correct order, and the obtained processing result is accurate, avoiding causing the processing device to flush the pipeline, reducing resource waste, and improving the efficiency of instruction processing.

[0132] In another exemplary embodiment, if the first instruction carries a first tag but the second instruction does not carry a second tag, or the second instruction carries a second tag but the first instruction does not carry the first tag, or both the first instruction and the second instruction do not carry a tag indicating that the emission unit sends the first instruction and the second instruction in the instruction fetch order, the emission unit may send the first instruction and the second instruction not in the instruction fetch order, but in the order of obtaining the operands of the first instruction and the second instruction.

[0133] For example, if the transmitting unit first obtains the operand of the first instruction and then obtains the operand of the second instruction, the transmitting unit may send the first instruction first and then send the second instruction; and if the transmitting unit first obtains the operand of the second instruction and then obtains the operand of the first instruction, the transmitting unit may send the second instruction first and then send the first instruction.

[0134] In some cases, no matter in which order the transmitting unit sends the first instruction and the second instruction, and no matter whether the first instruction and the second instruction carry tags, during the time between when the transmitting unit sends the first instruction and the second instruction, the transmitting unit may send other instructions that are not related to the first instruction and the second instruction to the execution unit.

[0135] In an embodiment of the present application, instructions are marked according to execution information, so that whether two instructions are related can be determined in the instruction fetch stage and the emission stage, and the two related instructions are emitted in the correct order in the emission stage, avoiding the wrong access order and conflict between the two related instructions to the same address, avoiding pipeline flushing, achieving performance optimization of the processing device, and improving the overall instruction processing efficiency of the processing device.

[0136] S204, processing the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction receiving order through the execution unit, and the instruction receiving order is the same as the instruction fetching order.

[0137] Since the first instruction carrying the first tag and the second instruction carrying the second tag will not be out of order during the transmission from the emission unit to the execution unit, the instruction reception order of the first instruction carrying the first tag and the second instruction carrying the second tag received by the execution unit is the same as the order in which the emission unit sends the two instructions. In addition, because the execution unit processes the two instructions respectively in the order in which the two instructions are received, and the emission unit transmits the two instructions in the order in which the two instructions are fetched, the execution order of the two instructions by the execution unit is the same as the instruction fetch order, thereby ensuring that the processing results of the two instructions are correct.

[0138] The above describes the various steps of the instruction processing method provided by the embodiment of the present application. Through the instruction processing method, the correlation between the first instruction and the second instruction can be determined during the process of the processing device processing the instruction, and the execution status of the first instruction and the second instruction can be predicted based on the correlation between the first instruction and the second instruction and the historical execution status of the instruction. If there is no correlation between the first instruction and the second instruction, the emission unit is allowed to emit the first instruction and the second instruction sequentially or out of order. If there is a correlation between the first instruction and the second instruction, the emission unit ensures that the first instruction and the second instruction are emitted sequentially, thereby ensuring that the execution unit processes the first instruction and the second instruction sequentially.

[0139] Next, taking the example where the first instruction is a store type instruction, the second instruction is a load type instruction, and the first instruction is fetched before the second instruction, the complete process of the instruction processing method provided in the embodiment of the present application is exemplified.

[0140] See also Figure 7 A schematic diagram of the structure of a processing device provided by an embodiment of the present application is shown. After the processing device is reset and released, the third instruction and the fourth instruction enter the LSU (Load Store Unit) of the execution unit. If a speculative execution error occurs between the third instruction and the fourth instruction, and the third instruction does not carry the third tag, a first missing information is generated, and the third instruction is marked as a "store miss" state through the first missing information, indicating that the third instruction should have been marked as an instruction that may have a speculative execution error, but the tag is missing (this is because the third instruction has not been processed by the execution unit before), and a speculative execution error has occurred. If the fourth instruction accesses the same address as the third instruction, the fourth instruction is correlated with the third instruction, and the fourth instruction does not carry the fourth tag, a second missing information is generated, and the fourth instruction is marked as a "load miss" state through the second missing information, indicating that the fourth instruction should have been marked as an instruction that may have a speculative execution error, but the tag is missing.

[0141] The LSU transmits the execution information including the first missing information and the second missing information as well as the third instruction and the fourth instruction to the RTU (Retire Unit). The RTU transmits the first PC, the second PC and the execution information to the IFU (Instruction Fetch Unit).

[0142] When the prediction subunit (raw_pred) in the IFU receives the first PC, the second PC and the execution information, the first PC and the second PC are written into the table entry corresponding to the first PC and the second PC. Since the execution information includes the first missing information and the second missing information, the first value of the saturation counter in the table entry is greater than the threshold.

[0143] When the instruction fetch PC matches the first PC or the second PC in the table entry, the prediction subunit marks the first instruction and the second instruction currently read according to the first value of the saturation counter in the table entry to obtain the first instruction carrying the first tag and the second instruction carrying the second tag. After receiving the first instruction carrying the first tag and the second instruction carrying the second tag, the emission unit sequentially emits the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction fetch order, that is, the first instruction carrying the first tag is emitted first, and then the second instruction carrying the second tag is emitted.

[0144] The LSU processes the instructions in the order of receiving the first instruction with the first tag and the second instruction with the second tag, and obtains the execution information. After the prediction is completed, the RTU feeds back the first PC, the second PC and the execution information to the instruction fetch unit, and the instruction fetch unit updates the table corresponding to the first PC and the second PC.

[0145] An instruction dependency prediction logic loop is formed through the IFU, the emission unit, the LSU and the RTU, and the dependency between the first instruction and the second instruction is predicted during the instruction fetch process, thereby reducing the overhead caused by pipeline flushing due to speculative execution.

[0146] To summarize, when the execution information indicates that the execution order and the instruction fetch order are different, a first instruction carrying a first tag and a second instruction carrying a second tag are sent to the emission unit, so that the emission unit sends the first instruction carrying the first tag and the second instruction carrying the second tag to the execution unit according to the instruction fetch order indicated by the first tag and the second tag, so that the order in which the execution unit receives the first instruction carrying the first tag and the second instruction carrying the second tag can be the same as the instruction fetch order, and the execution unit processes the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction fetch order. Therefore, in the present application, for instructions corresponding to a group of instruction fetch addresses, there will only be one execution order error, and the number of pipeline flushes based on instructions corresponding to a group of instruction fetch addresses is at most once, which reduces the possibility of flushing the pipeline, improves instruction processing efficiency and reduces resource waste caused by flushing the pipeline.

[0147] Specifically, the instruction processing method provided in the embodiment of the present application can record the execution status of the instructions corresponding to the PC, judge and predict the current state corresponding to the PC based on the execution information, reduce the probability of correlation errors occurring in the PC, and improve the IPC (Instruction Per Cycle, the number of instructions executed per cycle) of the processor. By reducing the number of times the pipeline is flushed, the CPI (Clock Cycle Per Instruction, the number of cycles required to execute an instruction) of the processing device is increased, thereby improving the efficiency of instruction processing.

[0148] If the instruction processing method provided in the embodiment of the present application is applied to a multi-pipeline or superscalar multi-core processing device, the instruction processing efficiency can be improved more significantly.

[0149] In an exemplary embodiment, the present application also provides a processing device. Figure 1The structural schematic diagram of the device shown in the figure, the device includes an instruction fetch unit 11, an execution unit 13 and a transmitting unit 12, and the transmitting unit 12 is connected to the instruction fetch unit 11 and the execution unit 13 respectively; the instruction fetch unit 11 is used to obtain a first instruction, a second instruction and execution information, and the execution information is determined by the execution unit 13 based on the execution order and the instruction fetch order, the execution order refers to the order in which the execution unit 13 processes the third instruction and the fourth instruction, and the instruction fetch order refers to the order in which the instruction fetch unit 11 obtains the third instruction and the fourth instruction, the instruction fetch addresses corresponding to the third instruction and the first instruction are the same, and the instruction fetch addresses corresponding to the fourth instruction and the second instruction are the same; when the execution information indicates that the execution order and the instruction fetch order are different, the first instruction carrying the first tag and the second instruction carrying the second tag are sent to the transmitting unit 12; the transmitting unit 12 is used to send the first instruction carrying the first tag and the second instruction carrying the second tag to the execution unit 13 according to the instruction fetch order based on the first tag and the second tag; the execution unit 13 processes the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction reception order, and the instruction reception order is the same as the instruction fetch order.

[0150] In a possible implementation, the execution unit 13 is further configured to obtain the third instruction, the fourth instruction and the instruction fetching order; process the third instruction and the fourth instruction respectively to obtain the execution order; and generate execution information according to the execution order and the instruction fetching order.

[0151] In a possible implementation, when the execution order and the instruction fetch order are different, the execution information includes first missing information of the first tag.

[0152] In one possible implementation, when the execution order and the instruction fetch order are different and the third instruction carries a third tag, the execution information includes first information indicating that the execution unit 13 predicts successfully, and the third tag indicates that the execution unit 13 predicts that the instruction fetch order and the execution order are different.

[0153] In one possible implementation, when the execution order and the instruction fetch order are the same and the third instruction carries a third tag, the execution information includes second information indicating that the execution unit 13 predicts a failure, and the third tag indicates that the execution unit 13 predicts that the instruction fetch order and the execution order are different.

[0154] In a possible implementation, when the execution order and the instruction fetch order are different, the execution information further includes second missing information of the second tag.

[0155] In one possible implementation, when the execution order and the instruction fetch order are different and the fourth instruction carries a fourth tag, the execution information also includes third information indicating that the execution unit 13 predicts successfully, and the fourth tag indicates that the execution unit 13 predicts that the instruction fetch order and the execution order are different.

[0156] In one possible implementation, when the execution order and the instruction fetch order are the same and the fourth instruction carries a fourth tag, the execution information also includes fourth information indicating that the execution unit 13 predicts a failure, and the fourth tag indicates that the execution unit 13 predicts that the instruction fetch order and the execution order are different.

[0157] In a possible implementation, the instruction fetch unit 11 is further configured to determine a first value according to the execution information; and when the first value is greater than or equal to a threshold, obtain a first instruction carrying a first tag and a second instruction carrying a second tag.

[0158] In one possible implementation, the instruction fetch unit 11 is used to determine the second value as the threshold when the execution information indicates that the execution order is different from the processing order; when the address accessed by the second instruction is the same as that accessed by the first instruction, add the third value to the second value to obtain the first value, and the third value is a positive number; when the address accessed by the second instruction is different from that accessed by the first instruction, subtract the fourth value from the second value to obtain the first value, and the fourth value is a positive number.

[0159] In a possible implementation manner, the first instruction and the second instruction satisfy any one of a read-after-write relationship, a read-after-read relationship, a write-after-read relationship, or a write-after-write relationship.

[0160] It should be noted that the device provided in the above embodiment only uses the division of the above functional modules as an example to implement its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and their specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0161] In an exemplary embodiment, a computer device is also provided, which can implement the instruction processing methods provided in the above-mentioned various method embodiments. The computer device can be, for example, a smart phone, a tablet computer, a player, a laptop computer or a desktop computer. The terminal may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names. The computer device can also be a server or any other device that can implement the instruction processing methods described above.

[0162] See also Figure 8 , shows a schematic diagram of the structure of a computer device provided in an embodiment of the present application, wherein the computer device 800 includes a processing device 801, which may be the processing device provided in the above embodiment, and the processing device 801 includes: Figure 1 The fetch unit 11, the issue unit 12 and the execution unit 13 are shown. Figure 8 In the embodiment, the processing device 801 is coupled to the memory 802, and it should be understood that the computer device 800 also supports other memory configurations known in the art.

[0163] The memory 802 may include one or more computer-readable storage media, which may be non-transitory. The computer-readable storage medium stores at least one computer program, which is loaded and executed by the processing device 801 to enable the computer device 800 to implement any of the above-mentioned instruction processing methods.

[0164] The memory 802 may also include a high-speed random access memory and a non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 802 is used to store at least one instruction, and the at least one instruction is used to be executed by the processing device 801 so that the computer device 800 implements the instruction processing method provided by the above method embodiment.

[0165] In one possible implementation, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0166] Figure 8 Also shown is a display 806 coupled to the processing device 801. In some cases, the computer device 800 can be used for wireless communication. Figure 8 Also shown are a speaker 809 and a microphone 810 coupled to the processing device 801 via a codec 811 ; and a wireless antenna 808 coupled to the wireless controller 805 .

[0167] The display 806 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos and any combination thereof. When the display 806 is a touch display screen, the display 806 also has the ability to collect touch signals on the surface or above the surface of the display 806. At this time, the display 806 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display 806 can be one, set on the front panel of the terminal; in other embodiments, the display 806 can be at least two, respectively set on different surfaces of the terminal or in a folding design; in other embodiments, the display 806 can be a flexible display screen, set on a curved surface or a folding surface of the terminal. Even, the display 806 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display 806 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode) and the like.

[0168] Microphone 810 is used to collect sound waves from the user and the environment, and input the sound waves to the processing device 801 for processing. For the purpose of stereo sound collection or noise reduction, there can be multiple microphones 810, which are respectively arranged at different parts of the terminal. Microphone 810 can also be an array microphone or an omnidirectional collection microphone. Speaker 809 is used to convert electrical signals from processing device 801 into sound waves. Speaker 809 can be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging.

[0169] The processing device 801 and the memory 802 may be included in a system-in-package or system-on-chip device.

[0170] Input device 807 and power supply 803 are coupled to system-on-chip device 812. Optionally, as Figure 8 As shown, when one or more optional blocks are present, the display 806, input device 807, speaker 809, microphone 810, wireless antenna 808, and power supply 803 are external to the system-on-chip device 812. However, each of the display 806, input device 807, speaker 809, microphone 810, wireless antenna 808, and power supply 803 may be coupled to a component of the system-on-chip device 812, such as an interface or controller.

[0171] The power supply 803 is used to power various components in the terminal. The power supply 803 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 803 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0172] In one possible implementation, the processing device 801 and the memory 802 may be integrated into a set-top box, a server, a music player, a video player, an entertainment unit, a navigation device, a personal digital assistant (PDA), a fixed location data unit, a computer, a laptop computer, a tablet computer, a communication device, a mobile phone, or other similar devices.

[0173] The method described in conjunction with the embodiments of the present application can be directly implemented in a software module executed by a processing device. The software module can reside in a random access memory (Random Access Memory, RAM) memory, a flash memory, a read-only memory (Read Only Memory, ROM) memory, an electrically programmable read-only memory (ErasableProgrammable Read Only Memory, EPROM) memory, an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM) memory, a register, a hard disk, a removable disk, a compact disc read-only memory (Compact Disc Read-Only Memory, CDROM) or any other form of storage medium known in the art. The storage medium is coupled to the processing device so that the processing device can read information from the storage medium and write information to the storage medium. Optionally, the storage medium can be integrated with the processing device.

[0174] Those skilled in the art will understand that Figure 8 The structure shown in the figure does not constitute a limitation on the computer device. The computer device may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0175] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any of the above instruction processing methods.

[0176] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the instructions involved in this application are all obtained with full authorization.

[0177] It should be noted that the terms "first", "second", etc. in the embodiments of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application described here can be implemented in various orders.

[0178] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0179] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A processing device, characterized in that: The processing device comprises an instruction fetch unit, an execution unit and a transmission unit, wherein the transmission unit is connected to the instruction fetch unit and the execution unit respectively; The instruction fetch unit is used to obtain a first instruction, a second instruction and execution information, wherein the execution information is determined by the execution unit based on an execution order and an instruction fetch order, wherein the execution order refers to a sequence in which the execution unit processes a third instruction and a fourth instruction, and the instruction fetch order refers to a sequence in which the instruction fetch unit obtains the third instruction and the fourth instruction, wherein the third instruction has the same instruction fetch address as the first instruction, and the fourth instruction has the same instruction fetch address as the second instruction; The instruction fetch unit is further configured to send a first instruction carrying a first tag and a second instruction carrying a second tag to the transmitting unit when the execution information indicates that the execution order is different from the instruction fetch order; The transmitting unit is configured to send the first instruction carrying the first tag and the second instruction carrying the second tag to the executing unit in the instruction fetching order based on the first tag and the second tag; The execution unit is used to process the first instruction carrying the first tag and the second instruction carrying the second tag according to the instruction receiving order, and the instruction receiving order is the same as the instruction fetching order.

2. The device according to claim 1, characterized in that The execution unit is further used to obtain the third instruction, the fourth instruction and the instruction fetching order; process the third instruction and the fourth instruction respectively to obtain the execution order; and generate the execution information according to the execution order and the instruction fetching order.

3. The device according to claim 2, characterized in that In a case where the execution order and the instruction fetch order are different, the execution information includes first missing information of the first tag.

4. The device according to claim 2, characterized in that When the execution order is different from the instruction fetch order and the third instruction carries a third tag, the execution information includes first information indicating that the execution unit predicts successfully, and the third tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

5. The device according to claim 2, characterized in that When the execution order is the same as the instruction fetch order and the third instruction carries a third tag, the execution information includes second information indicating that the execution unit predicts a prediction failure, and the third tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

6. The device according to any one of claims 3 to 5, characterized in that: In a case where the execution order is different from the instruction fetch order, the execution information further includes second missing information of the second tag.

7. The device according to any one of claims 3 to 5, characterized in that: When the execution order is different from the instruction fetch order and the fourth instruction carries a fourth tag, the execution information further includes third information indicating that the execution unit predicts successfully, and the fourth tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

8. The device according to any one of claims 3 to 5, characterized in that: When the execution order is the same as the instruction fetch order and the fourth instruction carries a fourth tag, the execution information further includes fourth information indicating that the execution unit predicts a prediction failure, and the fourth tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

9. The device according to claim 1, characterized in that The instruction fetch unit is further configured to determine a first value according to the execution information; and when the first value is greater than or equal to a threshold, obtain the first instruction carrying the first tag and the second instruction carrying the second tag.

10. The device according to claim 9, characterized in that The instruction fetch unit is configured to, when the execution information indicates that the execution order is different from the processing order, determine a second value as the threshold; when the second instruction accesses the same address as the first instruction, add a third value to the second value to obtain the first value, wherein the third value is a positive number; In the case where the second instruction accesses a different address than the first instruction, the first value is obtained by subtracting a fourth value from the second value, and the fourth value is a positive number.

11. The device according to claim 1, characterized in that The first instruction and the second instruction satisfy any one of a read-after-write relationship, a read-after-read relationship, a write-after-read relationship, or a write-after-write relationship.

12. A method for processing an instruction, characterized in that: The method is applied to a processing device, the processing device includes an instruction fetch unit, an execution unit and a transmission unit, the transmission unit is connected to the instruction fetch unit and the execution unit respectively, and the method includes: Obtaining, by the instruction fetch unit, a first instruction, a second instruction and execution information, wherein the execution information is determined by the execution unit based on an execution order and an instruction fetch order, wherein the execution order refers to a sequence in which the execution unit processes a third instruction and a fourth instruction, and the instruction fetch order refers to a sequence in which the instruction fetch unit obtains the third instruction and the fourth instruction, wherein the third instruction has the same instruction fetch address as the first instruction, and the fourth instruction has the same instruction fetch address as the second instruction; Sending, by the instruction fetch unit, a first instruction carrying a first tag and a second instruction carrying a second tag to the transmitting unit when the execution information indicates that the execution order and the instruction fetch order are different; Sending, by the issuing unit, the first instruction carrying the first tag and the second instruction carrying the second tag to the executing unit in the instruction fetching order based on the first tag and the second tag; The first instruction carrying the first tag and the second instruction carrying the second tag are processed by the execution unit according to an instruction receiving order, and the instruction receiving order is the same as the instruction fetching order.

13. The method according to claim 12, characterized in that Before obtaining the first instruction, the second instruction and the execution information through the instruction fetch unit, the method further includes: Obtaining, by the execution unit, the third instruction, the fourth instruction and the instruction fetching order; Processing the third instruction and the fourth instruction respectively by the execution unit to obtain the execution order; The execution information is generated by the execution unit according to the execution order and the instruction fetch order.

14. The method according to claim 13, characterized in that In a case where the execution order and the instruction fetch order are different, the execution information includes first missing information of the first tag.

15. The method according to claim 13, characterized in that When the execution order is different from the instruction fetch order and the third instruction carries a third tag, the execution information includes first information indicating that the execution unit predicts successfully, and the third tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

16. The method according to claim 13, characterized in that When the execution order is the same as the instruction fetch order and the third instruction carries a third tag, the execution information includes second information indicating that the execution unit predicts a prediction failure, and the third tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

17. The method according to any one of claims 14 to 16, characterized in that: In a case where the execution order is different from the instruction fetch order, the execution information further includes second missing information of the second tag.

18. The method according to any one of claims 14 to 16, characterized in that: When the execution order is different from the instruction fetch order and the fourth instruction carries a fourth tag, the execution information further includes third information indicating that the execution unit predicts successfully, and the fourth tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

19. The method according to any one of claims 14 to 16, characterized in that: When the execution order is the same as the instruction fetch order and the fourth instruction carries a fourth tag, the execution information further includes fourth information indicating that the execution unit predicts a prediction failure, and the fourth tag indicates that the execution unit predicts that the instruction fetch order is different from the execution order.

20. The method according to claim 12, characterized in that Before sending, by the instruction fetch unit, the first instruction carrying the first tag and the second instruction carrying the second tag to the transmitting unit when the execution information indicates that the execution order and the instruction fetch order are different, the method further includes: Determining, by the instruction fetch unit, a first value according to the execution information; The first instruction carrying the first tag and the second instruction carrying the second tag are acquired by the instruction fetch unit when the first value is greater than or equal to a threshold.

21. The method according to claim 20, characterized in that The step of determining, by the instruction fetch unit, a first value according to the execution information includes: By means of the instruction fetch unit, when the execution information indicates that the execution order is different from the processing order, determining a second value as the threshold; By means of the instruction fetch unit, when the second instruction accesses the same address as the first instruction, adding a third value to the second value to obtain the first value, wherein the third value is a positive number; Through the instruction fetch unit, when the second instruction and the first instruction access different addresses, a fourth value is subtracted from the second value to obtain the first value, and the fourth value is a positive number.

22. The method according to claim 12, characterized in that The first instruction and the second instruction satisfy any one of a read-after-write relationship, a read-after-read relationship, a write-after-read relationship, or a write-after-write relationship.

23. A computer device, characterized in that: The computer device includes a processor and a memory, wherein at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor so that the computer device implements the instruction processing method according to any one of claims 12 to 22.

24. A computer-readable storage medium, characterized in that: At least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by the processor so that the computer implements the instruction processing method according to any one of claims 12 to 22.

Citation Information

Cited By

  • Processor instruction reading control method and system and electronic equipment

    CN120743353A