A method for calculating WCRT of OpenMP programs with loop structures

By formulating the workload of the OpenMP task system into a cyclic graph model and designing a linear time dynamic programming algorithm, the complexity problem of cyclic structure WCRT calculation in the OpenMP task system is solved, and a higher precision and simplified calculation process is achieved.

CN114020274BActive Publication Date: 2024-09-06NORTHEASTERN UNIV AT QINHUANGDAO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111252124.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2024-09-06
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively calculate the worst-case response time (WCRT) safety upper limit of the loop structure in the OpenMP task system, and the simple enumeration execution flow method is complex and difficult to handle.

Method used

Formulate the workload of the OpenMP task system as a loop graph model, design a linear-time dynamic programming algorithm, and calculate the WCRT boundary by traversing the task system in reverse order and calculating the capacity and longest path length of the task system without unrolling the loop or explicitly enumerating the execution flow.

Benefits of technology

The calculation method of the WCRT boundary is simplified, the calculation accuracy is improved, and the time complexity is made independent of the cycle boundary, simplifying the calculation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114020274B
    Figure CN114020274B
Patent Text Reader

Abstract

The invention belongs to the field of real-time scheduling and model detection of real-time systems, and specifically relates to a WCRT method of an OpenMP program with a loop structure, the method comprising: establishing an OpenMP task system model; defining a statement tree of the task system; accurately calculating the capacity of the task system, traversing each task in the task system in reverse order, and calculating the capacity related to each task in the task system; accurately calculating the longest path length of the task system; traversing each task in the task system in reverse order, and calculating the length of the longest path of each node B in the statement tree from the leaf to the root of each task; and calculating the upper bound of the WCRT of the task system. The method adopts a linear time dynamic programming algorithm to calculate the WCRT boundary without expanding the loop and explicitly enumerating the execution flow, so that the time complexity is independent of the loop boundary, simplifies the calculation method, and improves the WCRT boundary accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of real-time scheduling and model detection of real-time systems, and in particular relates to a WCRT method for calculating an OpenMP program with a loop structure. Background Art

[0002] OpenMP is a set of guiding compilation processing schemes designed for multiprocessor programs in shared memory parallel systems, which was proposed by the OpenMP Architecture Review Board and is widely accepted. It is a promising framework for multi-core parallel real-time software development. In recent years, many graph-based task models have adopted the OpenMP framework, which represent the realistic characteristics of OpenMP task systems. Loop structures are common in OpenMP task systems, however, current research has not modeled loop structures; in OpenMP task systems, it is necessary to explicitly enumerate the execution flow, and simple enumeration of the execution flow will make the calculation of the safety upper limit of the worst-case response time (WCRT) very complicated and difficult to handle. Summary of the invention

[0003] The present invention formulates the workload of an OpenMP task system with a loop structure into a loop graph model, and solves the problem of how to calculate the safety upper limit of the worst case response time (WCRT); a linear time dynamic programming algorithm is designed to calculate the WCRT boundary without expanding the loop or explicitly enumerating the execution flow, so that the time complexity is independent of the loop boundary, the calculation method is simplified, and the accuracy of the WCRT boundary is improved.

[0004] The specific steps of a method for calculating the WCRT of an OpenMP program with a loop structure of the present invention include:

[0005] Step 1: Establish an OpenMP task system model;

[0006] Step 2: Define the statement tree of the task system;

[0007] Step 3: Accurately calculate the capacity of the task system, traverse each task in the task system in reverse order, and calculate the capacity associated with each task in the task system;

[0008] Step 4: Accurately calculate the longest path length of the task system; traverse each task in the task system in reverse order, and find the length of the longest path of each task traversing each node B in the statement tree from the leaf to the root;

[0009] Step 5: Calculate the upper bound of the WCRT of the task system.

[0010] Furthermore, the longest path length of the task system in step 4 is the path through the vertices of the induced directed graph of B: the following six types of paths through the vertices of the induced directed graph of B are considered:

[0011] A set of paths starting from the entry vertex of B.

[0012] A set of paths starting from the waiting vertex of B.

[0013] A set of paths starting from the entry vertex of B and ending at the exit vertex of B.

[0014] A set of paths starting from the entry vertex of B and ending at the sink of the subtask.

[0015] A set of paths starting from a waiting vertex of B and ending at the exit vertex of B. A set of paths starting from the waiting vertex of B and ending at the sink of the subtask.

