Method for constructing pipeline execution timing diagram
By building a pipeline execution timing chart of the PowerPC E500 processor, the modeling problem of the existing technology not being able to support the processor is solved, and accurate analysis and tool support for its worst-case execution time is achieved, improving processor performance and analysis Accuracy.
Patent Information
- Application Number
- PCT/CN2024/090981
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-29
- Filing Date
- 2024-04-30
- Publication Date
- 2024-12-05
AI Technical Summary
The prior art is unable to support pipeline execution timing diagram modeling of PowerPC E500 processors, resulting in failure to ensure system execution time analysis in the worst-case scenario.
By obtaining the processing stage and hardware characteristic parameters that each instruction in the target basic block needs to go through, determining the dependency and competition relationship between instructions, and building an execution timing chart, where each node corresponds to a processing stage, and the edge represents the dependency and competition relationship. .
The foundation for worst-case execution time analysis of PowerPC E500 processors is implemented, accurate WCET analysis tools are provided, and integrated modeling of branch prediction and cache is supported, improving the accuracy of program execution time.
Smart Images

Figure CN2024090981_05122024_PF_FP_ABST
Abstract
Description
A method for constructing pipeline execution timing diagram
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This disclosure is based on Chinese patent application CN202310617687.2, filed on May 29, 2023, entitled “A Method for Constructing a Pipeline Execution Timing Diagram”, and claims the priority of the patent application, and all the contents disclosed therein are incorporated into this disclosure by reference. Technical Field
[0003] The present disclosure relates to the field of embedded systems, and in particular to a method for constructing a pipeline execution timing diagram. Background Art
[0004] In high-security, high-reliability embedded real-time systems, such as those in aerospace, energy, and transportation, system correctness depends not only on the execution results but also on the time it takes to produce them. Failure to complete tasks on time can have disastrous consequences. To ensure that system performance meets stringent time safety requirements, it is necessary to measure the system's worst-case execution time (WCET) to facilitate proper scheduling design and hardware configuration.
[0005] In the related art, the execution time of the basic block is measured in an actual hardware environment (known as the measurement-based WCET analysis method in the industry), but it cannot ensure that all scenarios are covered and cannot guarantee a safe worst-case execution time.
[0006] Related technologies also simulate and abstract hardware such as the processor's pipeline, branch prediction, and cache, and then theoretically estimate the maximum execution time of a basic block based on the resulting abstract model (known in the industry as a static WCET analysis method). Pipeline modeling is the most critical and fundamental step in static WCET analysis, and the mainstream method used in this step is the pipeline execution timing diagram method. However, because the pipeline execution timing diagram is tightly coupled with the processor architecture, the structures of different processor models of the same type may vary. In addition, the PowerPC E500 processor supports complex features such as superscalar and out-of-order execution. Therefore, neither commercial nor open source software currently supports pipeline execution timing diagram modeling for the PowerPC E500 processor.
[0007] In summary, there is no corresponding solution to the problem that pipeline execution timing diagram modeling in related technologies cannot support the PowerPC E500 processor.
[0008] Summary of the Invention
[0009] The embodiments of the present disclosure provide a method for constructing a pipeline execution timing diagram, so as to at least solve the problem in the related art that the pipeline execution timing diagram modeling cannot support the PowerPC E500 processor.
[0010] According to an embodiment of the present disclosure, a method for constructing a pipeline execution timing graph is provided, which is applied to a PowerPC E500 processor. The method includes: obtaining multiple processing stages that each instruction of multiple instructions of a target basic block needs to pass through sequentially, and extracting hardware characteristic parameters of the multiple processing stages respectively; determining the dependency and competition relationships between the multiple instructions based on the multiple processing stages and the hardware characteristic parameters; and constructing an execution timing graph of the target basic block based on the dependency and competition relationships, wherein each node in the execution timing graph corresponds to a processing stage of an instruction, and the edges in the execution timing graph correspond to the dependency and competition relationships.
[0011] According to another embodiment of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are executed.
[0012] According to another embodiment of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] FIG1 is a hardware structure block diagram of a method for constructing a pipeline execution timing diagram according to an embodiment of the present disclosure;
[0014] FIG2 is a flow chart of a method for constructing a pipeline execution timing diagram according to an embodiment of the present disclosure;
[0015] FIG3 is a schematic diagram of an abstract pipeline model of a PowerPC E500 processor according to an embodiment of the present disclosure;
[0016] FIG4 is a pipeline execution timing diagram of a basic block according to an embodiment of the present disclosure;
[0017] FIG5 is a schematic diagram of competition relationships in a pipeline execution timing diagram according to an embodiment of the present disclosure;
[0018] FIG6 is a schematic diagram of dependency relationships in a pipeline execution timing diagram according to an embodiment of the present disclosure (I);
[0019] FIG7 is a schematic diagram of dependency relationships in a pipeline execution timing diagram according to an embodiment of the present disclosure (II);
[0020] FIG8 is a block diagram of a device for constructing a pipeline execution timing diagram according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings and in conjunction with the embodiments.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0023] The method embodiments provided in the embodiments of the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, FIG1 is a hardware structure block diagram of the method for constructing a pipeline execution timing diagram of an embodiment of the present disclosure. As shown in FIG1 , the hardware board may include one or more (only one is shown in FIG1 ) processors 12 (the processor 12 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device) and a memory 14 for storing data, wherein the above-mentioned mobile terminal may also include a transmission device 16 and an input and output device 18 for communication functions. It can be understood by those skilled in the art that the structure shown in FIG1 is only for illustration and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may also include more or fewer components than those shown in FIG1 , or have a configuration different from that shown in FIG1 .
[0024] The memory 14 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for constructing the pipeline execution timing diagram in the embodiment of the present disclosure. The processor 12 executes various functional applications and the method for constructing the pipeline execution timing diagram by running the computer program stored in the memory 14, that is, implementing the above method. The memory 14 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 14 may further include a memory remotely located relative to the processor 12, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0025] The transmission device 16 is used to receive or send data via a network. Specific examples of the aforementioned network may include a wireless network provided by a communications provider. In one embodiment, the transmission device 16 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 16 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0026] In one embodiment of the present disclosure, a method for constructing a pipeline execution timing diagram is provided. FIG2 is a flow chart of the method for constructing a pipeline execution timing diagram according to an embodiment of the present disclosure. As shown in FIG2 , the process includes the following steps:
[0027] Step S202 , obtaining multiple processing stages that each instruction of the target basic block needs to sequentially pass through, and extracting hardware characteristic parameters of the multiple processing stages respectively;
[0028] Step S204, determining the dependency and competition relationships among the multiple instructions based on the multiple processing stages and hardware characteristic parameters;
[0029] Step S206 : constructing an execution sequence diagram of the target basic block according to the dependency relationship and the competition relationship.
[0030] In the embodiment of the present disclosure, the above steps S202 to S206 can solve the problem in the related art that pipeline execution timing diagram modeling cannot support the PowerPC E500 processor, laying a foundation for the worst-case execution time analysis of the PowerPC E500 processor.
[0031] In this embodiment, the multiple processing stages that each instruction needs to sequentially go through in step S202 may specifically include: an instruction fetch stage, a decoding and scheduling stage, an issue stage, an execution stage, a completion stage, and a write-back stage.
[0032] The embodiments of the present disclosure are mainly directed to the PowerPC E500 processor, which is a 32-bit microprocessor core based on the Freescale Power Architecture main processor. By abstracting the pipeline of the PowerPC E500 processor, the above-mentioned multiple processing stages related to the instruction execution timing can be obtained.
[0033] Furthermore, pipelining technology refers to a technology that breaks down instructions into multiple processing stages and allows the processing stages of different instructions to overlap, thereby realizing parallel processing of multiple instructions to speed up the program running process.
[0034] In this embodiment, the multiple processing stages in the PowerPC E500 processor respectively perform the following operations:
[0035] Instruction fetch stage, which reads instructions from memory or cache and saves them into the instruction queue;
[0036] The decoding and scheduling phase decodes the instruction and decides whether to schedule it to the emission queue based on the current hardware resources. It also allocates a position in the completion queue to ensure that the execution results can be written back in order.
[0037] The issue stage, which reads the instruction's source operands from the rename registers and register file and decides when to latch the instruction into the execution unit's reservation station;
[0038] The execution phase executes the instructions assigned to the various execution units and writes the results to the result bus;
[0039] The completion phase ensures the correct machine state and delivers results in the correct order.
[0040] The write-back stage ensures that the computation results are written to the architecturally defined registers in the correct order.
[0041] In this embodiment, the execution timing graph in step S206 includes multiple nodes and multiple edges, each node corresponds to a processing stage of an instruction, and each edge corresponds to a dependency relationship and a competition relationship.
[0042] In an exemplary embodiment, step S202 may specifically include the following steps:
[0043] Step S2021, obtaining the instruction queue size and instruction fetch overscaling metric of the processor in the instruction fetch phase;
[0044] Step S2022, obtaining a transmit queue size, a completion queue size, a decoding overscaling metric, and a scheduling overscaling metric of the processor in the decoding scheduling phase;
[0045] Step S2023, obtaining a transmission over-scale metric of the processor in the transmission phase;
[0046] Step S2024, obtaining the number of execution units of the processor in the execution phase;
[0047] Step S2025, obtaining a completion overscaling metric of the processor in the completion phase;
[0048] Step S2026, obtaining a commit overscaling metric of the processor in the write-back phase;
[0049] Furthermore, the hardware characteristic parameters include: instruction queue size, instruction fetch overscaling metric, issue queue size, completion queue size, scheduling overscaling metric, issue overscaling metric, number of execution units, completion overscaling metric, and commit overscaling metric.
[0050] In this embodiment, step S204 may specifically include: determining the dependency relationship between the same instruction or different instructions in the multiple instructions in the multiple processing stages according to the order of the multiple processing stages and the hardware characteristic parameters; and determining the competitive relationship between different instructions in the multiple instructions in the execution stage according to the hardware characteristic parameters.
[0051] In an exemplary embodiment, the dependency relationship in step S204 may include: phase dependency relationship, sequence dependency relationship, queue dependency relationship, and data dependency relationship.
[0052] Furthermore, determining the dependency relationship of the same instruction or different instructions in the multiple instructions in the multiple processing stages according to the order of the multiple processing stages and the hardware characteristic parameters in step S204 may specifically include the following steps:
[0053] Step S2041, determining the stage dependency of each instruction in the multiple processing stages according to the order of the multiple processing stages;
[0054] Step S2042, determining sequential dependencies of different instructions in the plurality of processing stages according to the instruction fetch overscalar metric, the decode overscalar metric, the schedule overscalar metric, the transmit overscalar metric, and the commit overscalar metric in the hardware characteristic parameters;
[0055] Step S2043: determining queue dependencies of different instructions in mutually related processing stages based on the instruction queue size, the issue queue size, and the completion queue size in the hardware characteristic parameters, wherein the decode scheduling stage is mutually related to any of the following processing stages: the instruction fetch stage, the issue stage, and the completion stage;
[0056] Step S2044 : determining data dependencies of the multiple instructions in the execution phase according to the instruction contents of the multiple instructions.
[0057] In one embodiment, the stage dependency in step S2041 means that each instruction must pass through the instruction fetch stage, decode scheduling stage, issue stage, execution stage, completion stage, and write-back stage in sequence in the pipeline, and the next stage can only start after the previous stage is completed.
[0058] In one embodiment, the sequential dependency in step S2042 means that all instructions in the basic block must be executed in the order of their instruction numbers in all processing stages except the execute stage. The PowerPC E500 processor supports superscalar processing, meaning that each processing stage can fetch multiple instructions for parallel execution within a cycle. The instruction fetch superscalar metric indicates the number of instructions that can be processed in parallel in the instruction fetch stage. Similarly, the decode superscalar metric, the schedule superscalar metric, the issue superscalar metric, and the commit superscalar metric also indicate the number of instructions that can be processed in parallel in the corresponding processing stage.
[0059] In one embodiment, the queue dependency in step S2043 is caused by buffer queue size limitation.
[0060] Specifically, when the instruction queue is full, the decoding and scheduling stage needs to take out the instruction from the instruction queue before there is a free space in the instruction queue, and new instructions can be put into the instruction queue; when the emission queue is full, the emission queue needs to take out the instruction from the emission queue during the emission stage before there is a free space in the emission queue, and new instructions can be decoded and scheduled into the emission queue; when the completion queue is full, the completion stage needs to take out the instruction from the completion queue before there is a free space, and new instructions can be decoded and scheduled into the completion queue.
[0061] In one embodiment, the data dependency in step S2044 means that a certain instruction requires the execution result of another instruction. If the execution result has not yet been generated, the instruction that depends on the execution result will be blocked until the execution result is generated.
[0062] Furthermore, the processing stages involved in data dependencies may also differ depending on the type of the dependent instruction. Specifically, the results of most instructions in the PowerPC E500 processor are written to the rename register after the execute phase, allowing subsequent instructions to use them without waiting for the writeback phase. However, load / store instructions are an exception; their results must be written back before they can be used by subsequent instructions.
[0063] In this embodiment, determining the competition relationship between different instructions in the execution phase according to the hardware characteristic parameters in step S204 may specifically include:
[0064] Step S2045, judging whether any two instructions among the multiple instructions meet a preset condition based on the distance between the different instructions, the completion queue size, and the instruction content of the multiple instructions, and determining the competition relationship between the two instructions that meet the preset condition if the judgment result is yes.
[0065] Furthermore, the processor's hardware characteristic parameters also include an out-of-order execution attribute, which indicates whether the processor supports out-of-order execution. This attribute indicates whether multiple instructions within a basic block can be run out of order during the execution phase. The PowerPC E500 processor supports out-of-order execution during the execution phase, which can reduce pipeline stalls and improve processor performance.
[0066] In this embodiment, each execution unit can only process one instruction at a time. Since the PowerPC E500 processor supports out-of-order execution, two instructions may use a certain execution unit at the same time. In addition, the number of various execution units of the processor is limited, and the execution of the two instructions may cause competition for execution unit resources.
[0067] Furthermore, one of the two competing instructions must be blocked and must wait until the other instruction is completed and the execution unit is released before entering the execution phase.
[0068] In an exemplary embodiment, step S2045 may specifically include: judging whether the distance between any two instructions is less than or equal to the completion queue size based on the distance between the different instructions; judging whether the execution stages of the two instructions use the same execution unit based on the instruction contents of the multiple instructions; judging whether there is no data dependency between the two instructions based on the instruction contents of the multiple instructions; if the judgment results are all yes, determining that the corresponding two instructions meet the preset conditions; if any judgment result is no, determining that the corresponding two instructions do not meet the preset conditions.
[0069] Furthermore, instructions of the same instruction type use the same execution unit. For example, load / store instructions use the load / store unit, and multiplication / division instructions use the multiplication / division unit. A data dependency relationship means that one instruction requires the execution result of another instruction. For example, instruction 1 is "mult r1 r2 r3", which calculates the product of r2 and r3 to be r1, and instruction 2 is "mult r5 r1 r4", which calculates the product of r1 and r4 to be r5. Instruction 2 requires the execution result of instruction 1. There is a data dependency relationship between the two. In this case, even if other conditions are met, there is no competition between instructions 1 and 2.
[0070] In an exemplary embodiment, there may be multiple execution units of each type. When the number of instructions in a competing relationship is greater than the number of corresponding execution units, at least one instruction must be blocked.
[0071] In this embodiment, step S206 may specifically include the following steps:
[0072] Step S2061, setting a node for each of the plurality of processing stages corresponding to each instruction in the plurality of instructions;
[0073] Step S2062: Based on the dependency relationship, if the first node depends on the second node, a directed dependency edge is established with the second node as the source node and the first node as the target node, wherein the first node and the second node represent any processing stage of any instruction;
[0074] Step S2063: When the competition relationship exists between the third node and the fourth node, an undirected competition edge is established between the third node and the fourth node, wherein the third node and the fourth node are the execution stages of any instruction.
[0075] The pipeline execution timing diagram method is currently the most mainstream pipeline modeling method in the industry. This method uses each pipeline stage of each instruction as a node, establishes edges between nodes based on the instruction address sequence and the dependency and competition relationships between the various pipeline stages of the instruction, and finally forms an execution timing diagram. Based on this timing diagram, the instruction sequence execution time is evaluated.
[0076] Through the disclosed embodiments, a pipeline execution timing diagram for the PowerPC E500 processor can be created. This can be used to accurately calculate the maximum possible execution time of basic block instruction sequences, providing a core foundation for the design and development of static worst-case execution time (WCET) analysis tools for the PowerPC E500 processor. Furthermore, based on the pipeline execution timing diagram, modeling models for other core processor components, such as branch prediction and cache, can be easily integrated to perform more accurate worst-case program execution time analysis.
[0077] In this embodiment, a basic block refers to a sequence of instructions executed sequentially in a program. A basic block has only one entry and one exit: the entry is the first statement in the block, and the exit is the last statement. A basic block is the fundamental unit of WCET analysis.
[0078] FIG3 is a schematic diagram of an abstract pipeline model of a PowerPC E500 processor according to an embodiment of the present disclosure. As shown in FIG3 , the abstract pipeline model of the PowerPC E500 processor specifically includes the following processing stages:
[0079] Fetch Stage 31 , Decode / Dispatch Stage 32 , Issue Stage 33 , Execute Stage 34 , Completion Stage 35 , and Write-Back Stage 36 .
[0080] In this embodiment, the pipeline of the PowerPC E500 processor is abstracted into a 6-stage model, and hardware characteristics related to instruction execution timing are extracted from these 6 stages, while other details are ignored.
[0081] In this embodiment, the description of each processing stage is as follows:
[0082] Instruction fetch stage 31, this stage reads instructions from memory or cache and stores them in the instruction queue. Hardware characteristics related to instruction execution timing that need to be collected in this stage include: instruction queue size and instruction fetch overscaling metric.
[0083] Decode and schedule stage 32 decodes the instruction. The PowerPC E500 processor pipeline also determines whether to schedule the instruction to the issue queue based on current hardware resources. When scheduling an instruction to the issue queue, it also allocates a slot in the completion queue to ensure that the execution results are subsequently written back in order. Hardware characteristics related to instruction execution timing that need to be collected in this stage include: issue queue size, completion queue size, decoding overscaling metric, and scheduling overscaling metric.
[0084] Issue stage 33, PowerPC E500 processor pipeline design. This stage reads the instruction's source operands from the rename register and register file and determines when to latch the instruction into the execution unit's reservation station. Hardware characteristics related to instruction execution timing that need to be collected at this stage include issue overscaling metrics.
[0085] The execution phase 34 executes the instructions assigned to each execution unit and writes the results to the result bus. Hardware characteristics related to instruction execution timing that need to be collected in this phase include out-of-order execution and the number of execution units.
[0086] Complete stage 35. The PowerPC E500 processor pipeline is designed to ensure the correct machine state and deliver results in the correct order. Hardware characteristics related to instruction execution timing that need to be collected in this stage include: completing superscalar measurements.
[0087] In the write-back phase 36, the computation results are written to the architecture-defined registers in the correct order. Hardware characteristics related to instruction execution timing that need to be collected in this phase include: submitting superscalar metrics.
[0088] In this embodiment, the transmit stage 33 and the complete stage 35 are processing stages unique to the PowerPC E500 processor, and the decode scheduling stage 32 also has the characteristics of the PowerPC E500 processor.
[0089] In this embodiment, the rename register is used to store the results of instructions that have completed execution but have not yet been written back. The function of saving the results to the rename register allows subsequent instructions to access the new value before the new value is written back, thereby improving processor performance.
[0090] In this embodiment, the reservation station is a buffer between the issue stage and the execute stage that allows instructions to be issued even if resources required for execution or the results of other instructions that the issued instruction may depend on are not yet available.
[0091] Through the embodiments of the present disclosure, an abstract pipeline model of the PowerPC E500 processor can be constructed, which is also the most basic and critical step in constructing a pipeline execution timing diagram of the PowerPC E500 processor.
[0092] In another embodiment, based on the pipeline abstract model in the above embodiment, combined with the execution timing logic of the PowerPC E500 processor instructions in the pipeline, the dependency and competition relationship between the various pipeline processing stages of each instruction in a basic block can be analyzed, providing a theoretical basis for constructing a pipeline execution timing diagram.
[0093] In one embodiment, for two pipeline stages I and J in a pipeline, if J must start after I is completed, then J is said to be dependent on I, that is, there is a dependency relationship between J and I.
[0094] Specifically, I and J may be different pipeline stages of the same instruction, or the same or different pipeline stages of different instructions.
[0095] In the embodiments of the present disclosure, dependencies may specifically include: dependencies between different pipeline stages of the same instruction (i.e., stage dependencies), sequence dependencies between instructions, dependencies between different instructions caused by buffer queue size limitations (i.e., queue dependencies), and data dependencies between instructions, but the present disclosure is not limited to the above dependencies.
[0096] In one embodiment, the stage dependency specifically includes: an instruction must go through the six stages of instruction fetch, decode / scheduling, emission, execution, completion, and write-back in sequence in the pipeline to be completed. The next stage can only start after the previous stage is completed, so a certain stage depends on the previous stage.
[0097] In one embodiment, the order dependency may include but is not limited to the following dependencies: order dependency in the instruction fetch stage, order dependency in the decode scheduling stage, order dependency in the issue stage, and order dependency in the write-back stage.
[0098] Furthermore, the sequential dependencies can be analyzed and determined according to the following method:
[0099] The order dependency of the instruction fetch stage. If the processor's instruction fetch overscaling metric is n, the instruction fetch stage of instruction i+n can only start after the instruction fetch stage of instruction i is completed. Therefore, the instruction fetch stage of instruction i+n depends on the instruction fetch stage of instruction i.
[0100] Decoding and scheduling order dependency. If the processor's decoding superscalar metric or scheduling superscalar metric is n, instruction i+n can only start decoding and scheduling after the decoding / scheduling stage of instruction i is completed. Therefore, the decoding / scheduling stage of instruction i+n depends on the decoding / scheduling stage of instruction i.
[0101] The order dependency of the emission phase. If the processor's emission overscaling metric is n, instruction i+n can only start entering the emission phase after the emission phase of instruction i is completed. Therefore, the emission phase of instruction i+n depends on the emission phase of instruction i.
[0102] Sequential dependency of the write-back phase. If the processor's commit superscalar metric is n, instruction i+n can only start its write-back phase after the write-back phase of instruction i is completed. Therefore, the write-back phase of instruction i+n depends on the write-back phase of instruction i.
[0103] In one embodiment, queue dependencies may include but are not limited to the following dependencies: dependencies caused by instruction queue size limitations, dependencies caused by issue queue size limitations, and dependencies caused by completion queue size limitations.
[0104] Furthermore, queue dependencies can be analyzed and determined using the following methods:
[0105] The dependency caused by the instruction queue size limit is that when the instruction queue is full, the decoding stage needs to take out instructions from the instruction queue before there is a free position in the instruction queue and new instructions can be put into the instruction queue. Therefore, if the instruction queue size is n, the instruction fetch stage of instruction i+n depends on the decoding stage of instruction i.
[0106] The issue queue size limit causes dependencies. When the issue queue is full, the issue phase must retrieve instructions from the issue queue before there are free slots in the issue queue to decode and schedule new instructions into the issue queue. Therefore, if the issue queue size is n, the decode phase of instruction i+n depends on the issue phase of instruction i.
[0107] The dependency caused by the completion queue size limit is that when the completion queue is full, the completion stage must retrieve an instruction from the completion queue before a free slot is available to decode and schedule a new instruction into the completion queue. Therefore, if the completion queue size is n, the decoding stage of instruction i+n depends on the completion stage of instruction i.
[0108] In one embodiment, data dependencies can be analyzed and determined according to the following method: if an instruction i needs to use the execution result of a previous instruction j, and when instruction i is ready to enter the execution stage, the execution result of instruction j has not yet been generated, then instruction i will be blocked until instruction j is completed and the result is available before execution can begin. This situation is called instruction i having a data dependency on instruction j, and a dependency relationship needs to be established.
[0109] Furthermore, the results of most instructions in the PowerPC E500 processor are written to the rename register after the execution phase, and subsequent instructions can use them without waiting for the write-back phase to end. However, load / store instructions are an exception. The results must be written back before they can be used by subsequent instructions. Therefore, the following two data dependencies need to be established:
[0110] If j is a load / store instruction, the execute phase of instruction i depends on the write-back phase of instruction j;
[0111] If j is any other instruction, the execution phase of instruction i depends on the execution phase of instruction j.
[0112] In the disclosed embodiment, since the PowerPCE500 processor pipeline supports out-of-order execution, two instructions may use a certain execution unit at the same time. In addition, the number of various execution units of the processor is limited. The execution of the two instructions may cause competition for the execution unit resources. Once competition occurs, one of the instructions will be blocked and must wait until the other instruction is completed and the execution unit is released before entering the execution stage.
[0113] In this embodiment, for the PowerPC E500 processor, the preset conditions for determining whether two instructions are in contention specifically include the following conditions: the two instructions are simultaneously present in the completion queue, that is, the distance between the two instructions cannot exceed the completion queue size, otherwise the two instructions cannot be executed simultaneously and contention cannot occur; the two instructions use the same execution unit; and there is no data dependency between the two instructions.
[0114] Furthermore, the execution phases of instructions i and j that meet the above preset conditions will compete with each other, and a competition relationship needs to be established between the two instruction execution phases.
[0115] In this embodiment, the execution stage includes multiple different types of execution units, and each type of execution unit may have one or more, such as a load / store unit (LSU), a multiplication / division unit (MU), an addition / subtraction unit (SU), etc. The present disclosure is not limited to the above-mentioned execution units.
[0116] FIG4 is a pipeline execution timing diagram of a basic block according to an embodiment of the present disclosure. As shown in FIG4 , the first column on the left is an example of an instruction sequence of a basic block, and the right is an execution timing diagram corresponding to the instruction sequence.
[0117] In this embodiment, the instruction sequence of the basic block includes 7 instructions, I1 to I7.
[0118] In this embodiment, each row in the execution timing diagram contains 6 nodes corresponding to the 6 pipeline stages of the instruction on the left, the solid lines are directed dependency edges between these pipeline stages, and the dotted lines are undirected competition edges between these pipeline stages.
[0119] In this embodiment, the six pipeline stages are: fetch stage, decode scheduling stage, issue stage, execute stage, completion stage, and write-back stage. Each instruction needs to pass through the six pipeline stages in sequence.
[0120] In this embodiment, the slash in FIG4 is used to represent the queue dependency.
[0121] Specifically, queue dependencies may include: dependencies caused by instruction queue size limitations, dependencies caused by transmit queue size limitations, and dependencies caused by completion queue size limitations.
[0122] Furthermore, for example, if the size of the transmit queue is 4, the transmit queue needs to have a free position after the I1 instruction is taken out from the transmit queue during the transmit phase of the I1 instruction, and the I5 instruction can be decoded and scheduled to enter the transmit queue.
[0123] Figure 5 is a schematic diagram of competition relationships in a pipeline execution timing diagram according to an embodiment of the present disclosure. As shown in Figure 5, the dotted lines are undirected competition edges, indicating the competition relationships between multiple instructions in a basic block during the execution phase.
[0124] In this embodiment, the determination of the contention relationship requires that the following conditions are simultaneously met: the distance between the two instructions does not exceed the completion queue size, the execution phases of the two instructions use the same execution unit, and there is no data dependency between the two instructions.
[0125] In this embodiment, instructions I1, I2, and I4 are multiplication instructions. When the processor includes only one multiplication / division unit and the distance between instructions does not exceed the completion queue size, the execution stages of I1, I2, and I4 compete with each other.
[0126] In this embodiment, instruction I3 is a subtraction instruction, and instructions I5 and I7 are addition instructions. When the processor includes only one addition / subtraction unit and the distance between instructions does not exceed the completion queue size, there is a competitive relationship between the execution stages of I3 and I5, and I5 and I7.
[0127] Furthermore, in this embodiment, the distance between I3 and I7 exceeds the completion queue size, and there is no competition between the execution phases of I3 and I7.
[0128] FIG6 is a schematic diagram (I) of dependency relationships in a pipeline execution timing diagram according to an embodiment of the present disclosure. As shown in FIG6 , a directed dependency edge represents a stage dependency relationship or a sequence dependency relationship between two nodes.
[0129] In this embodiment, the horizontal directed dependency edge is a stage dependency, indicating that the next stage of the same instruction depends on the completion of the previous stage of the instruction. The stage dependency of the same instruction in other adjacent stages is expressed in the same way.
[0130] In this embodiment, the vertical directed dependency edges represent sequential dependencies. The sequential dependencies of the instruction fetch phases are determined by the instruction fetch overscaling metric. When the instruction fetch overscaling metric is 2, the instruction fetch phase of instruction I1 in the basic block can only proceed to the instruction fetch phase of instruction I3. The instruction fetch phase of instruction I4 depends on the instruction fetch phase of instruction I2, and so on.
[0131] Furthermore, since the instruction fetch, decode scheduling, issue, and completion stages do not support out-of-order execution but do support superscalar execution, these stages all need to analyze the order dependencies of different instructions in the same stage based on the corresponding superscalar parameters. The order dependencies of the other stages described above are expressed in the same way as the instruction fetch stage.
[0132] Specifically, the superscalar parameters include fetch superscalar metrics, decode superscalar metrics, schedule superscalar metrics, transmit superscalar metrics, and commit superscalar metrics. In some embodiments, the decode superscalar metrics and the schedule superscalar metrics are the same and can be replaced by the decode schedule superscalar metrics.
[0133] FIG7 is a schematic diagram (II) of dependency relationships in a pipeline execution timing diagram according to an embodiment of the present disclosure. As shown in FIG7 , a directed dependency edge represents a data dependency relationship between two nodes.
[0134] In this embodiment, if an instruction i needs to use the execution result of a previous instruction j, and when instruction i is ready to enter the execution stage, the execution result of instruction j has not yet been generated, then instruction i will be blocked until instruction j is completed and the result is available before it can start execution. This situation is called instruction i having data dependency on instruction j.
[0135] In this embodiment, the results of most instructions of the PowerPC E500 processor will be written to the rename register after the execution phase ends, and subsequent instructions can use them without waiting for the write-back phase to end. However, load / store instructions are an exception. The results need to be written back before they can be used by subsequent instructions. Therefore, it is necessary to establish data dependency relationships for two situations: if j is a load / store instruction, the execution phase of instruction i depends on the write-back phase of instruction j; if j is any other instruction, the execution phase of instruction i depends on the execution phase of instruction j.
[0136] In this embodiment, the I3 instruction is "sub r6 r6 r2", which requires r6 and r2, where r6 is the execution result of I1 "mult r6 r10 4". Therefore, the execution stage of the I3 instruction depends on the execution stage of the I1 instruction.
[0137] In this embodiment, the I6 instruction is "LD r3 16(r1)," a load instruction (using the LSU) used to load the data from r3. The I7 instruction is "add r2 r3 r2," meaning the I7 execution phase requires the data from r3. Therefore, the I7 execution phase depends on the I6 writeback phase. The completion phase node is omitted in this embodiment.
[0138] According to another aspect of the embodiment of the present disclosure, a device for constructing a pipeline execution timing diagram is provided, which is applied to a PowerPC E500 processor.
[0139] FIG8 is a block diagram of a device for constructing a pipeline execution timing diagram according to an embodiment of the present disclosure. As shown in FIG8 , the device includes:
[0140] An extraction module 82 is configured to obtain multiple processing stages that each instruction of a plurality of instructions of a target basic block needs to sequentially pass through, and extract hardware characteristic parameters of the plurality of processing stages respectively;
[0141] a determination module 84 configured to determine dependencies and competition relationships among the plurality of instructions based on the plurality of processing stages and the hardware characteristic parameters;
[0142] The construction module 86 is configured to construct an execution timing graph of the target basic block according to the dependency relationship and the competition relationship.
[0143] In this embodiment, each node in the execution timing graph corresponds to a processing stage of an instruction, and the edges in the execution timing graph correspond to the dependency relationship and the competition relationship.
[0144] The embodiments of the present disclosure can solve the problem in related art that pipeline execution timing diagram modeling cannot support the PowerPC E500 processor, laying a foundation for worst-case execution time analysis of the PowerPC E500 processor.
[0145] In this embodiment, the multiple processing stages that each instruction needs to sequentially go through may specifically include: an instruction fetch stage, a decoding and scheduling stage, an issue stage, an execution stage, a completion stage, and a write-back stage.
[0146] The embodiments of the present disclosure are mainly directed to the PowerPC E500 processor, which is a 32-bit microprocessor core based on the Freescale Power Architecture main processor. By abstracting the pipeline of the PowerPC E500 processor, the above-mentioned multiple processing stages related to the instruction execution timing can be obtained.
[0147] Furthermore, pipelining technology refers to a technology that breaks down instructions into multiple processing stages and allows the processing stages of different instructions to overlap, thereby realizing parallel processing of multiple instructions to speed up the program running process.
[0148] In this embodiment, the multiple processing stages in the PowerPC E500 processor respectively perform the following operations:
[0149] Instruction fetch stage, which reads instructions from memory or cache and saves them into the instruction queue;
[0150] The decoding and scheduling phase decodes the instruction and decides whether to schedule it to the emission queue based on the current hardware resources. It also allocates a position in the completion queue to ensure that the execution results can be written back in order.
[0151] The issue stage, which reads the instruction's source operands from the rename registers and register file and decides when to latch the instruction into the execution unit's reservation station;
[0152] The execution phase executes the instructions assigned to the various execution units and writes the results to the result bus;
[0153] The completion phase ensures the correct machine state and delivers results in the correct order.
[0154] The write-back stage ensures that the computation results are written to the architecturally defined registers in the correct order.
[0155] In an exemplary embodiment, the extraction module 82 may specifically include the following structure:
[0156] A first acquisition unit is configured to acquire an instruction queue size and an instruction fetch overscaling metric of the processor in the instruction fetch stage;
[0157] a second acquiring unit configured to acquire a transmit queue size, a completion queue size, a decoding overscaling metric, and a scheduling overscaling metric of the processor in the decoding scheduling phase;
[0158] a third acquiring unit, configured to acquire a transmission over-scale metric of the processor in the transmission phase;
[0159] a fourth acquiring unit, configured to acquire the number of execution units of the processor in the execution phase;
[0160] a fifth acquiring unit configured to acquire a completion overscaling metric of the processor in the completion phase;
[0161] A sixth obtaining unit is configured to obtain a commit overscalar metric of the processor in the write-back phase.
[0162] Furthermore, the hardware characteristic parameters include: instruction queue size, instruction fetch overscaling metric, issue queue size, completion queue size, scheduling overscaling metric, issue overscaling metric, number of execution units, completion overscaling metric, and commit overscaling metric.
[0163] In this embodiment, the determination module 84 specifically includes the following structure:
[0164] a dependency determining unit configured to determine, according to the order of the multiple processing stages and the hardware characteristic parameters, a dependency relationship between the same instruction or different instructions in the multiple instructions in the multiple processing stages;
[0165] The competition determination unit is configured to determine the competition relationship between different instructions in the plurality of instructions in the execution phase according to the hardware characteristic parameters.
[0166] In an exemplary embodiment, the dependency relationship may include: phase dependency relationship, sequence dependency relationship, queue dependency relationship and data dependency relationship. Further, the dependency determination unit may specifically include:
[0167] A first dependency unit is configured to determine a stage dependency relationship of each instruction in the multiple processing stages according to the order of the multiple processing stages;
[0168] a second dependency unit configured to determine sequential dependencies of different instructions in the plurality of processing stages according to the instruction fetch superscalar metric, the decode superscalar metric, the schedule superscalar metric, the transmit superscalar metric, and the commit superscalar metric in the hardware characteristic parameters;
[0169] a third dependency unit configured to determine queue dependencies of different instructions in mutually associated processing stages according to the instruction queue size, the issue queue size, and the completion queue size in the hardware characteristic parameters, wherein the decode scheduling stage is mutually associated with any of the following processing stages: the instruction fetch stage, the issue stage, and the completion stage;
[0170] The fourth dependency unit is configured to determine the data dependency relationship between the multiple instructions in the execution stage according to the instruction contents of the multiple instructions.
[0171] In one embodiment, the stage dependency means that each instruction must pass through the instruction fetch stage, decode scheduling stage, issue stage, execution stage, completion stage, and write-back stage in sequence in the pipeline, and the next stage can only start after the previous stage is completed.
[0172] In one embodiment, the sequential dependency means that each instruction in a basic block must be executed in the order of the instruction numbers in all processing stages except the execution stage. The PowerPC E500 processor supports superscalar processing, meaning that each processing stage can fetch multiple instructions for parallel execution within a cycle. The superscalar parameter refers to the number of instructions that can be processed in parallel by each processing stage.
[0173] In one embodiment, queue dependencies are due to buffer queue size limitations.
[0174] Specifically, when the instruction queue is full, the decoding and scheduling stage needs to take out the instruction from the instruction queue before there is a free space in the instruction queue, and new instructions can be put into the instruction queue; when the emission queue is full, the emission queue needs to take out the instruction from the emission queue during the emission stage before there is a free space in the emission queue, and new instructions can be decoded and scheduled into the emission queue; when the completion queue is full, the completion stage needs to take out the instruction from the completion queue before there is a free space, and new instructions can be decoded and scheduled into the completion queue.
[0175] In one embodiment, a data dependency relationship means that a certain instruction requires the execution result of another instruction. If the execution result has not yet been generated, the instructions that depend on the execution result will be blocked until the execution result is generated.
[0176] Furthermore, the processing stages involved in data dependencies may also differ depending on the type of the dependent instruction. Specifically, the results of most instructions in the PowerPC E500 processor are written to the rename register after the execute phase, allowing subsequent instructions to use them without waiting for the writeback phase. However, load / store instructions are an exception; their results must be written back before they can be used by subsequent instructions.
[0177] In this embodiment, the competition dependency unit is also configured to determine whether any two instructions among the multiple instructions meet the preset conditions based on the distance between the different instructions, the completion queue size and the instruction content of the multiple instructions, and determine the competition relationship between the two instructions that meet the preset conditions if the judgment result is yes.
[0178] Furthermore, the hardware feature parameters also include an out-of-order execution attribute, which indicates whether the processor supports out-of-order execution. This attribute indicates whether multiple instructions within a basic block can be run out of order during the execution phase. The PowerPC E500 processor supports out-of-order execution during the execution phase, which can reduce pipeline stalls and improve processor performance.
[0179] In this embodiment, each execution unit can only process one instruction at a time. Since the PowerPC E500 processor supports out-of-order execution, two instructions may use a certain execution unit at the same time. In addition, the number of various execution units of the processor is limited, and the execution of the two instructions may cause competition for execution unit resources.
[0180] Furthermore, one of the two competing instructions must be blocked and must wait until the other instruction is completed and the execution unit is released before entering the execution phase.
[0181] In an exemplary embodiment, the contention dependency unit is further configured to determine whether the distance between any two instructions is less than or equal to the completion queue size based on the distance between the different instructions; determine whether the execution stages of the two instructions use the same execution unit based on the instruction contents of the multiple instructions; determine whether there is no data dependency between the two instructions based on the instruction contents of the multiple instructions; if the judgment results are all yes, determine that the corresponding two instructions meet the preset conditions; if any judgment result is no, determine that the corresponding two instructions do not meet the preset conditions.
[0182] In this embodiment, the construction module 86 may specifically include:
[0183] A first construction unit is configured to respectively set a node for each of the plurality of processing stages corresponding to each instruction in the plurality of instructions;
[0184] The second construction unit is configured to, based on the dependency relationship, establish a directed dependency edge with the second node as a source node and the first node as a target node when the first node depends on the second node, wherein the first node and the second node are any processing stage of any instruction;
[0185] The third construction unit is used to establish an undirected competition edge between the third node and the fourth node when there is the competition relationship between the third node and the fourth node, wherein the third node and the fourth node are the execution stages of any instruction.
[0186] Through the disclosed embodiments, a pipeline execution timing diagram for the PowerPC E500 processor can be created. This can be used to accurately calculate the maximum possible execution time of basic block instruction sequences, providing a core foundation for the design and development of static worst-case execution time (WCET) analysis tools for the PowerPC E500 processor. Furthermore, based on the pipeline execution timing diagram, modeling models for other core processor components, such as branch prediction and cache, can be easily integrated to perform more accurate worst-case program execution time analysis.
[0187] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are executed.
[0188] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0189] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0190] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0191] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.
[0192] Obviously, those skilled in the art should understand that the modules or steps of the present disclosure described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and thus, they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present disclosure is not limited to any particular combination of hardware and software.
[0193] The foregoing description is merely a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that various modifications and variations of the present disclosure are possible. Any modifications, equivalent substitutions, or improvements made within the principles of the present disclosure shall be included within the scope of protection of the present disclosure.
Claims
1. A method for constructing a pipeline execution timing diagram, applied to a PowerPC E500 processor, the method comprising: Acquire multiple processing stages that each instruction of multiple instructions of the target basic block needs to sequentially pass through, and extract hardware characteristic parameters of the multiple processing stages respectively; Determine the dependency relationship and competition relationship between the plurality of instructions according to the plurality of processing stages and the hardware characteristic parameters; An execution timing graph of the target basic block is constructed according to the dependency relationship and the competition relationship, wherein each node in the execution timing graph corresponds to a processing stage of an instruction, and the edges in the execution timing graph correspond to the dependency relationship and the competition relationship.
2. The method according to claim 1, wherein: The multiple processing stages include: The instruction fetch stage, the decode scheduling stage, the issue stage, the execute stage, the completion stage, and the write-back stage.
3. The method according to claim 2, wherein: The extracting the hardware characteristic parameters of the multiple processing stages respectively includes: Obtaining the instruction queue size and instruction fetch overscaling metric of the processor in the instruction fetch stage; Obtaining a transmit queue size, a completion queue size, a decoding overscaling metric, and a scheduling overscaling metric of the processor in the decoding scheduling phase; obtaining a transmit overscaling measure of the processor during the transmit phase; Obtaining the number of execution units of the processor in the execution phase; obtaining a completion overscaling measure of the processor at the completion stage; obtaining a committed overscalar metric of the processor during the writeback phase; The hardware characteristic parameters include: the instruction queue size, the instruction fetch superscalar metric, the issue queue size, the completion queue size, the scheduling superscalar metric, the issue superscalar metric, the number of execution units, the completion superscalar metric and the submission superscalar metric.
4. The method according to claim 3, wherein: The determining the dependency relationship and competition relationship between the multiple instructions according to the multiple processing stages and the hardware characteristic parameters includes: Determining dependencies between the same instruction or different instructions in the multiple processing stages according to the sequence of the multiple processing stages and the hardware characteristic parameters; The competition relationship between different instructions in the plurality of instructions in the execution phase is determined according to the hardware characteristic parameters.
5. The method according to claim 4, wherein: The dependencies include phase dependencies, sequence dependencies, queue dependencies and data dependencies; The determining, according to the order of the multiple processing stages and the hardware characteristic parameters, the dependency relationship between the same instruction or different instructions in the multiple instructions in the multiple processing stages includes: Determining the stage dependency of each instruction in the multiple processing stages according to the order of the multiple processing stages; Determine sequential dependencies of different instructions in the plurality of processing stages respectively according to the instruction fetch superscalar metric, the decode superscalar metric, the schedule superscalar metric, the transmit superscalar metric and the commit superscalar metric in the hardware characteristic parameters; The queue dependencies of different instructions in mutually related processing stages are determined according to the instruction queue size, the transmit queue size and the completion queue size in the hardware characteristic parameters, wherein the decoding scheduling stage is related to any of the following: A processing stage is an interrelated processing stage: the fetch stage, the issue stage, and the completion stage; The data dependencies of the multiple instructions at the execution stage are determined according to the instruction contents of the multiple instructions.
6. The method according to claim 4, wherein: The determining, according to the hardware characteristic parameter, the competition relationship between different instructions among the multiple instructions in the execution phase includes: Whether any two instructions among the multiple instructions meet a preset condition is judged according to the distance between the different instructions, the completion queue size and the instruction contents of the multiple instructions, and if the judgment result is yes, the competition relationship between the two instructions that meet the preset condition is determined.
7. The method according to claim 6, wherein: Determining whether any two instructions among the multiple instructions meet a preset condition according to the distance between the different instructions, the size of the completion queue, and the instruction contents of the multiple instructions includes: Determining whether the distance between any two instructions is less than or equal to the completion queue size according to the distance between the different instructions; Determining whether the execution phases of two instructions use the same execution unit according to the instruction contents of the multiple instructions; Determining whether there is no data dependency relationship between two instructions according to instruction contents of the multiple instructions; If both judgment results are yes, determining that the corresponding two instructions meet the preset condition; When any judgment result is negative, it is determined that the corresponding two instructions do not satisfy the preset condition.
8. The method according to claim 2, wherein: Constructing an execution timing diagram of the target basic block according to the dependency relationship and the competition relationship, including: Setting a node for each of the plurality of processing stages corresponding to each instruction in the plurality of instructions; According to the dependency relationship, when the first node depends on the second node, a directed dependency edge is established with the second node as the source node and the first node as the target node, wherein the first node and the second node are any processing stage of any instruction; In the case where the competition relationship exists between the third node and the fourth node, an undirected competition edge is established between the third node and the fourth node, wherein the third node and the fourth node are the execution stages of any instruction.
9. A computer-readable storage medium, wherein a computer program is stored in the storage medium, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is executed. 10 . An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method according to claim 1 .
Citation Information
Patent Citations
Instruction merging method, out-of-order execution device, chip and storage medium
CN112199118A
Instruction execution method and device for graph calculation
CN115269016A
Heuristic method and device suitable for instruction rearrangement of multiple transmitting processors
CN116028127A
