Storage sequence violation processing method and device, electronic equipment and medium
By using the load instruction to reorder queue in the processor to determine the first violation instruction of the storage order violation and execute instructions in the subsequent programs out of order, the power consumption waste caused by the storage order violation is solved and the processor performance is improved .
Patent Information
- Application Number
- CN202411042809.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2024-12-03
AI Technical Summary
When an existing processor detects a storage order violation, it will start to execute out of order again from the next instruction of the storage instruction in the program, resulting in an increase in the instruction spacing between the storage instruction and the load instruction, causing success and waste, and affecting the Processor performance.
By determining all violation instructions associated with the instruction to be executed in the load instruction reorder queue, and determining the first violation instruction from it, the instructions to be executed out of order are performed on the subsequent programs, thereby avoiding wasting the correct instructions that have been executed. Reduce power consumption and improve processor performance.
Accurately determine the initial instruction of program execution errors caused by storage order violations and starts to re-execute from the instruction, avoiding the waste of the correct program executed, realizing the handling of storage order violations, reducing power consumption and improving Processor performance.
Smart Images

Figure CN119065717A_ABST
Abstract
Description
[0001] This patent application is a divisional application of the Chinese patent application with application number 202311872930.1, application date December 29, 2023, and application name "Storage order violation processing method, device, electronic device and medium". Technical Field
[0002] The present application relates to computer technology, and in particular to a storage order violation processing method, device, electronic device and medium. Background Art
[0003] There are two types of processor execution modes: sequential execution and out-of-order execution. Sequential execution means executing in the order of instruction fetching of the Program Counter (PC). However, in the case of sequential execution, once an instruction dependency is encountered, it will stagnate, resulting in a waste of resources. Therefore, modern processors often use out-of-order execution to develop instruction-level parallelism in the program, thereby improving processor performance. Out-of-order execution allows irrelevant instructions to bypass long-delay events, thereby improving instruction throughput. There is a possibility of memory order violation in out-of-order execution. For example, suppose a store instruction and a load instruction access the same address one after another in the program. Due to out-of-order execution of instructions, the load instruction gets the older memory value before the store instruction writes the data, and the store instruction is executed successfully and writes the new value. At this time, other instructions that depend on the load instruction have already taken the old value to execute the instruction, which will cause a memory order violation, resulting in the result of out-of-order execution of instructions being inconsistent with the result of instructions executed in program order.
[0004] In the prior art, as in the above example, when a storage order violation is detected, out-of-order execution will be performed again starting from the next instruction of the storage instruction in the program. However, the instruction spacing between the storage instruction and the load instruction will increase during the out-of-order execution process, which means that directly starting execution from the next instruction of the storage instruction in the program will waste the instructions that have been correctly executed between the storage instruction and the load instruction, resulting in power consumption waste and affecting the performance of the processor. Summary of the invention
[0005] The present application provides a storage order violation processing method, device, electronic device and medium, which are used to reduce power consumption and improve processor performance when processing storage order violations.
[0006] On the one hand, the present application provides a storage order violation processing method, comprising:
[0007] In the process of out-of-order execution of instructions for the program to be executed, for each current instruction to be executed, all violating instructions associated with the instruction to be executed are determined according to the load instruction reordering queue;
[0008] Determine a first violating instruction that is at the front of the program to be executed from all violating instructions associated with the instruction to be executed; wherein the first violating instruction is a load instruction; the load instruction reordering sequence includes a plurality of items, different items correspond to different issued load instructions, and each item stores a load address of the load instruction corresponding to the item, thread information of the load instruction corresponding to the item, an execution state of the load instruction corresponding to the item, a snooped value of the load instruction corresponding to the item, and a sequence identifier of the load instruction corresponding to the item;
[0009] Performing out-of-order execution of the first violating instruction and subsequent programs in the program to be executed;
[0010] Among them, determining all violation instructions associated with the instruction to be executed based on the load instruction reordering queue includes: determining the violation condition corresponding to the instruction to be executed based on the instruction type of the instruction to be executed; and determining all violation instructions associated with the instruction to be executed based on the violation condition and the load instruction reordering queue.
[0011] Optionally, determining all violation instructions associated with the to-be-executed instruction according to the load instruction reordering queue includes:
[0012] If the instruction to be executed is a storage instruction, an instruction in the load instruction reordering queue that satisfies a first violation condition is used as a violation instruction associated with the instruction to be executed; the first violation condition includes that thread information is the same as thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed;
[0013] If the instruction to be executed is a load instruction, an instruction in the load instruction reordering queue that satisfies a second violation condition is used as a violation instruction associated with the instruction to be executed; the second violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the load address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1;
[0014] If the instruction to be executed is a synchronous instruction, the instruction in the load instruction reordering queue that meets the third violation condition is used as the violation instruction associated with the instruction to be executed; the third violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the execution status representation of all violation instructions associated with the instruction to be executed has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1.
[0015] Optionally, determining the first violating instruction that is at the front of the program to be executed from all violating instructions associated with the instruction to be executed includes:
[0016] If the number of the violation instructions associated with the to-be-executed instruction is one, the violation instruction is taken as the first violation instruction;
[0017] If there are multiple violating instructions associated with the instruction to be executed, then according to the sequence identifiers of all the violating instructions associated with the instruction to be executed, the violating instruction with the smallest sequence identifier is used as the first violating instruction.
[0018] Optionally, the step of determining, from among all the violating instructions associated with the to-be-executed instructions, before a first violating instruction that is at the front of the to-be-executed program further comprises:
[0019] If there are multiple violation instructions associated with the instruction to be executed, a check request corresponding to the instruction to be executed is generated, wherein the check request corresponding to the instruction to be executed includes the instruction identifier of the instruction to be executed and the sequence identifiers of all violation instructions associated with the instruction to be executed; the check request corresponding to the instruction to be executed is added to the check request queue;
[0020] The step of determining the first violating instruction which is at the front of the program to be executed from all the violating instructions associated with the instruction to be executed comprises:
[0021] For the to-be-executed instruction corresponding to the first check request in the check request queue, a first violating instruction which is at the front in the to-be-executed program is determined from all violating instructions associated with the to-be-executed instruction.
[0022] Optionally, the performing out-of-order execution of the first violating instruction and subsequent programs in the program to be executed includes:
[0023] End the out-of-order execution of the current instruction and obtain the instruction identifier of the first violating instruction; and read the program counter value corresponding to the first violating instruction from the instruction reordering buffer according to the instruction identifier of the first violating instruction;
[0024] According to the program counter value corresponding to the first violating instruction, instructions of the instruction whose instruction address in the to-be-executed program is the program counter value corresponding to the first violating instruction and the subsequent program are executed out of order.
[0025] Optionally, after the out-of-order execution of the current instructions is terminated, the method further includes:
[0026] Determining a second inspection request in the inspection request queue, wherein the instruction identifier in the second inspection request is greater than the instruction identifier of the first violating instruction;
[0027] The second inspection request is cleared from the inspection request queue.
[0028] Optionally, determining the first violating instruction that is at the front of the program to be executed from all violating instructions associated with the instruction to be executed includes:
[0029] Generate a violation signal corresponding to the instruction to be executed according to all violation instructions associated with the instruction to be executed, wherein the violation signal includes a plurality of bits, and each bit of the violation signal corresponds one-to-one to each item of the load instruction reordering queue, wherein the first value of the bit indicates that the load instruction corresponding to the bit is the violation instruction associated with the instruction to be executed, and the second value of the bit indicates that the load instruction corresponding to the bit is not the violation instruction associated with the instruction to be executed;
[0030] The violation signal is input into a checking unit to obtain a sequence identifier output by the checking unit, and a load instruction corresponding to the sequence identifier in the load instruction reordering queue is used as the first violation instruction.
[0031] Optionally, the checking unit includes a selector and a binary tree comparator corresponding to each item in the load instruction reordering queue; the step of inputting the violation signal into the checking unit to obtain a sequence identifier output by the checking unit includes:
[0032] Each bit of the violation signal corresponding to the instruction to be executed is used as an enable signal and input to the enable end of the selector corresponding to the corresponding item; wherein the selector corresponding to each item receives a preset value and a sequence identifier of the load instruction corresponding to the item, and is used to select to output the sequence identifier when the enable signal is a first value, and to select to output the preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue;
[0033] The result of the selector output corresponding to each item is input into the binary tree comparator to obtain the sequence identifier of the binary tree comparator output; wherein the binary tree comparator is used to compare the results of all selector outputs and output the minimum result.
[0034] On the other hand, the present application provides a storage order violation processing device, comprising:
[0035] A first determination module is used to determine, for each current instruction to be executed, all violation instructions associated with the instruction to be executed according to the load instruction reordering queue during the process of out-of-order execution of instructions for the program to be executed;
[0036] A second determination module is used to determine the first violating instruction that is the frontmost in the program to be executed from all the violating instructions associated with the instruction to be executed; wherein the first violating instruction is a load instruction; the load instruction reordering sequence includes a plurality of items, different items correspond to different issued load instructions, and each item stores a load address of the load instruction corresponding to the item, thread information of the load instruction corresponding to the item, execution status of the load instruction corresponding to the item, snooped value of the load instruction corresponding to the item, and sequence identifier of the load instruction corresponding to the item;
[0037] An execution module, used for executing the first violating instruction and subsequent programs in the program to be executed out of order;
[0038] The first determination module is specifically configured to determine, according to the instruction type of the instruction to be executed, a violation condition corresponding to the instruction to be executed; and, according to the violation condition and the load instruction reordering queue, determine all violation instructions associated with the instruction to be executed.
[0039] Optionally, the first determining module is specifically configured to:
[0040] If the instruction to be executed is a storage instruction, an instruction in the load instruction reordering queue that satisfies a first violation condition is used as a violation instruction associated with the instruction to be executed; the first violation condition includes that thread information is the same as thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed;
[0041] If the instruction to be executed is a load instruction, an instruction in the load instruction reordering queue that satisfies a second violation condition is used as a violation instruction associated with the instruction to be executed; the second violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the load address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1;
[0042] If the instruction to be executed is a synchronous instruction, the instruction in the load instruction reordering queue that meets the third violation condition is used as the violation instruction associated with the instruction to be executed; the third violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the execution status representation of all violation instructions associated with the instruction to be executed has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1.
[0043] Optionally, the second determining module is specifically configured to:
[0044] If the number of the violation instructions associated with the to-be-executed instruction is one, the violation instruction is taken as the first violation instruction;
[0045] If there are multiple violating instructions associated with the instruction to be executed, then according to the sequence identifiers of all the violating instructions associated with the instruction to be executed, the violating instruction with the smallest sequence identifier is used as the first violating instruction.
[0046] Optionally, the second determining module is further used to:
[0047] If there are multiple violation instructions associated with the instruction to be executed, a check request corresponding to the instruction to be executed is generated, wherein the check request corresponding to the instruction to be executed includes the instruction identifier of the instruction to be executed and the sequence identifiers of all violation instructions associated with the instruction to be executed; the check request corresponding to the instruction to be executed is added to the check request queue;
[0048] The second determining module is further specifically configured to:
[0049] For the to-be-executed instruction corresponding to the first check request in the check request queue, a first violating instruction which is at the front in the to-be-executed program is determined from all violating instructions associated with the to-be-executed instruction.
[0050] Optionally, the execution module is specifically used to:
[0051] End the out-of-order execution of the current instruction and obtain the instruction identifier of the first violating instruction; and read the program counter value corresponding to the first violating instruction from the instruction reordering buffer according to the instruction identifier of the first violating instruction;
[0052] According to the program counter value corresponding to the first violating instruction, instructions of the instruction whose instruction address in the to-be-executed program is the program counter value corresponding to the first violating instruction and the subsequent program are executed out of order.
[0053] Optionally, the second determining module is further used to:
[0054] a clearing module, configured to determine a second inspection request in the inspection request queue, wherein the instruction identifier in the second inspection request is greater than the instruction identifier of the first violation instruction;
[0055] The second inspection request is cleared from the inspection request queue.
[0056] Optionally, the second determining module is further used to:
[0057] Generate a violation signal corresponding to the instruction to be executed according to all violation instructions associated with the instruction to be executed, wherein the violation signal includes a plurality of bits, and each bit of the violation signal corresponds one-to-one to each item of the load instruction reordering queue, wherein the first value of the bit indicates that the load instruction corresponding to the bit is the violation instruction associated with the instruction to be executed, and the second value of the bit indicates that the load instruction corresponding to the bit is not the violation instruction associated with the instruction to be executed;
[0058] The violation signal is input into a checking unit to obtain a sequence identifier output by the checking unit, and a load instruction corresponding to the sequence identifier in the load instruction reordering queue is used as the first violation instruction.
[0059] Optionally, the checking unit includes a selector and a binary tree comparator corresponding to each item in the load instruction reordering queue; and the second determining module is further used to:
[0060] Each bit of the violation signal corresponding to the instruction to be executed is used as an enable signal and input to the enable end of the selector corresponding to the corresponding item; wherein the selector corresponding to each item receives a preset value and a sequence identifier of the load instruction corresponding to the item, and is used to select to output the sequence identifier when the enable signal is a first value, and to select to output the preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue;
[0061] The result of the selector output corresponding to each item is input into the binary tree comparator to obtain the sequence identifier of the binary tree comparator output; wherein the binary tree comparator is used to compare the results of all selector outputs and output the minimum result.
[0062] On the other hand, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method described above.
[0063] On the other hand, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method as described above.
[0064] In the storage order violation processing method, device, electronic device and medium provided by the present application, in the process of out-of-order execution of instructions for a program to be executed, for each current instruction to be executed, all violation instructions associated with the instruction to be executed are determined in the load instruction reordering queue according to the load addresses, thread information, execution status, snooped value and sequence identifier of different already issued load instructions saved in the load instruction reordering queue, and the first violation instruction that is at the front of the program to be executed is determined from all the violation instructions associated with the instruction to be executed; the instructions are executed out of order for the first violation instruction in the program to be executed and the programs after it; therefore, when the storage order violation causes the execution result of part of the program to be erroneous, the violation instruction with the initial erroneous execution result in the program is accurately determined, and the execution is re-executed starting from the violation instruction, which can avoid wasting the program that has been executed correctly, achieve storage order violation while reducing power consumption waste, and improve processor performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0066] Figure 1 A schematic diagram of the structure of a processor core is shown in FIG.
[0067] Figure 2 exemplarily shows a flow chart of a storage order violation processing method provided in Embodiment 1 of the present application;
[0068] Figure 3 exemplarily shows a schematic diagram of the structure of the load instruction reordering queue provided in the first embodiment of the present application;
[0069] Figure 4 The structure diagram of the inspection request queue provided in the first embodiment of the present application is exemplarily shown in FIG.
[0070] Figure 5 The flowchart of determining the first violating instruction provided in the first embodiment of the present application is exemplarily shown in FIG.
[0071] Figure 6 The structural diagram of the selector provided in the first embodiment of the present application is exemplarily shown in FIG.
[0072] Figure 7 The structural diagram of the inspection unit provided in the first embodiment of the present application is exemplarily shown in FIG.
[0073] Figure 8 exemplarily shows a structural diagram of a storage order violation processing device provided in Embodiment 2 of the present application;
[0074] Fig. 9 The structure diagram of the electronic device for handling storage order violations provided in the third embodiment of the present application is exemplarily shown in FIG.
[0075] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0076] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0077] The module in this application refers to a functional module or a logical module. It can be in software form, and its functions are realized by executing program code by a processor; it can also be in hardware form. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects before and after are in an "or" relationship.
[0078] First, the terms involved in this application are explained:
[0079] Multi-hot encoding converts the features into an n-dimensional numerical vector, where the interactive dimension is 1 and the other dimensions are 0.
[0080] There are two types of processor execution modes: sequential execution and out-of-order execution. Sequential execution means executing in the order of instruction fetches from the instruction counter. However, in the case of sequential execution, once an instruction dependency is encountered, a stagnation will occur, resulting in a waste of resources. Therefore, modern processors often use out-of-order execution to develop instruction-level parallelism in programs, thereby improving processor performance. Out-of-order execution allows irrelevant instructions to bypass long-delay events, thereby improving instruction throughput. Out-of-order execution may cause storage order violations. For example, suppose a program accesses a storage instruction and a load instruction to the same address one after the other. Due to out-of-order execution of instructions, the load instruction gets an older memory value before the storage instruction writes the data, and the storage instruction is successfully executed and the new value is written. At this time, other instructions that depend on the load instruction have already taken the old value to execute the instruction, which will cause a storage order violation, resulting in the result of out-of-order execution of instructions being inconsistent with the result of the instructions being executed in the order of the program.
[0081] In the prior art, as in the above example, when a storage order violation is detected, out-of-order execution will be performed again starting from the next instruction of the storage instruction in the program. However, the instruction spacing between the storage instruction and the load instruction will increase during the out-of-order execution process, which means that directly starting execution from the next instruction of the storage instruction in the program will waste the instructions that have been correctly executed between the storage instruction and the load instruction, resulting in power consumption waste and affecting the performance of the processor.
[0082] The storage order violation processing method, device, electronic device and medium provided in this application are intended to solve the above-mentioned technical problems.
[0083] In the storage order violation processing method, device, electronic device and medium provided by the present application, in the process of out-of-order execution of instructions for a program to be executed, for each current instruction to be executed, all violation instructions associated with the instruction to be executed are determined in the load instruction reordering queue according to the load addresses, thread information, execution status, snooped value and sequence identifier of different already issued load instructions saved in the load instruction reordering queue, and the first violation instruction that is at the front of the program to be executed is determined from all the violation instructions associated with the instruction to be executed; the instructions are executed out of order for the first violation instruction in the program to be executed and the programs after it; therefore, when the storage order violation causes the execution result of part of the program to be erroneous, the violation instruction with the initial erroneous execution result in the program is accurately determined, and the execution is re-executed starting from the violation instruction, which can avoid wasting the program that has been executed correctly, achieve storage order violation while reducing power consumption waste, and improve processor performance.
[0084] Figure 1 A schematic diagram of the structure of a processor core is shown as an example. Figure 1As shown, the processor core is a simple example of a high-performance out-of-order processor core, which can be a hardware single-threaded or hardware multi-threaded processor core. The processor core pipeline is, from front to back, an instruction cache (I-cache) 101, an instruction fetch unit (IFU) 102, a branch prediction unit (BPU) 103, an instruction decode unit (IDU) 104, a register renaming unit 105, an instruction issue queue 106, a physical register file 107, an integer execution unit 108, a floating point / vector execution unit 109, a load-store unit (LSU) 110, a data cache 111, an instruction reorder buffer (ROB / inst-ROB) 112, an address resolution completion table 113, a completion unit 114, and an arch-state rename mapper 115.
[0085] The instruction cache 101 is responsible for storing instructions that are being used recently, instructions that will be used later, and auxiliary information of the instructions (such as pre-decoding information).
[0086] The instruction fetch unit 102 is responsible for indexing one or more instructions from the instruction cache 101 per clock cycle.
[0087] The branch prediction unit 103 can be tightly coupled to the instruction fetch unit 102, or decoupled from the instruction fetch unit 102. The branch prediction unit 103 predicts the trajectory of subsequent instruction fetches for the instruction fetch unit 102, that is, predicts the jump direction and jump address of the current instruction stream.
[0088] The decoding unit 104 receives instructions from the instruction fetch unit 102 for decoding, and usually decodes the instruction word specified by the instruction set into a microinstruction sequence suitable for hardware execution. Depending on the complexity of the instruction, it is decoded into one or more microinstructions or internal operations (IOPs). IOPs can be processed by subsequent pipelines and executed out of order, but often need to wait for all internal operations belonging to the same instruction to be correctly executed before they can be submitted.
[0089] The register renaming unit 105 is usually used to eliminate false dependencies between instructions / internal operations (such as write-after-write, WAW for short; write-after-read, WAR for short), so as to avoid serial execution of instructions. In a specific implementation, the renaming unit can map the logical (instruction set architecture level) target register number to the number in the physical register space, and can eliminate false dependencies (such as WAW, WAR) during the mapping process. Once decoded and renamed, the IOP can be allocated pipeline back-end resources in the dispatch stage, such as the instruction reorder buffer 112, the instruction dispatch queue (Issue Queue), the load instruction reorder queue (Load Reorder Queue, LRQ for short), and the store instruction reorder queue (Store Reorder Queue, SRQ for short). According to the classification of the IOP information, the relevant resources are stored separately to prepare for the execution of instructions.
[0090] The instruction reorder buffer 112 allocates table entries for instructions in the dispatch stage, and stores the instruction information entering the instruction reorder buffer 112 from the dispatch stage, until the instruction is submitted from the instruction reorder buffer 112 and the architecture state register mapping table 115 is updated, and the corresponding table entry of the instruction reorder buffer 112 is released. The instruction reorder buffer 112 mainly stores the instruction completion status, instruction exception type, instruction register mapping history, instruction address and other related information, so as to support the normal submission of instructions or handle instruction speculation errors (exceptions, branch prediction errors, storage order violations, etc.), and restore the micro-architecture state related to the processor core to re-fetch instructions for execution.
[0091] The instruction emission queue 106 is responsible for storing the renamed IOP, tracking the operand preparation status of the instruction, the running status of the execution unit and the status of the resources required by the instruction pipeline; waking up the instructions in the queue that depend on certain operands, which may be generated by the IOP that is about to be emitted. The instruction queue is also responsible for selecting the corresponding IOP for the downstream execution unit, arbitrating the oldest or most critical instructions to be emitted for execution. After the instruction queue emits the IOP, it will pass through the physical register file 107, read the source operand or get the data from the bypass path, and then send it to the corresponding execution unit, such as the branch execution unit (Branch Execution Unit), integer execution unit 108, floating point / vector execution unit 109, memory access instruction execution unit 110, etc.
[0092] The completion unit 114 is responsible for checking the completion status of the instruction and determining whether an exception occurs. If no exception occurs, the corresponding architecture register mapping table 115 is updated according to the instruction type. The mapping table stores the mapping of the destination register logical address (logical GPR index) of the submitted instruction to the physical address (physical GPR index). If an exception occurs, the exception information in the ROB is used to jump to the corresponding exception handling routine to execute the exception handling program.
[0093] The technical solution of the present application is illustrated below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0094] Embodiment 1
[0095] Figure 2 A flowchart of a storage order violation processing method provided by an embodiment of the present application is shown in FIG. Figure 2 As shown, the storage order violation processing method provided in this embodiment may include:
[0096] S201, in the process of out-of-order execution of instructions for a program to be executed, for each current instruction to be executed, all violating instructions associated with the instruction to be executed are determined according to a load instruction reordering queue;
[0097] S202, determining the first violating instruction that is at the front of the program to be executed from all violating instructions associated with the instruction to be executed; wherein the first violating instruction is a load instruction; the load instruction reordering sequence includes a plurality of items, different items correspond to different issued load instructions, and each item stores a load address of the load instruction corresponding to the item, thread information of the load instruction corresponding to the item, execution status of the load instruction corresponding to the item, snooped value of the load instruction corresponding to the item, and sequence identifier of the load instruction corresponding to the item;
[0098] S203, executing the first violating instruction in the program to be executed and the subsequent instructions out of order.
[0099] In practical applications, the executor of this embodiment can be a storage order violation processing device, which can be implemented through a computer program, such as application software, etc.; or, it can also be implemented as a medium storing relevant computer programs, such as a USB flash drive, a cloud disk, etc.; or, it can also be implemented through a physical device integrated or installed with relevant computer programs, such as a chip, a server, etc.
[0100] The load instruction reorder queue is used to maintain the status of loads entering the out-of-order window and monitor potential semantic hazards. Figure 3A schematic diagram of the structure of a load instruction reordering queue provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, each load instruction is assigned to an item of the load instruction reordering queue in the dispatching stage or the emission stage. Different items of the load instruction reordering queue store the sequence identifier, load address, thread information (tid), execution status (finished) and snooped value of different load instructions. After the load instruction is executed, finished is set to 1. In the processor core that implements the hardware simultaneous multithreading function (SMT), in order to flexibly share the same set of LRQ resources, the items of the load instruction reordering queue are allowed to be allocated to different hardware threads as needed, resulting in the program order of the load instructions not being reflected in the physical order of the items of the load instruction reordering queue that are actually allocated.
[0101] Among them, the sequence identifier of the load instruction includes a load tag or an instruction tag (iop-tag). The load tag is an identifier assigned by the processor core before the load instruction is emitted to the emission queue, which is used to characterize the order of the load instruction among all load instructions in the program; the instruction tag is an identifier assigned by the processor core before the load instruction is emitted to the emission queue, which is used to characterize the order of the load instruction among all instructions in the program.
[0102] The snooped value represents the snooped status of the load instruction. At some point in time, an invalidate request from an external storage system may be sent to the load instruction reordering queue. The invalidate request is accompanied by load address information. The load address information in the invalidate request is compared with the load addresses of all load instructions with finished=1 in the load instruction reordering queue. If the comparison result is the same, the snooped value in the item will be set to 1, indicating that the load instruction has been snooped by other potential write requests, and the data corresponding to the load address may not be the latest.
[0103] In the process of executing instructions out of order for a program to be executed, for each current instruction to be executed, all violation instructions associated with the instruction to be executed are determined based on the information of the load instruction stored in the load instruction reordering queue; and the first violation instruction that is at the front of the program to be executed is determined from all the violation instructions associated with the instruction to be executed. The first violation instruction that is at the front of the program to be executed can be determined by comparing the sequence identifiers of all the violation instructions. The larger the sequence identifier, the later the corresponding violation instruction is in the program. The instructions are executed out of order for the first violation instruction in the program to be executed and the programs after it.
[0104] In this example, in the process of executing instructions out of order for a program to be executed, for each current instruction to be executed, all violating instructions associated with the instruction to be executed are determined in the load instruction reordering queue according to the load addresses, thread information, execution status, snooped value and sequence identifier of different already issued load instructions saved in the load instruction reordering queue, and the first violating instruction that is at the front of the program to be executed is determined from all the violating instructions associated with the instruction to be executed; the instructions are executed out of order for the first violating instruction in the program to be executed and the programs thereafter; thereby, when a storage order violation causes an erroneous execution result of part of the program, the violating instruction with the initially erroneous execution result in the program is accurately determined, and re-execution is performed starting from the violating instruction, which can avoid wasting the program that has been executed correctly, reduce power consumption while solving the storage order violation, and improve processor performance.
[0105] Among them, storage order violation may include multiple situations, such as Store-Hit-Load, Load-hit-load and Sync-hit-load. According to different storage order violation situations, different methods are required to determine all violation instructions associated with the instruction to be executed. In one example, according to the load instruction reordering queue, all violation instructions associated with the instruction to be executed are determined, including:
[0106] If the instruction to be executed is a storage instruction, an instruction in the load instruction reordering queue that meets the first violation condition is used as a violation instruction associated with the instruction to be executed; the first violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed;
[0107] If the instruction to be executed is a load instruction, the instruction in the load instruction reordering queue that meets the second violation condition is used as the violation instruction associated with the instruction to be executed; the second violation condition includes that the thread information is the same as the thread information of the instruction to be executed, and the load address is the same as the load address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1;
[0108] If the instruction to be executed is a synchronous instruction, the instruction that meets the third violation condition in the load instruction reordering queue will be used as the violation instruction associated with the instruction to be executed; the third violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the execution status representation of all violation instructions associated with the instruction to be executed has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1.
[0109] Specifically, Store-Hit-Load is referred to as SHL, which refers to the store instruction and load instruction that access the same address in a program one after the other. Due to the out-of-order execution of instructions, the load instruction gets the older memory value before the store instruction writes the data, and the store instruction is successfully executed and the new value is written. At this time, other instructions that depend on the load instruction have taken the old value to execute the instruction, which will cause a storage order violation. If the instruction to be executed is a storage instruction, it is necessary to detect whether Store-Hit-Load occurs. Detecting whether Store-Hit-Load occurs can be achieved by judging whether the load instruction in the load instruction reordering queue meets the first violation condition, wherein the first violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state represents that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed. According to the load instruction reordering queue and the sequence identifier, storage address, and thread information of the instruction to be executed, the instruction in the load instruction reordering queue that meets the first violation condition is used as the violation instruction associated with the instruction to be executed.
[0110] Load-hit-load is referred to as LHL, which refers to the first load (load1) instruction and the second load (load2) instruction that access the same address in a program one after the other. Due to the out-of-order execution of instructions, the second load instruction is executed before the first load instruction. After obtaining the value in the memory, other programs in the storage system also update the value of the address. After that, the first load instruction is executed and obtains the latest value in the memory, which violates the sequential consistency of the program and causes a storage order violation. At this time, the second load instruction has been snooped by other potential write requests, indicating that the data corresponding to its address may not be the latest. If the instruction to be executed is a load instruction, it is necessary to detect whether a load-hit-load occurs. Detecting whether a load-hit-load occurs can be achieved by determining whether the load instruction in the load instruction reordering queue meets the second violation condition, wherein the second violation condition includes that the thread information is the same as the thread information of the instruction to be executed, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed, and the snooped value is 1. According to the load instruction reordering queue and the sequence identifier, storage address, and thread information of the instructions to be executed, the instructions in the load instruction reordering queue that meet the second violation condition are used as violation instructions associated with the instructions to be executed.
[0111] Sync-hit-load refers to the synchronization (sync) instruction and load (load) instruction that are placed one after the other in the program. The synchronization instruction needs to sort the subsequent load operations. That is, the load instruction that accesses a certain address can only get the value of the address in the memory after the synchronization instruction performs global memory sorting. Because of out-of-order execution, after the load instruction is executed first and gets the value in the memory, other programs in the storage system also update the value of the address. Then the synchronization instruction is executed and enters the storage subsystem to complete the sorting operation, and returns the response sync_ack of the sorting completion. After receiving sync_ack, the processor core needs to query all the load instructions that have been executed but not submitted. If a load instruction is invalidated by an external snoop request (the load instruction is marked as invalid execution, or marked as snooped), it means that the load instruction is executed too early and gets the old value. If there is a synchronization instruction before the load instruction to sort the memory access instruction, a storage order violation occurs at this time. If the instruction to be executed is a synchronization instruction, it is necessary to detect whether a Sync-hit-load occurs. Whether a Sync-hit-load occurs can be detected by determining whether the load instruction in the load instruction reordering queue satisfies the third violation condition, wherein the third violation condition includes that the thread information is the same as the thread information of the instruction to be executed, the execution state indicates that the execution has been completed, the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed, and the snooped value is 1. According to the load instruction reordering queue and the sequence identifier and thread information of the instruction to be executed, the instruction in the load instruction reordering queue that satisfies the third violation condition is used as the violation instruction associated with the instruction to be executed.
[0112] In the above process of comparing the sequence identifier of the instruction to be executed with the sequence identifier of the loading instruction, the type of the sequence identifier of the instruction to be executed and the sequence identifier of the loading instruction are always consistent, that is, when the sequence identifier of the instruction to be executed is the loading identifier corresponding to the instruction to be executed, the sequence identifier of the loading instruction is the loading identifier of the loading instruction; when the sequence identifier of the instruction to be executed is the instruction identifier corresponding to the instruction to be executed, the sequence identifier of the loading instruction is the instruction identifier of the loading instruction. Among them, the loading identifier corresponding to the instruction to be executed refers to the loading identifier recorded by the processor core at this moment before the instruction to be executed is dispatched to the emission queue; the instruction identifier of the instruction to be executed refers to the instruction identifier assigned by the processor core before the instruction to be executed is dispatched to the emission queue, which is used to characterize the order of each instruction in the program.
[0113] In this example, for various storage order violation situations, the violation instructions associated with the instructions to be executed can be accurately obtained.
[0114] In actual applications, there may be multiple violation instructions associated with the instruction to be executed. In this case, it is necessary to further determine the oldest violation instruction among all the violation instructions and re-execute from the oldest violation instruction. In one example, determining the first violation instruction at the front of the program to be executed from all the violation instructions associated with the instruction to be executed includes:
[0115] If the number of the violating instructions associated with the instruction to be executed is one, the violating instruction is taken as the first violating instruction;
[0116] If there are multiple violating instructions associated with the instruction to be executed, then according to the sequence identifiers of all the violating instructions associated with the instruction to be executed, the violating instruction with the smallest sequence identifier is taken as the first violating instruction.
[0117] Specifically, when the number of violating instructions associated with the instruction to be executed is one, the violating instruction can be directly determined as the first violating instruction; when the number of violating instructions associated with the instruction to be executed is multiple, the oldest violating instruction can be determined by the sequence identifier, that is, the violating instruction with the smallest sequence identifier can be determined as the first violating instruction.
[0118] In this example, the first violating instruction can be accurately determined among the violating instructions associated with a plurality of instructions to be executed through sequential identification.
[0119] In actual applications, there may be multiple storage order violations, and the violating instructions have multiple pending instructions, so a check request queue (CRQ) can be established to store multiple pending instructions to determine the first violating instruction. In one example, before determining the first violating instruction that is at the front of the pending program from all the violating instructions associated with the pending instructions, it also includes:
[0120] If there are multiple violation instructions associated with the instruction to be executed, a check request corresponding to the instruction to be executed is generated, and the check request corresponding to the instruction to be executed includes the instruction identifier of the instruction to be executed and the sequence identifiers of all violation instructions associated with the instruction to be executed; the check request corresponding to the instruction to be executed is added to the check request queue;
[0121] Determining the first violating instruction that is at the front of the program to be executed from all the violating instructions associated with the instruction to be executed, including:
[0122] For the to-be-executed instruction corresponding to the first check request in the check request queue, a first violating instruction which is at the front of the to-be-executed program is determined from all violating instructions associated with the to-be-executed instruction.
[0123] Figure 4 A schematic diagram of the structure of the inspection request queue provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, for a to-be-executed instruction with a plurality of associated violation instructions, a check request (CheckRequest) corresponding to the execution instruction is generated, the check request includes the instruction identifier of the to-be-executed instruction and the sequence identifiers of all the violation instructions associated with the to-be-executed instruction; and the check request is added to a check request queue, and the check request queue saves the check request to a free item (free slots). The check request queue can save multiple check requests, and the first check request with the oldest sequence in the check request queue is sent to the oldest-Load pipeline using the first-in-first-out method. By comparing the sequence identifiers of all the violation instructions associated with the to-be-executed instruction, the first violation instruction that is at the front of the to-be-executed program is determined from all the violation instructions associated with the to-be-executed instruction.
[0124] In this example, by establishing a check request queue, it is possible to determine in order the oldest violating instruction corresponding to a plurality of to-be-executed instructions associated with a plurality of violating instructions.
[0125] In one example, executing the first violating instruction in the program to be executed and the subsequent instructions out of order includes:
[0126] End the out-of-order execution of the current instruction and obtain the instruction identifier of the first violating instruction; and, according to the instruction identifier of the first violating instruction, read the program counter value corresponding to the first violating instruction from the instruction reordering buffer;
[0127] According to the value of the program counter corresponding to the first violating instruction, instructions of the instruction whose instruction address in the program to be executed is the value of the program counter corresponding to the first violating instruction and the subsequent program are executed out of order.
[0128] Specifically, the pipeline is flushed to terminate the out-of-order execution of instructions. The instruction identifier of the first violating instruction is obtained, and according to the instruction identifier of the first violating instruction, the value of the program counter (PC) corresponding to the first violating instruction is read from the instruction reordering buffer. In practical applications, instructions are stored in a memory space with continuous addresses, and the program counter (PC) is used to store the addresses of instructions. When the program is executed, the initial value of the program counter is the address of the first instruction of the program. The first step of instruction execution is to fetch instructions from the memory according to the address in the program counter, and then the address in the program counter is automatically increased by 1 or the address of the next instruction in the program is given by the transfer pointer. Therefore, according to the value of the program counter corresponding to the first violating instruction, the instruction whose instruction address in the program to be executed is the value of the program counter corresponding to the first violating instruction and the program after it can be executed out of order.
[0129] In this example, according to the instruction identifier of the first violating instruction, the program counter value corresponding to the first violating instruction is read from the instruction reordering buffer, so that the first violating instruction and subsequent instructions can be re-executed starting with the first violating instruction.
[0130] After re-execution out of order based on the first violating instruction corresponding to a to-be-executed instruction, some to-be-executed instructions corresponding to the check request stored in the check request queue may be within the scope of the out-of-order execution. In order to avoid waste of resources, in an example, after the out-of-order execution of the instruction is ended, the following is further included:
[0131] Determine a second inspection request in the inspection request queue, wherein the instruction identifier in the second inspection request is greater than the instruction identifier of the first violating instruction;
[0132] The second inspection request is cleared from the inspection request queue.
[0133] Specifically, according to the first violating instruction corresponding to a certain instruction to be executed, the instructions are executed out of order again. After the out of order execution of this instruction is completed, the instruction identifier of the first violating instruction is compared with the instruction identifier of the instruction to be executed stored in the check request queue, and the check requests with instruction identifiers greater than the instruction identifier of the first violating instruction are removed. If the instruction to be executed corresponding to the check request is within the range of re-out of order execution, the current storage order violation of the instruction to be executed will be eliminated, effectively avoiding waste of power consumption.
[0134] In this example, after the out-of-order execution of this instruction is completed, the check request in the check request queue whose instruction identifier is greater than the instruction identifier of the first violating instruction is removed, effectively avoiding determining the oldest first violating instruction among the multiple violating instructions associated with the to-be-executed instruction corresponding to the check request, reducing power consumption and improving processor performance.
[0135] In practical applications, based on the violation condition, the information of the instruction to be executed can be compared with the information in the load instruction reordering queue to generate a violation signal, and all the violation instructions associated with the instruction to be executed can be determined based on the violation signal. In one example, the first violation instruction at the front of the program to be executed is determined from all the violation instructions associated with the instruction to be executed, including:
[0136] Generate a violation signal corresponding to the instruction to be executed according to all violation instructions associated with the instruction to be executed, the violation signal includes a plurality of bits, each bit of the violation signal corresponds to each item of the load instruction reordering queue, wherein a bit having a first value indicates that the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed, and a bit having a second value indicates that the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed;
[0137] The violation signal is input into the checking unit to obtain a sequence identifier output by the checking unit, and the load instruction corresponding to the sequence identifier in the load instruction reordering queue is used as the first violation instruction.
[0138] Specifically, a violation signal can be generated based on the aforementioned first violation condition, second violation condition, or third violation condition, wherein the violation signal includes a plurality of bits, each bit of the violation signal corresponds one-to-one to each item of the load instruction reordering queue, and the value of each bit can be a first value or a second value, and a bit having a first value indicates that the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed, and the load instruction and the instruction to be executed together constitute a storage order violation; a bit having a second value indicates that the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed, and the load instruction and the instruction to be executed do not constitute a storage order violation. Exemplarily, the first value can be 1, and the second value can be 0, that is, when a certain bit of the violation signal is 1, the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed; when a certain bit of the violation signal is 0, the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed.
[0139] When there is one bit with the first value in the violation signal, the load instruction corresponding to the bit is taken as the first violation instruction; when there are multiple bits with the first value in the violation signal, the violation signal is input into the checking unit, and the order of the multiple violation instructions is compared by the checking unit to obtain the sequence identifier output by the checking unit; the load instruction corresponding to the sequence identifier in the load instruction reordering queue is taken as the first violation instruction. In practical applications, the check request may include a violation signal corresponding to the instruction to be executed, and the violation signal corresponding to the check request with the first order in the check request queue is input into the checking unit to determine the first violation instruction corresponding to the instruction to be executed.
[0140] Figure 5 A flowchart of determining a first violating instruction is provided for an embodiment of the present application, such as Figure 5As shown, in one example, taking the storage order violation of Store-Hit-Load as an example, after executing the read register file and address generation, it is determined whether the corresponding information of the load instruction in the load instruction reordering queue meets the first violation condition, and the judgment result is characterized by Multi-Hot encoding, wherein the address generation includes source operand selection and address generation. Assuming that there are N items in the load instruction reordering queue, the sequence identifier of the instruction to be executed is compared with the sequence identifier in the load instruction reordering queue to generate an older signal including N bits, each bit of the older signal corresponds to each item in the load instruction reordering queue one by one, the sequence identifier of the load instruction corresponding to the bit with a value of 1 in the older signal is greater than the sequence identifier of the instruction to be executed, and the sequence identifier of the load instruction corresponding to the bit with a value of 0 in the older signal is not greater than the sequence identifier of the instruction to be executed; the storage address of the instruction to be executed is compared with the load address in the load instruction reordering queue to generate a match signal including N bits, each bit of the match signal corresponds to each item in the load instruction reordering queue one by one, the load address of the load instruction corresponding to the bit with a value of 1 in the match signal is the same as the storage address of the instruction to be executed, and the load instruction corresponding to the bit with a value of 0 in the match signal is not greater than the sequence identifier of the instruction to be executed. The loading address of the instruction is different from the storage address of the instruction to be executed; the thread information of the instruction to be executed is compared with the thread information in the load instruction reordering queue, and a thread signal including N bits is generated, and each bit of the thread signal corresponds to each item of the load instruction reordering queue one by one. The thread information of the load instruction corresponding to the bit with a value of 1 in the thread signal is the same as the thread information of the instruction to be executed, and the thread information of the load instruction corresponding to the bit with a value of 0 in the thread signal is different from the thread information of the instruction to be executed; according to the execution status in the load instruction reordering queue, a fin signal including N bits is generated, and each bit of the fin signal corresponds to each item of the load instruction reordering queue one by one. The execution status of the load instruction corresponding to the bit with a value of 1 in the fin signal is executed, and the execution status of the load instruction corresponding to the bit with a value of 0 in the fin signal is not executed. Perform a bitwise AND operation on the older signal, the match signal, the thread signal, and the fin signal to obtain a violation signal. At this time, the first value is 1 and the second value is 0. That is, when a bit of the violation signal is 1, the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed; when a bit of the violation signal is 0, the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed.Input the violation signal into the signal checking circuit, exemplarily the signal checking circuit may be a multi-hot detection circuit; based on the signal checking circuit, determine whether the number of bits with a value of 1 in the violation signal is 1, if the number of bits with a value of 1 in the violation signal is 1, use the violation signal as an index to determine the first violating instruction in the load instruction reordering queue; if there are multiple bits with a value of 1 in the violation signal, determine the first violating instruction through the checking unit. Exemplarily, a corresponding check request may be generated and added to the check request queue, the violation signal corresponding to the check request with the first order in the check request queue may be input into the checking unit, and the first violating instruction corresponding to the instruction to be executed may be determined according to the sequence identifier of the violating instruction. The structure of the check request queue is as follows. Figure 4 shown.
[0141] In this example, by generating a violation signal representing a load instruction violation in the load instruction reordering queue, the violating instruction associated with the instruction to be executed can be accurately determined, and the first violating instruction among multiple violating instructions can be determined by the checking unit.
[0142] The structure of the checking unit can be various. In one example, the checking unit includes a selector and a binary tree comparator corresponding to each item in the load instruction reordering queue; the violation signal is input into the checking unit to obtain a sequence identifier output by the checking unit, including:
[0143] Each bit of the violation signal corresponding to the instruction to be executed is used as an enable signal and input to the enable end of the selector corresponding to the corresponding item; wherein the selector corresponding to each item receives a preset value and a sequence identifier of the load instruction corresponding to the item, and is used to select the output sequence identifier when the enable signal is a first value, and to select the output preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue;
[0144] The result of the selector output corresponding to each item is input into the binary tree comparator to obtain the sequence identification of the binary tree comparator output; wherein the binary tree comparator is used to compare the results of all selector outputs and output the minimum result.
[0145] Figure 6 A schematic diagram of the structure of a selector provided in an embodiment of the present application is shown in FIG. Figure 6As shown, the enable end of the 1 selector corresponding to each item in the load instruction reordering queue receives each bit value of the violation signal corresponding to the instruction to be executed, and the selector corresponding to each item receives a preset value (Max_value) and a sequence identifier of the load instruction corresponding to the item, and selects to output the sequence identifier of the load instruction corresponding to the item when the enable signal is a first value, and selects to output the preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue, so that they can be filtered out in the subsequent comparison of the binary tree comparator. Figure 7 A schematic diagram of the structure of the inspection unit provided in one embodiment of the present application is shown in FIG. Figure 7 As shown, the result output by each selector is input into the binary tree comparator, wherein the binary tree comparator is composed of multiple 2-input comparison selectors, each 2-input comparison selector outputs the smaller input value, and finally obtains the smallest sequence identifier. Assuming that the load instruction reordering queue has N items, and N is an integer power of 2, then the binary tree selector array is a regular binary tree. When N is 64, 32 2-to-1 selectors are required for level comparison. Each level compares the sequence identifiers corresponding to two bits of a group of adjacent violation signals. The first level includes 16 2-input comparison selectors, the second level includes 8 2-input comparison selectors, the third level includes 4 2-input comparison selectors, the fourth level includes 2 2-input comparison selectors, and the fifth level includes 1 2-input comparison selector, and finally outputs the smallest sequence identifier.
[0146] In the storage order violation processing method provided by the present embodiment, in the process of out-of-order execution of instructions for a program to be executed, for each current instruction to be executed, all violation instructions associated with the instruction to be executed are determined in the load instruction reordering queue according to the load addresses, thread information, execution status, snooped value and sequence identifier of different issued load instructions stored in the load instruction reordering queue, and the first violation instruction that is the frontmost in the program to be executed is determined from all the violation instructions associated with the instruction to be executed; the instructions are executed out of order for the first violation instruction in the program to be executed and the programs after it; therefore, when the storage order violation causes the execution result of part of the program to be erroneous, the violation instruction with the initial execution result erroneous in the program is accurately determined, and the program is re-executed starting from the violation instruction, which can avoid wasting the program that has been executed correctly, reduce power consumption while solving the storage order violation, and improve the performance of the processor.
[0147] Embodiment 2
[0148] Figure 8 A schematic diagram of the structure of a storage order violation processing device provided by an embodiment of the present application. Figure 8 As shown, the storage order violation processing device 800 provided in this embodiment may include:
[0149] A first determination module 81 is used to determine, for each current instruction to be executed, all violation instructions associated with the instruction to be executed according to the load instruction reordering queue during the process of out-of-order execution of instructions for the program to be executed;
[0150] The second determination module 82 is used to determine the first violating instruction that is the frontmost in the program to be executed from all the violating instructions associated with the instruction to be executed; wherein the first violating instruction is a load instruction; the load instruction reordering sequence includes a plurality of items, different items correspond to different issued load instructions, and each item stores the load address of the load instruction corresponding to the item, the thread information of the load instruction corresponding to the item, the execution state of the load instruction corresponding to the item, the snooped value of the load instruction corresponding to the item, and the sequence identifier of the load instruction corresponding to the item;
[0151] The execution module 83 is used to execute the first violating instruction and subsequent programs in the program to be executed out of order.
[0152] In practical applications, the storage order violation processing device can be implemented through a computer program, such as application software, etc.; or, it can also be implemented as a medium storing relevant computer programs, such as a USB flash drive, a cloud disk, etc.; or, it can also be implemented through a physical device integrated or installed with relevant computer programs, such as a chip, a server, etc.
[0153] The load instruction reordering queue is used to maintain the status of loads entering the out-of-order window and monitor potential semantic hazards. Each load instruction is assigned to an item in the load instruction reordering queue during the dispatch phase or the emission phase. Different items in the load instruction reordering queue store the sequence identifier, load address, thread information, execution status, and snooped value of different load instructions. In the processor core that implements the hardware simultaneous multi-threading function, in order to flexibly share the same set of LRQ resources, the items in the load instruction reordering queue are allowed to be allocated to different hardware threads on demand, resulting in the program order of the load instructions not being reflected in the physical order of the items in the load instruction reordering queue that are actually allocated.
[0154] Among them, the sequence identifier of the load instruction includes a load identifier or an instruction identifier. The load identifier is an identifier assigned by the processor core before the load instruction is emitted to the emission queue to characterize the order of the load instruction among all load instructions in the program; the load identifier is an identifier assigned by the processor core before the load instruction is emitted to the emission queue to characterize the order of the load instruction among all instructions in the program.
[0155] The snooped value represents the snooped status of the load instruction. At some point in time, an invalidate request from an external storage system may be sent to the load instruction reordering queue. The invalidate request is accompanied by load address information. The load address information in the invalidate request is compared with the load addresses of all executed load instructions in the load instruction reordering queue. If the comparison result is the same, the snooped value in the item will be set to 1, indicating that the load instruction has been snooped by other potential write requests, and the data corresponding to the load address may not be the latest.
[0156] In the process of executing instructions out of order for a program to be executed, for each current instruction to be executed, all violation instructions associated with the instruction to be executed are determined based on the information of the load instruction stored in the load instruction reordering queue; and the first violation instruction that is at the front of the program to be executed is determined from all the violation instructions associated with the instruction to be executed. The first violation instruction that is at the front of the program to be executed can be determined by comparing the sequence identifiers of all the violation instructions. The larger the sequence identifier, the later the corresponding violation instruction is in the program. The instructions are executed out of order for the first violation instruction in the program to be executed and the programs after it.
[0157] In this example, in the process of executing instructions out of order for a program to be executed, for each current instruction to be executed, all violating instructions associated with the instruction to be executed are determined in the load instruction reordering queue according to the load addresses, thread information, execution status, snooped value and sequence identifier of different already issued load instructions saved in the load instruction reordering queue, and the first violating instruction that is at the front of the program to be executed is determined from all the violating instructions associated with the instruction to be executed; the instructions are executed out of order for the first violating instruction in the program to be executed and the programs thereafter; thereby, when a storage order violation causes an erroneous execution result of part of the program, the violating instruction with the initially erroneous execution result in the program is accurately determined, and re-execution is performed starting from the violating instruction, which can avoid wasting the program that has been executed correctly, reduce power consumption while solving the storage order violation, and improve processor performance.
[0158] Among them, storage order violations may include multiple situations, such as Store-Hit-Load, Load-hit-load and Sync-hit-load. According to different storage order violation situations, different methods are required to determine all violation instructions associated with the instruction to be executed. In one example, the first determination module can be specifically used to:
[0159] If the instruction to be executed is a storage instruction, an instruction in the load instruction reordering queue that meets the first violation condition is used as a violation instruction associated with the instruction to be executed; the first violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed;
[0160] If the instruction to be executed is a load instruction, the instruction in the load instruction reordering queue that meets the second violation condition is used as the violation instruction associated with the instruction to be executed; the second violation condition includes that the thread information is the same as the thread information of the instruction to be executed, and the load address is the same as the load address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1;
[0161] If the instruction to be executed is a synchronous instruction, the instruction that meets the third violation condition in the load instruction reordering queue will be used as the violation instruction associated with the instruction to be executed; the third violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the execution status representation of all violation instructions associated with the instruction to be executed has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1.
[0162] Specifically, Store-Hit-Load is referred to as SHL, which refers to the store instruction and load instruction that access the same address in a program one after the other. Due to the out-of-order execution of instructions, the load instruction gets the older memory value before the store instruction writes the data, and the store instruction is successfully executed and the new value is written. At this time, other instructions that depend on the load instruction have taken the old value to execute the instruction, which will cause a storage order violation. If the instruction to be executed is a storage instruction, it is necessary to detect whether Store-Hit-Load occurs. Detecting whether Store-Hit-Load occurs can be achieved by judging whether the load instruction in the load instruction reordering queue meets the first violation condition, wherein the first violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state represents that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed. According to the load instruction reordering queue and the sequence identifier, storage address, and thread information of the instruction to be executed, the instruction in the load instruction reordering queue that meets the first violation condition is used as the violation instruction associated with the instruction to be executed.
[0163] Load-hit-load is referred to as LHL, which refers to the first load (load1) instruction and the second load (load2) instruction that access the same address in a program one after the other. Due to the out-of-order execution of instructions, the second load instruction is executed before the first load instruction. After obtaining the value in the memory, other programs in the storage system also update the value of the address. After that, the first load instruction is executed and obtains the latest value in the memory, which violates the sequential consistency of the program and causes a storage order violation. At this time, the second load instruction has been snooped by other potential write requests, indicating that the data corresponding to its address may not be the latest. If the instruction to be executed is a load instruction, it is necessary to detect whether a load-hit-load occurs. Detecting whether a load-hit-load occurs can be achieved by determining whether the load instruction in the load instruction reordering queue meets the second violation condition, wherein the second violation condition includes that the thread information is the same as the thread information of the instruction to be executed, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed, and the snooped value is 1. According to the load instruction reordering queue and the sequence identifier, storage address, and thread information of the instructions to be executed, the instructions in the load instruction reordering queue that meet the second violation condition are used as violation instructions associated with the instructions to be executed.
[0164] Sync-hit-load refers to the synchronization (sync) instruction and load (load) instruction that are placed one after the other in the program. The synchronization instruction needs to sort the subsequent load operations. That is, the load instruction that accesses a certain address can only get the value of the address in the memory after the synchronization instruction performs global memory sorting. Because of out-of-order execution, after the load instruction is executed first and gets the value in the memory, other programs in the storage system also update the value of the address. Then the synchronization instruction is executed and enters the storage subsystem to complete the sorting operation, and returns the response sync_ack of the sorting completion. After receiving sync_ack, the processor core needs to query all the load instructions that have been executed but not submitted. If a load instruction is invalidated by an external snoop request (the load instruction is marked as invalid execution, or marked as snooped), it means that the load instruction is executed too early and gets the old value. If there is a synchronization instruction before the load instruction to sort the memory access instruction, a storage order violation occurs at this time. If the instruction to be executed is a synchronization instruction, it is necessary to detect whether a Sync-hit-load occurs. Whether a Sync-hit-load occurs can be detected by determining whether the load instruction in the load instruction reordering queue satisfies the third violation condition, wherein the third violation condition includes that the thread information is the same as the thread information of the instruction to be executed, the execution state indicates that the execution has been completed, the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed, and the snooped value is 1. According to the load instruction reordering queue and the sequence identifier and thread information of the instruction to be executed, the instruction in the load instruction reordering queue that satisfies the third violation condition is used as the violation instruction associated with the instruction to be executed.
[0165] In the above process of comparing the sequence identifier of the instruction to be executed with the sequence identifier of the loading instruction, the type of the sequence identifier of the instruction to be executed and the sequence identifier of the loading instruction are always consistent, that is, when the sequence identifier of the instruction to be executed is the loading identifier corresponding to the instruction to be executed, the sequence identifier of the loading instruction is the loading identifier of the loading instruction; when the sequence identifier of the instruction to be executed is the instruction identifier corresponding to the instruction to be executed, the sequence identifier of the loading instruction is the instruction identifier of the loading instruction. Among them, the loading identifier corresponding to the instruction to be executed refers to the loading identifier recorded by the processor core at this moment before the instruction to be executed is dispatched to the emission queue; the instruction identifier of the instruction to be executed refers to the instruction identifier assigned by the processor core before the instruction to be executed is dispatched to the emission queue, which is used to characterize the order of each instruction in the program.
[0166] In this example, for various storage order violation situations, the violation instructions associated with the instructions to be executed can be accurately obtained.
[0167] In actual applications, there may be multiple violation instructions associated with the instruction to be executed. In this case, it is necessary to further determine the oldest violation instruction among all the violation instructions and re-execute from the oldest violation instruction. In one example, the second determination module can be specifically used to:
[0168] If the number of the violating instructions associated with the instruction to be executed is one, the violating instruction is taken as the first violating instruction;
[0169] If there are multiple violating instructions associated with the instruction to be executed, then according to the sequence identifiers of all the violating instructions associated with the instruction to be executed, the violating instruction with the smallest sequence identifier is taken as the first violating instruction.
[0170] Specifically, when the number of violating instructions associated with the instruction to be executed is one, the violating instruction can be directly determined as the first violating instruction; when the number of violating instructions associated with the instruction to be executed is multiple, the oldest violating instruction can be determined by the sequence identifier, that is, the violating instruction with the smallest sequence identifier can be determined as the first violating instruction.
[0171] In this example, the first violating instruction can be accurately determined among the violating instructions associated with a plurality of instructions to be executed through sequential identification.
[0172] In actual applications, there may be multiple storage order violations, and the violating instruction has multiple pending instructions, so a check request queue can be established to save multiple pending instructions to determine the request of the first violating instruction. In one example, the second determination module can also be used to:
[0173] If there are multiple violation instructions associated with the instruction to be executed, a check request corresponding to the instruction to be executed is generated, and the check request corresponding to the instruction to be executed includes the instruction identifier of the instruction to be executed and the sequence identifiers of all violation instructions associated with the instruction to be executed; the check request corresponding to the instruction to be executed is added to the check request queue;
[0174] Determining the first violating instruction that is at the front of the program to be executed from all the violating instructions associated with the instruction to be executed, including:
[0175] For the to-be-executed instruction corresponding to the first check request in the check request queue, a first violating instruction which is at the front of the to-be-executed program is determined from all violating instructions associated with the to-be-executed instruction.
[0176] Specifically, for a to-be-executed instruction with multiple associated violation instructions, a check request corresponding to the execution instruction is generated, the check request includes the instruction identifier of the to-be-executed instruction and the sequence identifiers of all the violation instructions associated with the to-be-executed instruction; and the check request is added to the check request queue, and the check request queue saves the check request to the free item. The check request queue can save multiple check requests, and the first check request with the oldest sequence in the check request queue is sent to the oldest-Load pipeline using the first-in-first-out method. By comparing the sequence identifiers of all the violation instructions associated with the to-be-executed instruction, the first violation instruction that is at the front of the to-be-executed program is determined from all the violation instructions associated with the to-be-executed instruction.
[0177] In this example, by establishing a check request queue, it is possible to determine in order the oldest violating instruction corresponding to a plurality of to-be-executed instructions associated with a plurality of violating instructions.
[0178] In one example, the execution module may be specifically used to:
[0179] End the out-of-order execution of the current instruction and obtain the instruction identifier of the first violating instruction; and, according to the instruction identifier of the first violating instruction, read the program counter value corresponding to the first violating instruction from the instruction reordering buffer;
[0180] According to the value of the program counter corresponding to the first violating instruction, instructions of the instruction whose instruction address in the program to be executed is the value of the program counter corresponding to the first violating instruction and the subsequent program are executed out of order.
[0181] Specifically, the pipeline is cleared to terminate the out-of-order execution of instructions. The instruction identifier of the first violating instruction is obtained, and according to the instruction identifier of the first violating instruction, the program counter value corresponding to the first violating instruction is read from the instruction reordering buffer. In practical applications, instructions are stored in a memory space with continuous addresses, and the program counter is used to store the addresses of instructions. When the program is executed, the initial value of the program counter is the address of the first instruction of the program. The first step of instruction execution is to fetch instructions from the memory according to the address in the program counter, and then the address in the program counter is automatically increased by 1 or the address of the next instruction in the program is given by the transfer pointer. Therefore, according to the program counter value corresponding to the first violating instruction, the instruction whose instruction address in the program to be executed is the program counter value corresponding to the first violating instruction and the subsequent program can be executed out of order.
[0182] In this example, according to the instruction identifier of the first violating instruction, the program counter value corresponding to the first violating instruction is read from the instruction reordering buffer, so that the first violating instruction and subsequent instructions can be re-executed starting with the first violating instruction.
[0183] After re-execution out of order based on the first violating instruction corresponding to a to-be-executed instruction, some to-be-executed instructions corresponding to the check request stored in the check request queue may be within the scope of the out-of-order execution. In order to avoid waste of resources, in one example, the second determining module may also be used to:
[0184] Determine a second inspection request in the inspection request queue, wherein the instruction identifier in the second inspection request is greater than the instruction identifier of the first violating instruction;
[0185] The second inspection request is cleared from the inspection request queue.
[0186] Specifically, according to the first violating instruction corresponding to a certain instruction to be executed, the instructions are executed out of order again. After the out of order execution of this instruction is completed, the instruction identifier of the first violating instruction is compared with the instruction identifier of the instruction to be executed stored in the check request queue, and the check requests with instruction identifiers greater than the instruction identifier of the first violating instruction are removed. If the instruction to be executed corresponding to the check request is within the range of re-out of order execution, the current storage order violation of the instruction to be executed will be eliminated, effectively avoiding waste of power consumption.
[0187] In this example, after the out-of-order execution of this instruction is completed, the check request in the check request queue whose instruction identifier is greater than the instruction identifier of the first violating instruction is removed, effectively avoiding determining the oldest first violating instruction among the multiple violating instructions associated with the to-be-executed instruction corresponding to the check request, reducing power consumption and improving processor performance.
[0188] In practical applications, based on the violation condition, the information of the instruction to be executed can be compared with the information in the load instruction reordering queue to generate a violation signal, and all violation instructions associated with the instruction to be executed can be determined based on the violation signal. In one example, the second determination module can also be used to:
[0189] Generate a violation signal corresponding to the instruction to be executed according to all violation instructions associated with the instruction to be executed, the violation signal includes a plurality of bits, each bit of the violation signal corresponds to each item of the load instruction reordering queue, wherein a bit having a first value indicates that the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed, and a bit having a second value indicates that the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed;
[0190] The violation signal is input into the checking unit to obtain a sequence identifier output by the checking unit, and the load instruction corresponding to the sequence identifier in the load instruction reordering queue is used as the first violation instruction.
[0191] Specifically, a violation signal can be generated based on the aforementioned first violation condition, second violation condition, or third violation condition, wherein the violation signal includes a plurality of bits, each bit of the violation signal corresponds one-to-one to each item of the load instruction reordering queue, and the value of each bit can be a first value or a second value, and a bit having a first value indicates that the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed, and the load instruction and the instruction to be executed together constitute a storage order violation; a bit having a second value indicates that the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed, and the load instruction and the instruction to be executed do not constitute a storage order violation. Exemplarily, the first value can be 1, and the second value can be 0, that is, when a certain bit of the violation signal is 1, the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed; when a certain bit of the violation signal is 0, the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed.
[0192] When the value of the bit in the violation signal is one and the first value is the bit, the load instruction corresponding to the bit is taken as the first violation instruction; when the value of the bit in the violation signal is one and the first value is the bit, the violation signal is input into the checking unit, and the order of multiple violation instructions is compared by the checking unit to obtain the order identifier output by the checking unit; the load instruction corresponding to the order identifier in the load instruction reordering queue is taken as the first violation instruction. In practical applications, the check request may include the violation signal corresponding to the instruction to be executed, and the violation signal corresponding to the check request with the first order in the check request queue is input into the checking unit to determine the first violation instruction corresponding to the instruction to be executed.
[0193] Exemplarily, taking the storage order violation of Store-Hit-Load as an example, based on the first violation condition, assuming that there are N items in the load instruction reordering queue, the sequence identifier of the instruction to be executed is compared with the sequence identifier in the load instruction reordering queue, and an older signal including N bits is generated. Each bit of the older signal corresponds to each item in the load instruction reordering queue one by one. The sequence identifier of the load instruction corresponding to the bit with a value of 1 in the older signal is greater than the sequence identifier of the instruction to be executed, and the sequence identifier of the load instruction corresponding to the bit with a value of 0 in the older signal is not greater than the sequence identifier of the instruction to be executed; the storage address of the instruction to be executed is compared with the load address in the load instruction reordering queue, and a match signal including N bits is generated. Each bit of the match signal corresponds to each item in the load instruction reordering queue one by one. The load address of the load instruction corresponding to the bit with a value of 1 in the match signal is the same as the storage address of the instruction to be executed. The loading address of the load instruction corresponding to the bit with a value of 0 in the match signal is different from the storage address of the instruction to be executed; the thread information of the instruction to be executed is compared with the thread information in the load instruction reordering queue to generate a thread signal including N bits, each bit of the thread signal corresponds to each item of the load instruction reordering queue one by one, the thread information of the load instruction corresponding to the bit with a value of 1 in the thread signal is the same as the thread information of the instruction to be executed, and the thread information of the load instruction corresponding to the bit with a value of 0 in the thread signal is different from the thread information of the instruction to be executed; according to the execution status in the load instruction reordering queue, a fin signal including N bits is generated, each bit of the fin signal corresponds to each item of the load instruction reordering queue one by one, the execution status of the load instruction corresponding to the bit with a value of 1 in the fin signal is executed, and the execution status of the load instruction corresponding to the bit with a value of 0 in the fin signal is not executed. The older signal, the match signal, the thread signal and the fin signal are bitwise ANDed to obtain a violation signal, in which the first value is 1 and the second value is 0, that is, when a certain bit of the violation signal is 1, the load instruction corresponding to the bit is a violation instruction associated with the instruction to be executed; when a certain bit of the violation signal is 0, the load instruction corresponding to the bit is not a violation instruction associated with the instruction to be executed. The violation signal is input into a multi-Hot detection circuit, and the multi-Hot detection circuit is used to determine whether the number of bits with a value of 1 in the violation signal is 1. If the number of bits with a value of 1 in the violation signal is 1, the violation signal is used as an index to determine the first violation instruction in the load instruction reordering queue; if the number of bits with a value of 1 in the violation signal is multiple, the first violation instruction is determined by the inspection unit.
[0194] In this example, by generating a violation signal representing a load instruction violation in the load instruction reordering queue, the violating instruction associated with the instruction to be executed can be accurately determined, and the first violating instruction among multiple violating instructions can be determined by the checking unit.
[0195] The structure of the checking unit may be various. In one example, the checking unit includes a selector and a binary tree comparator corresponding to each item in the load instruction reordering queue; the second determination module may also be used to:
[0196] Each bit of the violation signal corresponding to the instruction to be executed is used as an enable signal and input to the enable end of the selector corresponding to the corresponding item; wherein the selector corresponding to each item receives a preset value and a sequence identifier of the load instruction corresponding to the item, and is used to select the output sequence identifier when the enable signal is a first value, and to select the output preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue;
[0197] The result of the selector output corresponding to each item is input into the binary tree comparator to obtain the sequence identification of the binary tree comparator output; wherein the binary tree comparator is used to compare the results of all selector outputs and output the minimum result.
[0198] Specifically, the enable end of the 1 selector corresponding to each item in the load instruction reordering queue receives each bit value of the violation signal corresponding to the instruction to be executed, and the selector corresponding to each item receives a preset value and a sequence identifier of the load instruction corresponding to the item, and selects to output the sequence identifier of the load instruction corresponding to the item when the enable signal is a first value, and selects to output the preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue, so that it can be filtered out in the subsequent comparison of the binary tree comparator. The result output by each selector is input into the binary tree comparator, wherein the binary tree comparator is composed of multiple 2-input comparison selectors, each of which outputs a smaller input value, and finally obtains the smallest sequence identifier.
[0199] In the storage order violation processing device provided by the present embodiment, in the process of out-of-order execution of instructions for a program to be executed, for each current instruction to be executed, all violation instructions associated with the instruction to be executed are determined in the load instruction reordering queue according to the load addresses, thread information, execution status, snooped value and sequence identifier of different issued load instructions stored in the load instruction reordering queue, and the first violation instruction that is at the front in the program to be executed is determined from all the violation instructions associated with the instruction to be executed; the instructions are executed out of order for the first violation instruction in the program to be executed and the programs after it; therefore, when the storage order violation causes the execution result of part of the program to be erroneous, the violation instruction with the initial execution result erroneous in the program is accurately determined, and the execution is re-executed starting from the violation instruction, which can avoid wasting the program that has been executed correctly, reduce power consumption while solving the storage order violation, and improve the performance of the processor.
[0200] Embodiment 3
[0201] Fig. 9 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, such as Fig. 9 As shown, the electronic device includes:
[0202] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, the memory 292, and the communication interface 293 may communicate with each other through the bus 294. The communication interface 293 may be used for information transmission. The processor 291 may call the logic instructions in the memory 292 to execute the method of the above embodiment.
[0203] In addition, the logic instructions in the above-mentioned memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0204] The memory 292 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present disclosure. The processor 291 executes the software programs, instructions, and modules stored in the memory 292 to perform functional applications and data processing, that is, to implement the methods in the above method embodiments.
[0205] The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0206] An embodiment of the present disclosure provides a non-transitory computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method described in the above embodiment.
[0207] Embodiment 4
[0208] An embodiment of the present disclosure provides a computer program product, including a computer program. When the computer program is executed by a processor, the method provided in any embodiment of the present disclosure is implemented.
[0209] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0210] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A storage order violation processing method, characterized in that: include: In the process of out-of-order execution of instructions for the program to be executed, for each current instruction to be executed, all violating instructions associated with the instruction to be executed are determined according to the load instruction reordering queue; Determine a first violating instruction that is at the front of the program to be executed from all violating instructions associated with the instruction to be executed; wherein the first violating instruction is a load instruction; the load instruction reordering queue includes a plurality of items, different items correspond to different issued load instructions, and each item stores a load address of the load instruction corresponding to the item, thread information of the load instruction corresponding to the item, an execution state of the load instruction corresponding to the item, a snooped value of the load instruction corresponding to the item, and a sequence identifier of the load instruction corresponding to the item; Performing out-of-order execution of the first violating instruction and subsequent programs in the program to be executed; Among them, determining all violation instructions associated with the instruction to be executed based on the load instruction reordering queue includes: determining the violation condition corresponding to the instruction to be executed based on the instruction type of the instruction to be executed; and determining all violation instructions associated with the instruction to be executed based on the violation condition and the load instruction reordering queue.
2. The method according to claim 1, characterized in that The step of determining all illegal instructions associated with the instruction to be executed according to the load instruction reordering queue includes: If the instruction to be executed is a storage instruction, an instruction in the load instruction reordering queue that satisfies a first violation condition is used as a violation instruction associated with the instruction to be executed; the first violation condition includes that thread information is the same as thread information where the instruction to be executed is located, and the load address is the same as the storage address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; If the instruction to be executed is a load instruction, an instruction in the load instruction reordering queue that satisfies a second violation condition is used as a violation instruction associated with the instruction to be executed; the second violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the load address is the same as the load address of the instruction to be executed, and the execution state indicates that the execution has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1; If the instruction to be executed is a synchronous instruction, the instruction in the load instruction reordering queue that meets the third violation condition is used as the violation instruction associated with the instruction to be executed; the third violation condition includes that the thread information is the same as the thread information where the instruction to be executed is located, and the execution status representation of all violation instructions associated with the instruction to be executed has been completed, and the sequence identifier is greater than the sequence identifier corresponding to the instruction to be executed; and the snooped value is 1.
3. The method according to claim 1, characterized in that The step of determining the first violating instruction which is at the front of the program to be executed from all the violating instructions associated with the instruction to be executed comprises: If the number of the violation instructions associated with the to-be-executed instruction is one, the violation instruction is taken as the first violation instruction; If there are multiple violating instructions associated with the instruction to be executed, then according to the sequence identifiers of all the violating instructions associated with the instruction to be executed, the violating instruction with the smallest sequence identifier is used as the first violating instruction.
4. The method according to claim 1, characterized in that Before determining the first violating instruction which is the frontmost in the program to be executed from all the violating instructions associated with the to-be-executed instructions, the method further comprises: If there are multiple violation instructions associated with the instruction to be executed, a check request corresponding to the instruction to be executed is generated, wherein the check request corresponding to the instruction to be executed includes the instruction identifier of the instruction to be executed and the sequence identifiers of all violation instructions associated with the instruction to be executed; the check request corresponding to the instruction to be executed is added to the check request queue; The step of determining the first violating instruction which is at the front of the program to be executed from all the violating instructions associated with the instruction to be executed comprises: For the to-be-executed instruction corresponding to the first check request in the check request queue, a first violating instruction which is at the front in the to-be-executed program is determined from all violating instructions associated with the to-be-executed instruction.
5. The method according to claim 4, characterized in that The step of performing out-of-order execution of the first violating instruction and subsequent programs in the program to be executed includes: End the out-of-order execution of the current instruction and obtain the instruction identifier of the first violating instruction; and read the program counter value corresponding to the first violating instruction from the instruction reordering buffer according to the instruction identifier of the first violating instruction; According to the program counter value corresponding to the first violating instruction, instructions of the instruction whose instruction address in the to-be-executed program is the program counter value corresponding to the first violating instruction and the subsequent program are executed out of order.
6. The method according to claim 5, characterized in that After the out-of-order execution of the instructions is terminated, the following steps are further included: Determining a second inspection request in the inspection request queue, wherein the instruction identifier in the second inspection request is greater than the instruction identifier of the first violating instruction; The second inspection request is cleared from the inspection request queue.
7. The method according to any one of claims 1 to 6, characterized in that: The step of determining the first violating instruction which is at the front of the program to be executed from all the violating instructions associated with the instruction to be executed comprises: Generate a violation signal corresponding to the instruction to be executed according to all violation instructions associated with the instruction to be executed, wherein the violation signal includes a plurality of bits, and each bit of the violation signal corresponds one-to-one to each item of the load instruction reordering queue, wherein the first value of the bit indicates that the load instruction corresponding to the bit is the violation instruction associated with the instruction to be executed, and the second value of the bit indicates that the load instruction corresponding to the bit is not the violation instruction associated with the instruction to be executed; The violation signal is input into a checking unit to obtain a sequence identifier output by the checking unit, and a load instruction corresponding to the sequence identifier in the load instruction reordering queue is used as the first violation instruction.
8. The method according to claim 7, characterized in that The checking unit includes a selector and a binary tree comparator corresponding to each item in the load instruction reordering queue; the step of inputting the violation signal into the checking unit to obtain a sequence identifier output by the checking unit includes: Each bit of the violation signal corresponding to the instruction to be executed is used as an enable signal and input to the enable end of the selector corresponding to the corresponding item; wherein the selector corresponding to each item receives a preset value and a sequence identifier of the load instruction corresponding to the item, and is used to select to output the sequence identifier when the enable signal is a first value, and to select to output the preset value when the enable signal is a second value; wherein the preset value is greater than the sequence identifiers of all load instructions in the load instruction reordering queue; The result of the selector output corresponding to each item is input into the binary tree comparator to obtain the sequence identifier of the binary tree comparator output; wherein the binary tree comparator is used to compare the results of all selector outputs and output the minimum result.
9. A storage order violation processing device, characterized in that: include: A first determination module is used to determine, for each current instruction to be executed, all violation instructions associated with the instruction to be executed according to the load instruction reordering queue during the process of out-of-order execution of instructions for the program to be executed; A second determination module is used to determine the first violating instruction that is the frontmost in the program to be executed from all the violating instructions associated with the instruction to be executed; wherein the first violating instruction is a load instruction; the load instruction reordering queue includes a plurality of items, different items correspond to different issued load instructions, and each item stores a load address of the load instruction corresponding to the item, thread information of the load instruction corresponding to the item, execution status of the load instruction corresponding to the item, snooped value of the load instruction corresponding to the item, and sequence identifier of the load instruction corresponding to the item; An execution module, used for executing the first violating instruction and subsequent programs in the program to be executed out of order; The first determination module is specifically configured to determine, according to the instruction type of the instruction to be executed, a violation condition corresponding to the instruction to be executed; and, according to the violation condition and the load instruction reordering queue, determine all violation instructions associated with the instruction to be executed.
10. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
Citation Information
Cited By
Memory access violation prediction method and system, terminal and storage medium
CN119536811A
Instruction reloading method and device, electronic equipment and storage medium
CN122152369A