[0016] Furthermore, in step 4, the length of the longest path of each task traversing each node B in the statement tree from the leaf to the root is calculated:

[0017] (1) If B represents a vertex of a task, according to formula (1), (2), (3) Where (y = {*, ex, ct}); calculated according to formula (4) Where (y = {*, ex, ct});

[0018]

[0019]

[0020]

[0021]

[0022] but where (x∈{en,wt} and y={*,ex,ct}).

[0023] (2) If B is a sequential block, calculate according to formula (5) where (x∈{en,wt}and y={*,ex,ct}).

[0024]

[0025] but where (x∈{en,wt} and y={*,ex,ct}).

[0026] (3) If B is a branch block, calculate according to formula (6)(7)(8)(9)(10)(11) Where (x = {en, wt} and y = {∞, ex, ct}).

[0027]

[0028]

[0029]

[0030]

[0031]

[0032]

[0033] in but where (x∈{en,wt} and y={*,ex,ct}).

[0034] If B represents a loop block, the loop boundary is K. First, define it as follows:

[0035]

[0036]

[0037] Calculated by formula (12)(13)(14)(15)(16)(17) Where (x = {en, wt} and y = {∞, ex, ct}).

[0038]

[0039]

[0040]

[0041]

[0042]

[0043]

[0044] in where Γ3=α(K-1), in but where (x∈{en,wt} and y={*,ex,ct}).

[0045] Furthermore, the upper bound of WCRT in step 5 is Mission system capacity The longest path length of the task system (m is the number of threads).

[0046] The worst-case response time (WCRT) of a task system is equal to the maximum time it takes to execute all vertices in the task system on m threads under breadth-first scheduling (or width-first scheduling). The following theorem gives an upper bound on the worst-case response time of a task system.

[0047] Under breadth-first scheduling (or width-first scheduling), the worst-case response time of a task system executed on m threads is bounded by: the upper bound of the task system WCRT is Mission system capacity The longest path length of the task system (m is the number of threads).

[0048] The method for calculating the WCRT of an OpenMP program with a loop structure of the present invention has the following advantages:

[0049] By accurately calculating the capacity of the task system, traversing each task in the task system in reverse order, and calculating the capacity associated with each task in the task system; and accurately calculating the length of the longest path of each node B in the statement tree from the leaf to the root of each task traversal, a linear time dynamic programming algorithm is designed to calculate the WCRT boundary without unrolling the loop or explicitly enumerating the execution flow, which simplifies the calculation method and improves the accuracy of the WCRT boundary. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A schematic diagram of the control flow graph of each task in the OpenMP task system.

[0051] Figure 2 for Figure 1 The statement tree of τ1 in .

[0052] Figure 3 Experimental graph of a random task set with varying number of threads.

[0053] Figure 4 Experimental diagram of random task sets with varying number of system tasks.

[0054] Figure 5 Experimental diagram of a random task set with varying probabilities of conditional nodes being loop nodes.

[0055] Figure 6 Experimental diagram of a random task set with varying probability of the conditional node being an if node.

[0056] Figure 7 Experimental graph of a random task set with varying probabilities of creating nodes for non-conditional nodes.

[0057] Figure 8 Experimental diagram of a random task set with varying probabilities of non-conditional nodes being waiting nodes.

[0058] Fig. 9 This is an experimental diagram of the real program. DETAILED DESCRIPTION

[0059] In order to better understand the purpose, method and function of the present invention, a method for calculating the WCRT of an OpenMP program with a loop structure of the present invention is further described in detail below with reference to the accompanying drawings.

[0060] The method of the present invention is based on the classical response time set by Graham for the DAG task model, and a linear time algorithm is designed to accurately calculate the parameters (e.g., volume and length) used in the worst-case response time bound; the traditional loop structure combined with the creation of tasks and conditional branches leads to a large state space, and simply unrolling the loop and / or enumerating all possible execution flows is computationally intractable. The method of the present invention does not require unrolling the loop, so the time complexity is independent of the loop boundary.

[0061] Therefore, the present invention provides a method for calculating the WCRT of an OpenMP program with a loop structure, such as Figure 1 As shown, the specific steps include:

[0062] Step 1: Establish an OpenMP task system model.

[0063] 1) Randomly generate the code according to the relevant parameters input by the user. The user inputs the OpenMP task system scale parameters as shown in Table 1, and the CFG of each task in the OpenMP task system T is as follows: Figure 1 .

[0064] Table 1 Timed automaton system parameters

