CN104572103B - A kind of the worst execution time WCET method for quick estimating based on distribution function - Google Patents
A kind of the worst execution time WCET method for quick estimating based on distribution function Download PDFInfo
- Publication number
- CN104572103B CN104572103B CN201510009091.XA CN201510009091A CN104572103B CN 104572103 B CN104572103 B CN 104572103B CN 201510009091 A CN201510009091 A CN 201510009091A CN 104572103 B CN104572103 B CN 104572103B
- Authority
- CN
- China
- Prior art keywords
- basic block
- statement
- execution time
- instruction
- execution
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 68
- 238000005315 distribution function Methods 0.000 title claims abstract description 14
- 238000004458 analytical method Methods 0.000 claims description 28
- 238000012546 transfer Methods 0.000 claims description 23
- 238000004364 calculation method Methods 0.000 claims description 12
- 238000010586 diagram Methods 0.000 claims description 5
- 238000004422 calculation algorithm Methods 0.000 claims description 2
- 238000005516 engineering process Methods 0.000 abstract description 11
- 238000012360 testing method Methods 0.000 abstract description 4
- 230000003068 static effect Effects 0.000 description 16
- 238000000691 measurement method Methods 0.000 description 7
- 238000005259 measurement Methods 0.000 description 5
- 238000007781 pre-processing Methods 0.000 description 2
- 238000002474 experimental method Methods 0.000 description 1
- 238000005206 flow analysis Methods 0.000 description 1
- 239000012634 fragment Substances 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000012552 review Methods 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000010845 search algorithm Methods 0.000 description 1
- 238000007619 statistical method Methods 0.000 description 1
- 238000013179 statistical model Methods 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
本发明提供了一种基于分布函数的最坏执行时间WCET快速估计方法,通过对DSP工程目标代码(out文件)进行反汇编获得反汇编文件F;分析反汇编文件F,获取划分的各个基本块,得到程序的基本块集合B;辨识基本块集合B中各基本块之间的关系,构建程序流图C;计算每个基本块的执行时间T;将基本块执行时间T和基本块执行次数Ts作为权值得到加权的程序流图Cw;分析加权的程序流图Cw,获得总权值最大的路径,将最大的总权值作为程序最坏执行时间WCET。解决了现有技术中需运行程序得到测试样本的弊端和人工干预过多的问题以及传统PERT技术中贝塔分布参数估计方法的不合理性问题。
The present invention provides a WCET fast estimation method based on the distribution function, obtain the disassembly file F by disassembling the DSP engineering target code (out file); analyze the disassembly file F, and obtain each divided basic block , get the basic block set B of the program; identify the relationship between the basic blocks in the basic block set B, construct the program flow graph C; calculate the execution time T of each basic block; compare the basic block execution time T with the basic block execution times Ts is used as a weight to obtain a weighted program flow graph Cw; analyze the weighted program flow graph Cw to obtain the path with the largest total weight, and use the largest total weight as the worst execution time WCET of the program. It solves the disadvantages of running a program to obtain test samples and the problem of too much manual intervention in the prior art, as well as the irrationality of the beta distribution parameter estimation method in the traditional PERT technology.
Description
技术领域technical field
本发明属于实时嵌入式软件领域,特别涉及TI DSP技术中一种基于分布函数的最坏执行时间(WCET:Worst-Case Execution Time)快速估计方法,可用于评估DSP工程代码或者代码片段的最坏执行时间。The invention belongs to the field of real-time embedded software, in particular to a fast estimation method of Worst-Case Execution Time (WCET: Worst-Case Execution Time) based on distribution function in TI DSP technology, which can be used to evaluate the worst case of DSP engineering code or code fragment execution time.
背景技术Background technique
在实时嵌入式软件系统中,系统对时间具有更加严格的要求,系统的正确性不仅与其程序的逻辑有关,还与其时间特性有关,只有在规定时间内完成规定的任务才是有效的,否则会导致该系统性能的降低甚至系统的失败。因此,事先获取系统中每个任务的最坏执行时间(WCET)对实时系统的时序分析等具有重要的意义。In a real-time embedded software system, the system has stricter requirements on time. The correctness of the system is not only related to the logic of its program, but also related to its time characteristics. Only when the specified task is completed within the specified time is it effective, otherwise it will be Lead to the reduction of the performance of the system or even the failure of the system. Therefore, obtaining the Worst Execution Time (WCET) of each task in the system in advance is of great significance for timing analysis of real-time systems.
目前,WCET分析主要包括三种方法:静态分析法、动态度量法和混合分析法。At present, WCET analysis mainly includes three methods: static analysis method, dynamic measurement method and hybrid analysis method.
动态度量法就是通过运行程序动态的测试程序的执行时间,进而分析得到WCET,然而该方法存在很大的弊端,首先该方法需要目标机,需要实际运行程序并需要大量的实验,耗费人力、物力、财力,并且在航天、航空领域,很多情况下不能模拟真实的目标机环境或者目标机昂贵,且对实时性要求较高,不可能让未经检验的程序在真实的目标机上运行。除此之外,该方法很难保证测量得到的结果是安全的,即无法保证不低估最差执行时间,因为很难保证所做的实际测量满足程序WCET的条件,对于现代处理器来说,此点更难做到。The dynamic measurement method is to dynamically test the execution time of the program by running the program, and then analyze and obtain WCET. However, this method has great disadvantages. First, the method requires a target machine, needs to actually run the program, and requires a lot of experiments, which consumes manpower and material resources. , financial resources, and in the field of aerospace and aviation, in many cases it is impossible to simulate the real target machine environment or the target machine is expensive and has high requirements for real-time performance. It is impossible to let untested programs run on the real target machine. In addition, this method is difficult to ensure that the measured results are safe, that is, it cannot guarantee that the worst execution time will not be underestimated, because it is difficult to ensure that the actual measurement made meets the conditions of the program WCET. For modern processors, This point is more difficult to do.
混合分析法即将静态分析法和动态度量法相结合的方法,该方法具体分为两种情况,一种是首先对程序进行静态分析,即运用静态分析法进行分析,然后根据静态分析法的结果对程序进行运行测试,最终确定程序的WCET;另一种是首先对程序采用动态度量法进行测试分析,然后在动态度量法的基础上进行静态分析,进而确定程序的WCET。Hybrid analysis is a method that combines static analysis and dynamic measurement. This method is specifically divided into two situations. One is to first perform static analysis on the program, that is, use static analysis to analyze, and then analyze the The program is run and tested to finally determine the program's WCET; the other is to first test and analyze the program using the dynamic measurement method, and then perform static analysis on the basis of the dynamic measurement method to determine the program's WCET.
无论采用哪种方法,混合分析法在包含静态分析法和动态度量法的优点上,也包含他们各自的缺点,并且混合分析法比较复杂。No matter which method is used, the hybrid analysis method includes the advantages of static analysis method and dynamic measurement method, but also contains their own disadvantages, and the hybrid analysis method is more complicated.
静态分析法是通过理论分析估算得到程序的WCET,该方法不仅可以在不运行程序的情况下获得计算结果,而且能够保证得到的结果是安全的,因此,这是目前常用的方法。The static analysis method is to estimate the WCET of the program through theoretical analysis. This method can not only obtain the calculation results without running the program, but also ensure that the obtained results are safe. Therefore, this is a commonly used method at present.
传统静态分析方法一般由3个部分组成:①程序的控制流分析,主要分析确定程序可能的执行路径、最大循环次数和不可行路径等;②底层分析,主要考虑目标机器的特征,比如高速缓存、流水线、分支预测等,目的是确定每条汇编语句或者每个基本块执行的时间;③WCET计算,根据前两项信息,运用具体的计算方法对程序的WCET进行计算,主要计算方法分为基于路径的方法、基于树的方法和隐含路径枚举的方法。The traditional static analysis method generally consists of three parts: ①The control flow analysis of the program, which mainly analyzes and determines the possible execution path, the maximum number of cycles, and the infeasible path of the program; ②The underlying analysis mainly considers the characteristics of the target machine, such as cache , pipeline, branch prediction, etc., the purpose is to determine the execution time of each assembly statement or each basic block; ③WCET calculation, according to the first two items of information, use specific calculation methods to calculate the WCET of the program, the main calculation methods are divided into Path methods, tree-based methods, and methods that imply path enumeration.
总体上说,传统的静态分析方法是在WCET计算过程中,把每条汇编指令的执行时间作为确定值进行对待的,然后通过一定的方法得到程序的WCET,但此值也是确定的。Generally speaking, the traditional static analysis method treats the execution time of each assembly instruction as a definite value during the WCET calculation process, and then obtains the WCET of the program through a certain method, but this value is also definite.
可以看到,传统的方法没有考虑到程序执行时间的不确定性,根据现在处理器的特点,这种方法显然是存在很大弊端的,因为现在处理器为了加速运算的速度采用很多先进的技术,比如高度缓存、流水线、分支预测等,使得程序执行时间的不确定性更加明显。It can be seen that the traditional method does not take into account the uncertainty of program execution time. According to the characteristics of the current processor, this method obviously has great disadvantages, because the current processor adopts many advanced technologies to speed up the calculation. , such as high-level cache, pipeline, branch prediction, etc., make the uncertainty of program execution time more obvious.
因此,程序的运行时间不是单一的某个值,而是某个范围的区间值。Therefore, the running time of the program is not a single value, but a range of interval values.
目前针对此问题的解决方法主要是概率法求WCET,即pWCET,此概念是由GuillemBernat在2003年提出来的,主要目的解决某段代码或者某个函数等的WCET的概率分布问题。运用此方法计算WCET的文献已发表很多,比如:The current solution to this problem is mainly to find WCET by probability method, that is, pWCET. This concept was proposed by Guillem Bernat in 2003. The main purpose is to solve the probability distribution problem of WCET of a certain code or a certain function. A lot of literature has been published using this method to calculate WCET, such as:
1)在2003年,Stefan M Petters提出的采用极值统计理论求解程序执行时间区间的方法。该文献的大概思想为,多次运行程序,得到很多个程序运行时间值,然后用Gumble概率函数逼近,求取程序运行时间极值,即为WCET值。分析此文献,可以很容易看出,此种方法不能算是纯粹的静态分析,因为它是对多次运行程序得到的时间值进行函数拟合逼近,求极值得到的WCET,同样具有动态度量法的局限性。1) In 2003, Stefan M Petters proposed a method of using extreme value statistics theory to solve the program execution time interval. The general idea of this document is to run the program multiple times to obtain many program running time values, and then approximate it with the Gumble probability function to obtain the extreme value of the program running time, which is the WCET value. Analyzing this document, it can be easily seen that this method cannot be regarded as a pure static analysis, because it performs function fitting and approximation on the time value obtained by running the program multiple times, and the WCET obtained by finding the extreme value also has a dynamic measurement method limitations.
2)在2006年,胡明华、汤铭端在文献“基于分布函数的程序执行时间的静态预估”中提出的用概率分布模拟8087指令运行时间,进行指令叠加后用正态分布模拟整个程序执行时间的方法。然而,该方法事先需要对待分析程序进行很多的预处理,比如循环语句按照循环最大次数展开、分支判断语句则分为两支、case语句则分为多支等等,这在一定程度上限制了其适用性及自动化性,尤其对于大型的工程程序,需要大量的人力资源,具有很大的局限性。除此之外,该方法借鉴了计划评审技术(PERT)的思想,然而,该文献采用传统的PERT方法,其传统PERT方法本身具有很大的弊端,主要在于贝塔分布参数估计方法的不精确性。2) In 2006, Hu Minghua and Tang Mingduan proposed in the literature "Static Prediction of Program Execution Time Based on Distribution Function" to use probability distribution to simulate the running time of 8087 instructions, and use normal distribution to simulate the entire program execution time after instruction superposition method. However, this method requires a lot of preprocessing of the program to be analyzed in advance, such as expanding the loop statement according to the maximum number of loops, dividing the branch judgment statement into two branches, and dividing the case statement into multiple branches, etc., which limits the Its applicability and automation, especially for large-scale engineering programs, require a lot of human resources and have great limitations. In addition, this method draws on the idea of Program Review Technology (PERT). However, this literature uses the traditional PERT method, and the traditional PERT method itself has great drawbacks, mainly due to the inaccuracy of the beta distribution parameter estimation method .
3)在2010年,张保民、吴国伟等人在文献“程序最坏执行时间极值统计方法”中提出的采用程序执行时间的测量值作为样本,利用Gumble分布建立程序执行时间最坏统计模型,从而预测WCET的方法。然而该方法仍然需要运行程序获得测量值样本,具有动态度量法的局限性。3) In 2010, Zhang Baomin, Wu Guowei and others proposed in the document "Extreme Value Statistical Method of Program Execution Time" to use the measurement value of program execution time as a sample, and use the Gumble distribution to establish the worst statistical model of program execution time, thus Methods for Predicting WCET. However, this method still needs to run the program to obtain the measurement value samples, which has the limitation of the dynamic measurement method.
综上分析,目前WCET分析方法虽然采用静态分析方法,并从概率的角度分析得到WCET,绕开了复杂的底层硬件等特性的建模,简化了WCET估算方法,然而该静态分析方法还不是纯粹的静态分析,需要事先运行程序得到执行时间的测量值样本,然后用概率分布逼近,从而预测程序的WCET,算是一种混合分析法,因此具有很大的弊端。胡明华等人提出的方法事先对程序人工预处理较多,不能实现自动化分析,并且采用传统的PERT技术,具有很大的局限性。In summary, although the current WCET analysis method adopts the static analysis method and analyzes the WCET from the perspective of probability, it bypasses the modeling of complex underlying hardware and other characteristics, and simplifies the WCET estimation method. However, the static analysis method is not pure The static analysis of the program needs to run the program in advance to obtain the measurement value sample of the execution time, and then use the probability distribution to approximate it, so as to predict the WCET of the program. It is a hybrid analysis method, so it has great disadvantages. The method proposed by Hu Minghua et al. requires a lot of manual preprocessing of the program in advance, which cannot realize automatic analysis, and uses the traditional PERT technology, which has great limitations.
发明内容Contents of the invention
本发明的目的在于提出一种基于分布函数的最坏执行时间WCET快速估计方法,以解决现有技术中需运行程序得到测试样本的弊端和人工干预过多的问题以及传统PERT技术中贝塔分布参数估计方法的不合理性问题。The purpose of the present invention is to propose a WCET fast estimation method based on the distribution function, to solve the drawbacks of the prior art that need to run the program to obtain the test sample and the problem of too much manual intervention and the beta distribution parameters in the traditional PERT technology Unreasonableness of the estimation method.
为实现上述目的,本发明的技术方案包括如下步骤:To achieve the above object, the technical solution of the present invention comprises the following steps:
(1)通过对DSP工程目标代码(out文件)进行反汇编获得反汇编文件F;(1) Obtain the disassembly file F by disassembling the DSP engineering target code (out file);
(2)分析反汇编文件F,获取划分的各个基本块,得到程序的基本块集合B;(2) Analyze the disassembly file F, obtain each basic block divided, and obtain the basic block set B of the program;
(3)辨识基本块集合B中各基本块之间的关系,构建程序流图C;(3) Identify the relationship between the basic blocks in the basic block set B, and construct the program flow graph C;
(4)计算每个基本块的执行时间T;(4) Calculate the execution time T of each basic block;
(5)将基本块执行时间T和基本块执行次数Ts作为权值得到加权的程序流图Cw;(5) A weighted program flow diagram Cw using the basic block execution time T and the basic block execution times Ts as weights;
(6)分析加权的程序流图Cw,获得总权值最大的路径,将最大的总权值作为程序最坏执行时间WCET。(6) Analyze the weighted program flow graph Cw, obtain the path with the largest total weight, and use the largest total weight as the worst execution time WCET of the program.
本发明具有如下优点:The present invention has the following advantages:
1.本发明对DSP工程汇编代码进行静态分析,在无需运行DSP程序的情况下得到最坏执行时间,克服了传统方法中需运行程序得到测量值样本的弊端,便于实施,操作简单;1. The present invention carries out static analysis to DSP project assembly code, obtains the worst execution time under the situation that does not need to run DSP program, overcomes the drawback that needs to run program to obtain measured value sample in the traditional method, is convenient to implement, and is easy to operate;
2.本发明采用基于分布函数的方法估算WCET,绕过复杂的底层硬件特性,解决了传统方法中需对底层硬件特性进行建模的问题,具有易于实现的优点;2. The present invention adopts the method based on distribution function to estimate WCET, bypasses complex underlying hardware characteristics, solves the problem that the underlying hardware characteristics need to be modeled in traditional methods, and has the advantage of being easy to implement;
3.本发明利用基本块概念自动化构造程序流图,分析程序流图中各个结点的执行时间及程序流图的路径情况,在较少人工干预的情况得到程序的WCET,解决了传统方法中需要大量人工干预的问题;3. The present invention uses the basic block concept to automatically construct the program flow graph, analyzes the execution time of each node in the program flow graph and the path situation of the program flow graph, and obtains the WCET of the program with less manual intervention, which solves the problem in the traditional method. Problems that require a lot of human intervention;
4.本发明采用改进的PERT技术,解决了传统PERT技术中贝塔分布参数估计方法的不合理性问题,使得基本块执行时间的估算更加准确。4. The present invention adopts the improved PERT technology, which solves the irrationality problem of the beta distribution parameter estimation method in the traditional PERT technology, and makes the estimation of the basic block execution time more accurate.
附图说明Description of drawings
图1为本发明的实现流程图。Fig. 1 is the realization flowchart of the present invention.
具体实施方式detailed description
以下参照附图对本发明做进一步详细地描述。The present invention will be described in further detail below with reference to the accompanying drawings.
参照图1,本发明的具体实现步骤如下:With reference to Fig. 1, the concrete realization steps of the present invention are as follows:
步骤一,读取DSP工程反汇编文件:Step 1, read the DSP project disassembly file:
利用TI的反汇编工具对DSP工程编译得到的目标文件即out文件进行反汇编得到该工程的反汇编文件。Use TI's disassembly tool to disassemble the target file that is compiled by the DSP project, that is, the out file to obtain the disassembly file of the project.
步骤二,获得划分的基本块即图1中所示的基本块划分:Step 2, obtain the divided basic block, that is, the basic block division shown in Figure 1:
根据DSP工程反汇编文件特点及基本块划分的规则,逐行分析反汇编文件,得到划分的各个基本块,具体步骤如下:According to the characteristics of the DSP project disassembly file and the rules of basic block division, analyze the disassembly file line by line to obtain each basic block divided. The specific steps are as follows:
2.1)判断基本块的入口语句2.1) Determine the entry statement of the basic block
逐行扫描反汇编文件,判断其是否为基本块的入口语句,具体判断准则为:①程序的第一条语句;②条件转移语句或者无条件转移语句能够转移到的语句;③紧跟在条件转移语句后面的语句;④紧跟在无条件转移语句后面的语句。若满足上面条件之一,则判定为基本块入口语句,同时记录基本块入口语句在反汇编文件中对应的地址。Scan the disassembly file line by line to judge whether it is the entry statement of the basic block. The specific judgment criteria are: ① the first statement of the program; ② the statement to which the conditional transfer statement or unconditional transfer statement can be transferred; The statement behind the statement; ④ the statement immediately following the unconditional transfer statement. If one of the above conditions is satisfied, it is judged to be a basic block entry statement, and the address corresponding to the basic block entry statement in the disassembly file is recorded at the same time.
在TI C6000系列DSP汇编指令中转移语句主要体现为B指令,比如,[!A1]B.S10x00058语句为条件转移语句,该语句表示的意思为若A1等于0,则该语句执行,否则不执行;B.S1 0x00110语句为无条件转移语句,表示无条件执行该语句。对于B.S1 0x00110语句,在反汇编文件中搜索0x00110值,将其对应的汇编语句作为基本块的入口语句,同时将该语句后面的一条语句作为另一个基本块的入口语句。依据此DSP汇编指令特点并结合基本块入口语句判定准则,便可以判定反汇编文件中各个基本块的入口语句。In the TI C6000 series DSP assembly instructions, the transfer statement is mainly reflected in the B instruction, for example, [! A1] B.S10x00058 statement is a conditional transfer statement, which means that if A1 is equal to 0, the statement is executed, otherwise it is not executed; B.S1 0x00110 statement is an unconditional transfer statement, which means that the statement is executed unconditionally. For the B.S1 0x00110 statement, search for the 0x00110 value in the disassembly file, and use the corresponding assembly statement as the entry statement of the basic block, and at the same time, use the statement behind the statement as the entry statement of another basic block. According to the characteristics of this DSP assembly instruction and combined with the basic block entry sentence judgment criterion, the entry sentence of each basic block in the disassembly file can be judged.
2.2)判断基本块的出口语句2.2) Judge the exit statement of the basic block
逐行分析反汇编文件,若其满足下面两者之一则判定为基本块出口语句,同时记录该基本块出口语句在反汇编文件中对应的地址,其中基本块出口语句具体判定准则为:①下一个基本块入口语句之前的那条语句;②汇编代码的终止语句。Analyze the disassembly file line by line, if it satisfies one of the following two, it is determined as a basic block exit statement, and record the corresponding address of the basic block exit statement in the disassembly file, and the specific judgment criteria for the basic block exit statement are: ① The statement before the entry statement of the next basic block; ②The termination statement of the assembly code.
2.3)确定基本块范围2.3) Determine the basic block range
基本块由该入口语句到出口语句之间的汇编语句序列组成。确定基本块范围之后,并对各基本块依次标号为1、2、3……n,n≥1。A basic block consists of a sequence of assembly statements between the entry statement and the exit statement. After the basic block range is determined, each basic block is labeled as 1, 2, 3...n, n≥1.
考虑到划分得到的基本块数量不确定,为了便于存储及管理,本发明采用单链表结构定义、存储基本块及其相关信息,主要包括基本块标号、基本块入口语句对应的地址和出口语句对应的地址。Considering that the number of divided basic blocks is uncertain, in order to facilitate storage and management, the present invention uses a single linked list structure to define and store basic blocks and related information, mainly including basic block labels, addresses corresponding to basic block entry statements, and exit statement correspondences. the address of.
步骤三,获得图1中所示的程序流图:Step 3, obtain the program flow diagram shown in Figure 1:
根据划分得到的基本块及其标号等信息,可以获得基本块之间的关系,从而获得汇编代码的程序流图。According to the divided basic blocks and their labels and other information, the relationship between the basic blocks can be obtained, so as to obtain the program flow diagram of the assembly code.
确定基本块之间的关系主要是判断各个基本块之间是否可达,若可达则该基本块之间存在关系,否则不存在关系,其具体判断方法如下:Determining the relationship between basic blocks is mainly to judge whether each basic block is reachable. If reachable, there is a relationship between the basic blocks, otherwise there is no relationship. The specific judgment method is as follows:
3.1)若基本块i的出口语句为转移语句(条件或者无条件转移语句),并且该转移语句的目标地址等于基本块j的入口语句对应的地址,则i可以到达j;3.1) If the exit statement of basic block i is a transfer statement (conditional or unconditional transfer statement), and the target address of the transfer statement is equal to the address corresponding to the entry statement of basic block j, then i can reach j;
3.2)若基本块i的出口语句为条件转移语句,并且该出口语句对应的地址加4等于基本块k的入口语句对应的地址,则i可以到达k;3.2) If the exit statement of basic block i is a conditional transfer statement, and the address corresponding to the exit statement plus 4 is equal to the address corresponding to the entry statement of basic block k, then i can reach k;
3.3)若基本块i的出口语句为无条件转移语句,并且该出口语句对应的地址加4等于基本块k的入口语句对应的地址,则i可以到达k,但此时基本块k在基本块i、基本块j之后执行;3.3) If the exit statement of basic block i is an unconditional transfer statement, and the address corresponding to the exit statement plus 4 is equal to the address corresponding to the entry statement of basic block k, then i can reach k, but at this time basic block k is in basic block i , execute after the basic block j;
3.4)若基本块i的出口语句不为转移语句(条件或者无条件转移语句),并且该基本块的出口语句对应的地址加4等于基本块m的入口语句对应的地址,则i可以到达m。3.4) If the exit statement of basic block i is not a transfer statement (conditional or unconditional transfer statement), and the address corresponding to the exit statement of the basic block plus 4 is equal to the address corresponding to the entry statement of basic block m, then i can reach m.
通过上面的判断方法,便可以确定各个基本之间的关系,并用数据结构中基于邻接表的有向图进行描述存储,将基本块作为有向图中的各个节点,便可得到程序流图。Through the above judgment method, the relationship between each basic can be determined, and the directed graph based on the adjacency list in the data structure can be used to describe and store, and the basic block can be used as each node in the directed graph to obtain the program flow graph.
步骤四,计算图1中所示的基本块执行时间:Step 4, calculate the basic block execution time shown in Figure 1:
根据划分得到的基本块及其信息,静态估算基本块执行时间,其基本思想为:从概率角度出发,宏观上把握程序的运行时间区间,绕过复杂的底层硬件特性,采用改进的计划评审技术PERT模拟每条指令运行时间期望值和方差,根据中心极限定理,进行指令叠加后用正态分布模拟整个基本块的运行时间。然而,在进行指令叠加之前还需考虑指令的并行情况,本发明取并行指令中最大的指令执行时间作为该几条并行指令的最终执行时间,进而参与指令叠加运算。具体实现步骤为:According to the divided basic blocks and their information, statically estimate the execution time of basic blocks. The basic idea is: from the perspective of probability, grasp the running time interval of the program macroscopically, bypass the complex underlying hardware characteristics, and adopt improved plan review technology PERT simulates the expected value and variance of the running time of each instruction. According to the central limit theorem, the running time of the entire basic block is simulated with a normal distribution after instruction superposition. However, the parallel conditions of instructions need to be considered before instruction superposition. The present invention takes the largest instruction execution time among the parallel instructions as the final execution time of the several parallel instructions, and then participates in the instruction superposition operation. The specific implementation steps are:
4.1)计算每条指令运行时间的期望值μi和方差σi 2 4.1) Calculate the expected value μ i and variance σ i 2 of the running time of each instruction
本发明根据计划评审技术PERT的思想,对每条DSP汇编指令运行时间用改进的计划评审技术PERT模拟得到其期望值和方差,即采用Perry-Greig期望值近似公式计算每条DSP指令运行时间的期望值μi,采用Person-Turkry方差近似公式计算每条DSP指令运行时间的方差σi 2,具体计算公式分别为:According to the idea of PERT, the present invention simulates the running time of each DSP assembly instruction with the improved PERT to obtain its expected value and variance, that is, uses the approximate formula of Perry-Greig expected value to calculate the expected value μ of the running time of each DSP instruction i , using the Person-Turkry variance approximation formula to calculate the variance σ i 2 of the running time of each DSP instruction, the specific calculation formulas are:
μi=0.630mi+0.185(bi+ai),μ i =0.630m i +0.185(b i +a i ),
σi 2=0.630(mi-ui)2+0.185[(bi-ui)2+(ai-ui)2],σ i 2 =0.630(m i -u i ) 2 +0.185[(b i -u i ) 2 +(a i -u i ) 2 ],
式中,bi表示每条指令运行时间峰值,ai表示每条指令运行时间谷值,mi表示每条指令运行时间的最可能值,根据实验分析取i取取值范围为[1-N],N为基本块指令条数;In the formula, b i represents the peak value of the running time of each instruction, a i represents the valley value of the running time of each instruction, and mi represents the most likely value of the running time of each instruction. According to the experimental analysis, take The value range of i is [1-N], and N is the number of basic block instructions;
4.2)筛选并行指令4.2) Screen parallel instructions
在基本块中可能存在并行执行的指令,需要对指令并行性进行分析,从而使得估算的基本块执行时间更加准确。根据步骤4.2获得的每条指令运行时间的期望值μi和方差σi 2,并结合指令并行情况,筛选得到最终参加指令叠加运算的指令信息,具体为:There may be instructions executed in parallel in the basic block, and it is necessary to analyze the instruction parallelism, so that the estimated execution time of the basic block is more accurate. According to the expected value μ i and variance σ i 2 of the running time of each instruction obtained in step 4.2, and combined with the instruction parallelism, the instruction information finally participating in the instruction superposition operation is obtained by screening, specifically:
Fj=max(t1,L,tk,L,t8),F j = max(t 1 ,L,t k ,L,t 8 ),
其中,tk表示基本块中每个并行执行块中第k条指令的执行时间,k取值范围为[1-8],因为在TI DSP中最多只能有8条指令并行执行,max为取最大值操作,tk=Ak+2Sk,Ak为并行执行块中第k条指令对应基本块中指令的执行时间的期望值,Sk为并行执行块中第k条指令对应基本块中指令的执行时间的方差,Fj表示基本块中每个并行执行块的执行时间,j的取值范围为[1-M],M表示基本块中包含的并行执行块个数。Among them, t k represents the execution time of the kth instruction in each parallel execution block in the basic block, and the value range of k is [1-8], because only 8 instructions can be executed in parallel in TI DSP, and max is Take the maximum value operation, t k =A k +2S k , A k is the expected value of the execution time of the instruction in the basic block corresponding to the kth instruction in the parallel execution block, and S k is the corresponding basic block of the kth instruction in the parallel execution block The variance of the execution time of the instruction, F j represents the execution time of each parallel execution block in the basic block, the value range of j is [1-M], and M represents the number of parallel execution blocks contained in the basic block.
4.3)计算基本块执行时间均值μ和方差σ2,具体的计算公式分别为:4.3) Calculate the mean value μ and variance σ 2 of the execution time of the basic block. The specific calculation formulas are:
其中μj表示对应Fj的指令运行时间的期望值,σ2 j表示对应Fj的指令运行时间的方差。Among them, μ j represents the expected value of the instruction running time corresponding to F j , and σ 2 j represents the variance of the instruction running time corresponding to F j .
4.4)获得基本块执行时间T4.4) Get basic block execution time T
求得基本块执行时间的均值和方差后,给定时间t,就可以计算P(T‘≤t),即基本块执行时间不大于某一给定值的概率。After obtaining the mean and variance of the execution time of the basic block, given the time t, we can calculate P(T'≤t), that is, the probability that the execution time of the basic block is not greater than a given value.
对于正态分布X:N(μ,σ2),有如下事实:For the normal distribution X:N(μ,σ 2 ), there are the following facts:
P(t≤μ+σ)=84.15%,P(t≤μ+σ)=84.15%,
P(t≤μ+2σ)=97.7%,P(t≤μ+2σ)=97.7%,
P(t≤μ+3σ)=99.85%,P(t≤μ+3σ)=99.85%,
本实例取T=μ+2σ作为基本块的执行时间。In this example, T=μ+2σ is taken as the execution time of the basic block.
步骤五,获得图1中所示的加权程序流图:Step five, obtain the weighted program flow graph shown in Figure 1:
程序的最坏执行时间(WCET)不仅仅与程序的执行路径相关,还与基本块的执行时间和执行次数有关,所以要准确得到程序的最坏执行时间,需把程序的执行路径和基本块的执行时间和执行次数相结合。本发明基于此原因构建了以基本块执行时间和执行次数为权值的加权程序流图,其中基本块执行次数需要事先人为估计确定。具体实现方法为在得到的程序流图中为每个基本块添加执行时间和执行次数信息,即在程序流图的各个基本块存储结构中添加基本块执行时间和执行次数信息,从而得到加权程序流图。The worst execution time (WCET) of a program is not only related to the execution path of the program, but also related to the execution time and execution times of the basic block. The combination of execution time and number of executions. Based on this reason, the present invention constructs a weighted program flow graph with basic block execution time and execution times as weights, wherein the basic block execution times need to be manually estimated and determined in advance. The specific implementation method is to add the execution time and execution times information for each basic block in the obtained program flow graph, that is, add the basic block execution time and execution times information in the storage structure of each basic block in the program flow graph, so as to obtain the weighted program flow graph.
步骤六,计算最坏执行时间WCETStep 6, calculate the worst execution time WCET
构造了图1中所示的加权程序流图,即加权有向图之后,便可以利用有向图的一些处理方法得到所需的信息。本实施例利用路径搜索算法,寻找一条图1中所示的总权值最大的路径,则其执行时间最长,并将此路径上的总权值作为程序的WCET,具体实现步骤如下:After constructing the weighted program flow graph shown in Figure 1, that is, the weighted directed graph, some processing methods of the directed graph can be used to obtain the required information. This embodiment utilizes the path search algorithm to find a path with the largest total weight shown in Figure 1, then its execution time is the longest, and the total weight on this path is used as the WCET of the program. The specific implementation steps are as follows:
6.1)利用深度优先算法获得加权程序流图的各条路径,具体方法为:6.1) Use the depth-first algorithm to obtain each path of the weighted program flow graph, the specific method is:
6.1.1)确定程序流图的起始点和终止点,具体判断方法为:起始点为程序流图的第一个基本块,即标号为1的基本块;终止点为程序流图的整个基本块邻接表中出度为0的基本块;6.1.1) Determine the start point and end point of the program flow graph, the specific judgment method is: the start point is the first basic block of the program flow graph, that is, the basic block labeled 1; the end point is the entire basic block of the program flow graph A basic block with an out-degree of 0 in the block adjacency list;
6.1.2)将起始点入栈,并设置为已访问;6.1.2) Push the starting point onto the stack and set it as visited;
6.1.3)判断栈顶节点是否为终止点,若是则执行步骤6.1.4),否则执行步骤6.1.5);6.1.3) Determine whether the top node of the stack is the termination point, if so, execute step 6.1.4), otherwise execute step 6.1.5);
6.1.4)保存栈中元素,即为路径包含的节点,执行步骤6.1.6);6.1.4) Save the elements in the stack, which are the nodes included in the path, and perform step 6.1.6);
6.1.5)查看栈顶节点有没有后继且未访问的节点,若有则选择其中一个并将其入栈,并设置为已访问,执行步骤6.1.3),否则执行步骤6.1.6);6.1.5) Check whether there is any successor and unvisited node in the top node of the stack, if there is, select one of them and put it on the stack, and set it as visited, and execute step 6.1.3), otherwise execute step 6.1.6);
6.1.6)查看栈中元素是否为空,若是,则结束执行,否则,将栈顶节点出栈,并设置为未访问,执行步骤6.1.5);6.1.6) Check whether the element in the stack is empty, if so, end the execution, otherwise, pop the top node of the stack and set it as unvisited, and execute step 6.1.5);
6.2)计算每条路径上的执行时间,具体计算方法为:首先用每条路径上各个基本块的执行时间乘以其对应基本块执行次数,然后累加求和,即得到该条路径上的执行时间;6.2) Calculate the execution time on each path. The specific calculation method is: firstly, multiply the execution time of each basic block on each path by the execution times of the corresponding basic blocks, and then accumulate and sum to obtain the execution time on this path. time;
6.3)寻找所有路径上执行时间的最大值即图1中所示的最大执行时间,该最大执行时间即为程序的WCET。6.3) Find the maximum value of execution time on all paths, that is, the maximum execution time shown in FIG. 1 , and the maximum execution time is the WCET of the program.
综上,不难看出,通过对DSP工程汇编代码进行静态分析,在无需运行DSP程序的情况下得到最坏执行时间,克服了传统方法中需运行程序得到测量值样本的弊端,便于实施,操作简单;采用基于分布函数的方法估算WCET,绕过复杂的底层硬件特性,解决了传统方法中需对底层硬件特性进行建模的问题,具有易于实现的优点;利用基本块概念自动化构造程序流图,分析程序流图中各个结点的执行时间及程序流图的路径情况,在较少人工干预的情况得到程序的WCET,解决了传统方法中需要大量人工干预的问题;采用改进的PERT技术,解决了传统PERT技术中贝塔分布参数估计方法的不合理性问题,使得基本块执行时间的估算更加准确。In summary, it is not difficult to see that through static analysis of the DSP engineering assembly code, the worst execution time can be obtained without running the DSP program, which overcomes the disadvantages of running the program to obtain the measured value samples in the traditional method, and is easy to implement and operate. Simple; use the distribution function-based method to estimate WCET, bypass the complex underlying hardware characteristics, solve the problem of modeling the underlying hardware characteristics in traditional methods, and have the advantage of being easy to implement; use the concept of basic blocks to automatically construct program flow graphs , analyze the execution time of each node in the program flow graph and the path of the program flow graph, and obtain the WCET of the program with less manual intervention, which solves the problem of requiring a lot of manual intervention in the traditional method; using the improved PERT technology, It solves the irrationality problem of the beta distribution parameter estimation method in the traditional PERT technology, and makes the estimation of the basic block execution time more accurate.
Claims (7)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510009091.XA CN104572103B (en) | 2015-01-08 | 2015-01-08 | A kind of the worst execution time WCET method for quick estimating based on distribution function |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510009091.XA CN104572103B (en) | 2015-01-08 | 2015-01-08 | A kind of the worst execution time WCET method for quick estimating based on distribution function |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104572103A CN104572103A (en) | 2015-04-29 |
CN104572103B true CN104572103B (en) | 2017-07-11 |
Family
ID=53088269
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510009091.XA Expired - Fee Related CN104572103B (en) | 2015-01-08 | 2015-01-08 | A kind of the worst execution time WCET method for quick estimating based on distribution function |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104572103B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105677521B (en) * | 2015-12-29 | 2019-06-18 | 东南大学苏州研究院 | A kind of benchmark synthetic method towards mobile intelligent terminal processor |
CN109558141B (en) * | 2018-11-28 | 2022-05-13 | 北京东土科技股份有限公司 | Method and device for determining worst execution time WCET and readable medium |
CN109800171A (en) * | 2019-01-25 | 2019-05-24 | 上海创景信息科技有限公司 | The worst time analysis system and method based on hybrid analysis |
CN112905224B (en) * | 2019-12-04 | 2024-04-30 | 阿里巴巴集团控股有限公司 | Time-consuming determination method, device and equipment for code review |
CN111967144A (en) * | 2020-07-28 | 2020-11-20 | 陈本彬 | MPT model node frequency prediction method |
CN113658691B (en) * | 2021-08-31 | 2025-04-22 | 深圳平安医疗健康科技服务有限公司 | Clinical pathway construction method, device, equipment and storage medium |
CN114385487A (en) * | 2021-12-17 | 2022-04-22 | 斑马网络技术有限公司 | Execution time processing method and device and storage medium |
CN119310922B (en) * | 2024-12-17 | 2025-04-15 | 中电智能科技有限公司 | Method, device, equipment and medium for predicting execution time of PLC control task |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2425622A (en) * | 2005-04-27 | 2006-11-01 | Ncapsa Ltd | Programming real-time systems using data flow diagrams |
CN103207772A (en) * | 2013-04-07 | 2013-07-17 | 北京航空航天大学 | Instruction prefetching content selecting method for optimizing WCET (worst-case execution time) of real-time task |
-
2015
- 2015-01-08 CN CN201510009091.XA patent/CN104572103B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2425622A (en) * | 2005-04-27 | 2006-11-01 | Ncapsa Ltd | Programming real-time systems using data flow diagrams |
CN103207772A (en) * | 2013-04-07 | 2013-07-17 | 北京航空航天大学 | Instruction prefetching content selecting method for optimizing WCET (worst-case execution time) of real-time task |
Non-Patent Citations (5)
Title |
---|
"实时程序WCET分析模型与算法";江华;《中国优秀硕士论文学位论文全文数据库 信息科技编》;20100515;第2010年卷(第05期);第4.1节,图4.1 * |
汤森森."任务最坏执行时间分析与任务调度检测仿真工具的实现".《中国优秀硕士论文学位论文全文数据库 信息科技编》.2013,第2013年卷(第01期), * |
胡明华等."基于分布函数的程序执行时间的静态预估".《计算机工程与设计》.2006,第27卷(第16期), * |
赵修伟."基于抽象解释的实时软件WCET研究".《中国优秀硕士论文学位论文全文数据库 信息科技编》.2010,第2010年卷(第07期), * |
黎嘉翰."基于抽象分析的最坏执行时间分析技术".《中国优秀硕士论文学位论文全文数据库 信息科技辑》.2014,第2014年卷(第01期), * |
Also Published As
Publication number | Publication date |
---|---|
CN104572103A (en) | 2015-04-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104572103B (en) | A kind of the worst execution time WCET method for quick estimating based on distribution function | |
Rogge-Solti et al. | Prediction of business process durations using non-Markovian stochastic Petri nets | |
Rogge-Solti et al. | Prediction of remaining service execution time using stochastic petri nets with arbitrary firing delays | |
Yu | Using negative binomial regression analysis to predict software faults: A study of apache ant | |
Chen et al. | Functional test generation using efficient property clustering and learning techniques | |
Kozyrev | Estimation of the execution time in real-time systems | |
Tahvili et al. | Cost-benefit analysis of using dependency knowledge at integration testing | |
Lu et al. | A statistical approach to response-time analysis of complex embedded real-time systems | |
Seshia et al. | Game-theoretic timing analysis | |
Liu et al. | Program analysis: from qualitative analysis to quantitative analysis (nier track) | |
Staples et al. | Formal specifications better than function points for code sizing | |
Jakhar et al. | Measuring complexity, development time and understandability of a program: A cognitive approach | |
Yakovyna et al. | Discrete and Continuous Time High-Order Markov Models for Software Reliability Assessment. | |
Nogueira et al. | A formal model for performance and energy evaluation of embedded systems | |
Zhang et al. | Performance difference prediction in cloud services for SLA-based auditing | |
Preethi et al. | Survey on different strategies for software reliability prediction | |
Kästner et al. | Multi-core WCET Analysis Using Non-Intrusive Continuous Observation | |
Wang et al. | Software reliability accelerated testing method based on test coverage | |
Ermedahl et al. | Deriving the worst-case execution time input values | |
Iqtedar et al. | Probabilistic formal verification methodology for decentralized thermal management in on-chip systems | |
Kadam et al. | Increases the Reliability of Software using Enhanced Non Homogenous Poisson Process (EHPP), Functional Point and Test Point Analysis | |
Chen et al. | A reliability model for real-time rule-based expert systems | |
Andrade et al. | Drawing Lines for Measurement-Based Probabilistic Timing Analysis | |
CN110569155A (en) | data processing method and system, electronic device and medium | |
Goel et al. | Investigating of high and low impact faults in object-oriented projects |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20170711 Termination date: 20190108 |