[0065]

[0066] (2) The BOTS benchmark is converted into a DCG topology through the ompTG tool, and a task graph that conforms to the experimental model is generated.

[0067] Step 2: Define the statement tree of the task system, such as Figure 2 As shown, the statement tree of the task is as follows:

[0068] 1. The root node of the statement tree represents the control flow graph of the task.

[0069] 2. Each leaf node of the statement tree corresponds to the vertex of a task.

[0070] 3. The non-leaf node B of the statement tree represents the subgraph of the task:

[0071] (1) If B represents a branch block, it has an entry vertex, an exit vertex, and two branches B1 and B2.

[0072] (2) If B represents a cycle block, it has an entry vertex, an exit vertex, and a branch B'.

[0073] (3) If B represents a block sequence, it has two child nodes B1 and B2, representing the first block B1 of B and the remaining blocks of B respectively, that is, B2 = B-B1.

[0074] Step 3: Accurately calculate the capacity of the task system

[0075] The specific method is:

[0076] (1) Traverse each task in the task system in reverse order.

[0077] For each task, traverse its statement tree from the leaf to the root and calculate the capacity of each node B in the statement tree. First determine whether B is a leaf of the statement tree. If B is a leaf of the statement tree, it represents the vertex of the task, then the capacity of B = the worst-case execution time of the vertex; then determine whether the vertex is a creation vertex. If the vertex is a creation vertex, the capacity of B = the capacity of B + the capacity of the created task; if B is not a statement tree leaf node. Determine if B is a sequential block, that is, the capacity of B = the capacity of B1 + the capacity of B2; if B is a branch block, that is, the capacity of B = the worst-case execution time of the entry vertex + the worst-case execution time of the exit vertex + the maximum capacity of B1 and B2; if B corresponds to a loop block with a loop boundary of K, the capacity of B = (K+1) times the worst-case execution time of the entry vertex + the worst-case execution time of the exit vertex + K times the capacity of B'.

[0078] (2) Calculate the capacity associated with each task in the task system.

[0079] The capacity of the task system = the capacity of the main task. The time complexity of the algorithm is O(n'), where n' is the total number of nodes in the statement tree of all tasks in the task system.

[0080] Step 4: Accurately calculate the longest path length of the task system, considering the following six types of paths through the vertices of the induced directed graph of B:

[0081] A set of paths starting from the entry vertex of B.

[0082] A set of paths starting from the waiting vertex of B.

[0083] A set of paths starting from the entry vertex of B and ending at the exit vertex of B.

[0084] A set of paths starting from the entry vertex of B and ending at the sink of the subtask.

[0085] A set of paths starting from a waiting vertex of B and ending at the exit vertex of B.

[0086] A set of paths starting from the waiting vertex of B and ending at the sink of the subtask.

[0087] use express The length of the longest path (x∈{en,wt}and y={*,ex,ct}).

[0088] Traverse each task in the task system in reverse order, and find the length of the longest path of each task traversing each node B in the statement tree from the leaf to the root.

[0089] (1) If B represents a vertex of a task, according to formula (1), (2), (3) Where (y = {*, ex, ct}); calculated according to formula (4) Where (y = {*, ex, ct});

[0090]

[0091]

[0092]

[0093]

[0094] but where (x∈{en,wt} and y={*,ex,ct}).

[0095] (2) If B is a sequential block, calculate according to formula (5) where (x∈{en,wt}and y={*,ex,ct}).

[0096]

[0097] but where (x∈{en,wt} and y={*,ex,ct}).

[0098] (3) If B is a branch block, calculate according to formula (6)(7)(8)(9)(10)(11) Where (x = {en, wt} and y = {∞, ex, ct}).

[0099]

[0100]

[0101]

[0102]

[0103]

[0104]

[0105] in but where (x∈{en,wt} and y={*,ex,ct}).

[0106] If B represents a loop block, the loop boundary is K. First, define it as follows:

[0107]

[0108]

[0109] Calculated by formula (12)(13)(14)(15)(16)(17) Where (x = {en, wt} and y = {∞, ex, ct}).

[0110]

[0111]

[0112]

[0113]

[0114]

[0115]

[0116] where Γ1=αK, where Γ3=α(K-1), in but where (x∈{en,wt} and y={*,ex,ct}).

[0117] Finally, the length of the task system is calculated as the length of the directed graph induced by the main task.

[0118] The time complexity of calculating the length of all tasks in the task system is O(6n'), where n' is the total number of nodes in the statement trees of all tasks in the task system.

[0119] Step 5: Calculate the upper bound of the WCRT of the task system

[0120] Upper bound of WCRT Mission system capacity The longest path length of the task system (m is the number of threads).

[0121] Below Figure 3-9 The experimental data are explained as follows:

[0122] like Figure 3 As shown, it is an experimental graph of a random task set with a varying number of threads. The horizontal axis is the number of threads, the vertical axis of the bar graph is the limit ratio, the vertical axis of the line graph is the calculation time (milliseconds), R1 is the WCRT boundary calculated by the approximate method, t1 represents the calculation time for calculating the WCRT boundary R1, R2 is the WCRT boundary calculated by the precise method of the invention, t2 represents the calculation time for calculating the WCRT boundary R2, and other parameters are n=40, P con =0.5,P if =0.4,P lp =0.6,P wait =0.3,P cre =0.3. The ratio of R1 to R2 increases exponentially as the number of threads m increases. According to step 5, when m increases, the WCRT bounds R1 and R2 both decrease. The trend of the ratio of R1 to R2 in the figure shows that R2 decreases much faster than R1. The computation times t1 and t2 remain unchanged as m increases, because the number of threads m does not affect the complexity of the method.

[0123] like Figure 4As shown, it is an experimental graph of a random task set with a changing number of system tasks. The horizontal axis is the number of tasks in the system, the vertical axis of the bar graph is the limit ratio, the vertical axis of the line graph is the calculation time (milliseconds), R1 is the WCRT boundary calculated by the approximate method, t1 represents the calculation time for calculating the WCRT boundary R1, R2 is the WCRT boundary calculated by the precise method of the invention, t2 represents the calculation time for calculating the WCRT boundary R2, and other parameters are m=32, P con =0.5,P if =0.4,P lp =0.6,P wait =0.3,P cre =0.3. When the number of tasks n increases, the ratio of R1 to R2 increases. It can be concluded that R2 is more tolerant to the increase of tasks than R1. The computing time t1 and t2 both increase linearly with the increase of n.

[0124] like Figure 5 Figure 6 As shown, Figure 5 This is an experimental diagram of a random task set with a varying probability of a conditional node being a loop node. The horizontal axis is the probability of a conditional node being a loop node. Figure 6 The experimental diagram of the random task set with the probability change of the conditional node being the if node. The horizontal axis is the probability of the conditional node being the if node, the vertical axis of the bar graph is the boundary ratio, the vertical axis of the line graph is the calculation time (milliseconds), R1 is the WCRT boundary calculated by the approximate method, t1 represents the calculation time of calculating the WCRT boundary R1, R2 is the WCRT boundary calculated by the precise method of the invention, t2 represents the calculation time of calculating the WCRT boundary R2, and other parameters are m=32, n=40, P con =0.5,P wait =0.3,P cre =0.3. When P if As P increases, the ratio of R1 to R2 increases. There are usually two reasons for this. (1) When there are more loop blocks and more branch blocks nested with each other, the upper limit of the system capacity calculated by the approximate method becomes more pessimistic. (2) When there are more loop blocks containing creation vertices, the upper limit of the longest path length of the task system calculated by the approximate method becomes more pessimistic. The computation time t1 and t2 increases with P. lp decreases with the increase of P if This is because the branch block takes more time to analyze than the loop block because the branch block contains two branches and the loop block has only one branch.

[0125] like Figure 7As shown, it is an experimental diagram of a random task set with a probability change of a non-conditional node being a creation node. The horizontal axis is the probability of a non-conditional node being a creation node, the vertical axis of the bar graph is the boundary ratio, the vertical axis of the line graph is the calculation time (milliseconds), R1 is the WCRT boundary calculated by the approximate method, t1 represents the calculation time of calculating the WCRT boundary R1, R2 is the WCRT boundary calculated by the precise method of the invention, t2 represents the calculation time of calculating the WCRT boundary R2, and other parameters are m=32, n=40, P con =0.5,P if =0.4,P lp =0.6,P wait =0.3. R1 and R2 increase with P cre As the number of created vertices in a task is fixed, the larger the P cre Indicates that there are fewer vertices in the task. The fewer vertices, the smaller the R1 and R2 of the WCRT boundary. The trend of the ratio of R1 to R2 in the figure shows that R1 and R2 decrease at the same rate. The computation time t1 and t2 do not change with P. cre changes significantly with the increase of .

[0126] like Figure 8 As shown, it is an experimental diagram of a random task set with a probability change of a non-conditional node being a waiting node. The horizontal axis is the probability of a non-conditional node being a waiting node, the vertical axis of the bar graph is the boundary ratio, the vertical axis of the line graph is the calculation time (milliseconds), R1 is the WCRT boundary calculated by the approximate method, t1 represents the calculation time of calculating the WCRT boundary R1, R2 is the WCRT boundary calculated by the precise method of the invention, t2 represents the calculation time of calculating the WCRT boundary R2, and other parameters are m=32, n=40, P con =0.5,P if =0.4,P lp =0.6,P cre =0.3. The ratio of R1 to R2 increases with P wait This is because the number of waiting vertices in a task does not affect the upper limit of the longest path length of the task system calculated by the approximate method, but when there are more waiting vertices, the exact length of the longest path length of the task system becomes larger. The calculation time t1 and t2 do not increase with P wait changes significantly with the increase of .

[0127] like Fig. 9As shown, it is an experimental graph of a real program. The horizontal axis is the name of the real program, the vertical axis of the bar graph is the boundary ratio, the vertical axis of the line graph is the calculation time (milliseconds), R1 is the WCRT boundary calculated by the approximate method, t1 represents the calculation time for calculating the WCRT boundary R1, R2 is the WCRT boundary calculated by the precise method of the invention, t2 represents the calculation time for calculating the WCRT boundary R2, and the other parameters are m=32. The average boundary ratio of these benchmarks is 3.66. The ratio of benchmark su reaches 30.45, which is the highest among all benchmarks. This is because the nesting depth of loop blocks in su is 3 or 4, and there are creation vertices in loop blocks with a nesting depth of 2. In contrast, in other benchmarks (except sn), the nesting depth of loop blocks is 1 or 2, and creation vertices are only contained in loop blocks that are not nested in other loop blocks. The nesting depth of loop blocks in sn is 2 or 3, but no creation vertices are contained in the loop blocks. The computation time t1 and t2 of these benchmarks are positively correlated with the number of nodes and edges in the task system, and are 14.82ms and 40.26ms on average, respectively.

[0128] The above experimental results prove that, compared with the method of approximate parameter calculation, the precise method (used to calculate parameters) of the present invention can improve the WCRT bound by several dozen times.

[0129] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.

Claims

1. A method for calculating the WCRT of an OpenMP program with a loop structure, characterized in that: The specific steps of the method include: Step 1: Establish an OpenMP task system model; Step 2: Define the statement tree of the task system; Step 3: Accurately calculate the capacity of the task system, traverse each task in the task system in reverse order, and calculate the capacity associated with each task in the task system; Step 4: Accurately calculate the longest path length of the task system; traverse each task in the task system in reverse order, and find the length of the longest path of each task traversing each node B in the statement tree from the leaf to the root; Step 5: Calculate the upper bound of the WCRT of the task system; The longest path length of the task system in step 4 is considered to be the following six types of paths through the vertices of the induced directed graph of B: A set of paths starting from the entry vertex of B; A set of paths starting from the waiting vertex of B; A set of paths starting from the entry vertex of B and ending at the exit vertex of B; A set of paths starting from the entry vertex of B and ending at the sink of the subtask; A set of paths starting from a waiting vertex of B and ending at the exit vertex of B; A set of paths starting from the waiting vertex of B and ending at the sink of the subtask; In step 4, the length of the longest path of each task traversing each node B in the statement tree from the leaf to the root is calculated: (1) If B represents a vertex of a task, according to formula (1), (2), (3) Where (y = {*, ex, ct}); calculated according to formula (4) Where (y = {*, ex, ct}); (1) but where (x∈{en,wt} and y={*,ex,ct}); (2) If B is a sequential block, calculate according to formula (5) where (x∈{en,wt}and y={*,ex,ct}); but where (x∈{en,wt} and y={*,ex,ct}); (3) If B is a branch block, calculate according to formula (6)(7)(8)(9)(10)(11) where (x = {en, wt} and y = {∞, ex, ct}); in but where (x∈{en,wt} and y={*,ex,ct}); If B represents a loop block, the loop boundary is K; first define it as follows: Calculated by formula (12)(13)(14)(15)(16)(17) where (x = {en, wt} and y = {∞, ex, ct}); in in in but where (x∈{en,wt} and y={*,ex,ct}).