Full text
Fitting Processor Architectures for Measurement-Based Probabilistic Timing Analysis Leonidas Kosmidisa,b, Eduardo Qui˜nonesb, Jaume Abellab,∗, Tullio Vardanegac, Carles Hernandezb, Andrea Gianarrod, Ian Brostere, Francisco J. Cazorlab,f aUniversitat Politecnica de Catalunya bBarcelona Supercomputing Center cUniversity of Padova dCobham Gaisler eRapita Systems Ltd fSpanish National Research Council (IIIA-CSIC) Abstract The pressing market demand for competitive performance/cost ratios compels Critical Real-Time Embedded Systems industry to employ feature-rich hardware. The ensuing rise in hardware complexity however makes worst-case execution time (WCET) analysis of software programs – which is often required, especially for programs at the highest levels of integrity – an even harder challenge. State-of-the-art WCET analysis techniques are hampered by the soaring cost and complexity of obtaining accurate knowledge of the internal operation of advanced processors and the difficulty of relating data obtained from measurement observations with reliable worst-case behaviour. This frustrating conundrum calls for novel solutions, with low intrusiveness on development practice. Measurement-Based Probabilistic Timing Analysis (MBPTA) techniques offer the opportunity to simultaneously reduce the cost of acquiring the knowledge needed for computing reliable WCET bounds and gain increased confidence in the representativeness of measurement observations. This paper describes the changes required in the design of several high-performance features – massively used in modern processors – to meet MBPTA requirements. ∗jaume.ab[email protected], Telephone: +34 934137170, Fax: +34 934137721 Preprint submitted to Elsevier Journal of Microprocessors and Microsystems June 21, 2016 © 2016 Elsevier. This manuscript version is made available under the CC-BY-NC-ND 4.0 license http://creativecommons.org/licenses/by-nc-nd/4.0/
Keywords: worst-case execution time, processor architecture, cache memories, probabilistic analysis, time randomization 1. Introduction The market for Critical Real-Time Embedded Systems (CRTES), which includes the automotive and avionics sectors, is experiencing an unprecedented growth [1]. While crucial to keeping competitive advantage, the inclusion of increasingly sophisticated value-added functions, such as for example Advanced5 Driver Assistance Systems, causes CRTES makers to continually seek higher guaranteed computational performance while striving to contain cost and power budget. This goal can only realistically be achieved by adding complex and powerful hardware accelerator features such as caches or multicore designs1. However, the use of aggressive performance-enhancing hardware features10 may highly complicate the computation of reliable and tight timing bounds2. Worst-Case Execution Time (WCET) analysis is an integral step of verification for real-time systems in general, and for CRTES in particular. One common use of WCET bounds is for schedulability analysis to ascertain whether application tasks can complete within their assigned deadlines under all conditions.15 Numerous techniques exist for performing WCET analysis, ranging from measurement-based to static analysis, via hybrid variants that use elements of both [2]. Measurement-based techniques rely on user’s ability to design stressful tests in which the application under test is run in conditions similar to the worst ones that can arise during operation. Static timing analysis is challenged by the20 difficulty to model accurately the timing of complex hardware designs, and also by the increasing amount of information needed to feed the models to estimate the WCET. Finally, hybrid approaches alleviate some of the problems of those 1This trend deflects from prior practice in CRTES, where processors used to be in-order and cacheless, to simplify verification of timing behaviour. 2In the context of timing analysis, a reliable bound is a bound that can be supported by strong arguments and proofs. 2
techniques to handle complex hardware, but hybrid approaches are subject to similar limitations.25 The availability of more powerful hardware and the quest for more functional value per unit of product also prompt CRTES industry to consider adopting mixed-criticality design solutions for their systems. From the timing perspective, which is the focus of this paper, the challenge with mixed-criticality systems lays in the need for solutions to ensure strict temporal isolation between30 programs assigned to different criticality levels, so that their behaviour can be deemed composable in the time dimension3. In the absence of effective means to abate the pessimism of WCET analysis, however, mixed-criticality solutions that achieve time isolation by fencing budget allowances, risks incurring massive over-provisioning, which defeats the purpose of combining systems together.35 Probabilistic techniques may greatly aid on all of those fronts. In particular, with Measurement-Based Probabilistic Timing Analysis (MBPTA) methods [3, 4, 5, 6], the execution time of the application can be accurately modelled – at some level of execution granularity – by a probability distribution. MBPTA seeks to determine WCET estimates for arbitrarily low probabilities of40 exceedance, termed probabilistic WCET or pWCET. As a consequence, there is some residual risk (in the form of an exceedance probability) beyond which it cannot be proven that a pWCET bound cannot be exceeded. However, this residual risk is upper bounded with a given probability, which can be determined at a level low enough to suit the needs of system design in the application do-45 main. For example, the residual risk can stay in the region of 10−9per hour of operation, largely below the acceptable probability of failure in certified systems. Under MBPTA, at a given granularity of execution, the response time of every individual execution component at that level (e.g., an instruction) is assigned a distinct probability of occurrence. This trait – which shall not be50 3Time composability is had when the timing behaviour of an individual software component does not change in the face of composition when the system is integrated, and so, the timing analysis performed in isolation remains valid at system integration. 3
confused with the probability of that component being executed in a run of the program – is described by a probabilistic Execution Time Profile (ETP), expressed by the pair: <timing vector; probability vector>. The timing vector in the ETP enumerates all its possible response times. For each response time in the timing vector, the probability vector lists the probability of occurrence of55 that response time in an instance of execution. Hence, for execution component Ciwe have ETP(Ci) =< → ti,→ pi>where → ti= (t1 i, t2 i, ..., tNi i) and → pi= (p1 i, p2 i, ..., pNi i), with PNi j=1 pNj i= 1. At the program level, MBPTA requires that the ETP for the program exercised during analysis matches or upper-bounds program’s ETP during operation.60 The processor architecture is instrumental in ensuring that individual instructions have an associated ETP. As this guarantee in turn is a crucial enabler to a sound and effective application of MBPTA, the processor architecture is the level of execution granularity on which we focus in this work. Contribution. Within the context of the FP7 PROXIMA project [7] we de-65 scribe the architecture features that a processor should possess to be amenable by construction to the use of MBPTA. We term this quality MBPTA compliance. In presenting our case, we offer insight on the costs that may be incurred in actual implementation of a MBPTA-compliant processor. To that end, we categorise processor resources according to their timing behaviour and detail70 how they should be designed for use in a MBPTA-compliant processor. Without loss of generality, we consider the inner operation of the processor to employ a number of passive resources (e.g., caches, buffers, buses, etc.). We assume each processor instruction to use some of those resources in a given order, whether in sequence or in parallel. We design processor resources so that each of them75 can be assigned a given ETP. To achieve this for all resources, we use time randomisation in some, actually very few, of them. Resources that are not time randomised must be assigned a local upper bound to their response time that can be safely composed. We assume a time anomaly free baseline architecture. The remainder of this paper is organised as follows. Section 2 introduces80 PROXIMA and contextualises this work. Section 3 presents the requirements 4
that MBPTA places on processor hardware. Section 4 classifies hardware resources in a taxonomy specifically related with MBPTA. Section 5 presents software-only solutions that could be applied to make commercial-off-the-shelf processor hardware fit for MBPTA. Section 6 presents a demonstrative imple-85 mentation of a processor architecture, purposely designed for compliance with MBPTA. Section 7 surveys related work. Section 8 draws some conclusions and outlines the future of this line of work. 2. Context within PROXIMA This work has been performed within the scope of PROXIMA [7], an In-90 tegrated Project (IP) of the Seventh framework programme for research and technological development (FP7). PROXIMA objectives include providing a complete toolchain enabling low-cost timing verification for systems based on multicore and manycore processors implementing critical real-time functionalities. In particular, PROXIMA toolchain includes the following main elements:95 •Hardware and software platforms amenable for MBPTA. One of the key elements of the toolchain is a hardware platform providing the timing properties required by MBPTA to facilitate obtaining reliable and tight pWCET estimates. This hardware platform has been implemented in a FPGA prototype used in the Space domain. Alternative software-only100 solutions have been developed to enable MBPTA on top of commercial offthe-shelf (COTS) processors that include a non-MBPTA-compliant version of the Space prototype, an Infineon AURIX T277 and a Freescale P4080 processors. MBPTA compliance in future manycore processors has also been investigated by means of architectural simulators.105 •MBPTA-compliant real-time operating systems (RTOS). The RTOS needs to be enhanced with features so that its contribution to the execution time of the tasks analysed is made constant, and hence, time-composable, and its impact on the hardware and software state is neutral w.r.t. the 5
properties needed to attain MBPTA compliance, thus being transparent110 for the timing analysis process. RTOS features have been implemented as part of PikeOS, RTEMS-SMP, ERIKA and some research-oriented RTOS. •Timing analysis tools. Appropriate methods for the estimation of pWCET are required to account for the timing behaviour of the underlying hardware/software platform, being compatible with the tracing methods in115 place, and capable of providing pWCET estimates that hold valid in front of the different sources of execution time variation that can be exercised during operation such as hardware/software initial state, input values, execution path traversals, etc. Some of these methods have been implemented as part of RapiTime commercial toolchain whereas others will remain as120 standalone tools. These elements have been implemented by a set of industrial and academic partners including hardware, RTOS and timing analysis tool vendors and related research institutions. Evaluation is performed on a number of case studies from the avionics, space, railway and automotive domains. The project finishes in125 September 2016, so most technologies have reached a high degree of maturity. This paper reviews MBPTA-compliant hardware behaviour to deliver the timing properties needed to estimate reliable and tight pWCET. We also show how some of these goals can be achieved in the absence of MBPTA-compliant hardware.130 3. MBPTA Requirements on Hardware Design 3.1. Taxonomy of Timing Analysis Techniques We differentiate three main timing analysis types, each of which has a deterministic and probabilistic variant. •Measurement-based deterministic timing analysis (MBDTA) techniques135 take advantage of the observation data obtained from executing the programs of interest on the real processor hardware. Simple high-watermark 6
(a) Probability distribution (b) Cumulative distribution function (PDF) function (CDF) and 1-CDF (c) CDF and 1-CDF (d) Example of the pWCET (logarithmic scale) curve Figure 1: Synthetic program PDF, CDF, 1-CDF and pWCET curve techniques have been used in industry for many years. They are usually coupled with detailed analysis of the software structure that provides confidence in exercising those worst-case paths or scenarios at the application140 level that can arise during system operation. To make safety allowances for the unknown (which the cognizant associates with the difficulty of determining the hardware worst case), an engineering margin is often added to the computed bound. The intent of the margin is striking some sound balance between pessimistic overkill and risk of underestimation. Deter-145 mining a reliable and tight engineering margin is extremely difficult – if at all possible – especially when the system may exhibit discontinuous changes in timing due to unanticipated timing behaviour. The confidence had on the WCET estimate determined with MBDTA is, therefore, fully- 7
dependent on the ability of the end user to identify what behaviour needs150 to be triggered in the hardware and software to observe the WCET that can occur during operation (or execution times close to it) and to produce program inputs that trigger that behaviour. The increasing complexity of the hardware (i.e. the use of cache hierarchies and multicores) is also a threat for the scalability of this approach [8].155 •Static deterministic timing analysis (SDTA) techniques rely on the construction of a cycle-accurate model of the processor and an abstract representation of the application code. SDTA searches the resulting state space for the worst case, with constraint-based integer linear programming. Obviously, such an analysis cannot carry forward all the possible states of160 execution. Hence, conservative choices are made during the process, thus trading a reduction in the state space for increased pessimism [9, 10, 11]. SDTA has abundant need for information about the timing specification of the processor hardware and flow facts for the application. As the prediction must necessarily err on the side of pessimism, any lack of information165 about the timing behaviour of the object of analysis (e.g., the address of a memory access needed to determine if execution hits or misses in cache) or about processor timing behaviour degrades the tightness of the WCET estimate. Further, the result of the analysis is as reliable as the input provided to it [8]. The rise in complexity of next-generation CRTES greatly170 exacerbates this problem: the volume of detailed knowledge needed to construct a sufficiently accurate execution model as well as the time, effort, cost and complexity entailed in acquiring that information, challenge the adoption of SDTA for CRTES applications. •Hybrid techniques build upon MBDTA, but collect execution time mea-175 surements at finer granularities such as, for instance, per function, per basic block, etc. Then, they operate on those measurements to account for unobserved behaviour. For instance, RapiTime [12] creates a representation of the control flow of the program and operates on the mea- 8
surements obtained for each of the elements in the program, to generate180 measurements for unobserved execution paths. This approach can lead to higher confidence than that for traditional MBDTA, by inflating WCET estimates, and a lower effort/cost of use. However its confidence still depends on the ability of the user to make sound assertions on flow facts and to understand and control numerous hardware-related aspects such185 as cache interactions among programs and inter-task interference in the use of hardware shared resources in multicores [8]. At the present state of the art, probabilistic timing analysis (PTA) can be applied in either a static (SPTA) [5] or measurement-based (MBPTA) [4] fashion: we refer the interested reader to those works for details on PTA fundamentals.190 In this work we focus on MBPTA only since it is more mature for industrial use than SPTA [8]. MBPTA generates a probability distribution that describes the maximum probability with which an instance of the program can exceed its assigned budget. As illustrative example, Figure 1(a) shows the probability distribution195 function (PDF) of the execution times of a (single-path) synthetic program on a MBPTA-compliant processor architecture. From the PDF, one can build the cumulative distribution function (CDF) and its complementary (1-CDF) exceedance function or pWCET, which tells the probability that the execution time of one run of that program may exceed a given threshold (see Figure 1(b)200 and Figure 1(c)). Using conventional means, for a set of Rruns, one could only derive an exceedance probability of 1/R at most. For smaller probabilities, techniques such as Extreme Value Theory (EVT) [13] are needed: Figure 1(d) illustrates the hypothetical result of applying EVT to a collection of R= 1,000 measurement runs taken on a MBPTA-compliant processor. The dotted line205 represents the 1-CDF derived from the observed execution times. The continuous line represents the projection obtained with EVT. 9
for a given program. The significance of this impact depends on the magnitude of the jitter, the program under study, and the analysis method. For any given jittery resource, either all requests to it are assumed to incur the worst-case360 latency – as long as timing anomalies can be excluded [20] – or the resource is time-randomised. The design choice for a given resource needs to trade the design cost for time randomising against the degradation of WCET tightness for always assuming worst-case latency. The ETP for a resource rwl, assumed or configured to worst-case latency,365 can be expressed as ETPrwl =<(lmax),(1.0) >, where lmax is the worst-case latency of the resource. An example of the impact of such upper bounding is shown in Figure 3(b). In the example, the actual probabilities for each latency are unknown; only frequencies can be obtained; upper bounding therefore is needed. This would correspond, for instance, to the case of a floating-point370 divider whose latency depends on the input values operated since, typically, we cannot determine what their distribution will be during operation. Conversely, the ETP of a time-randomised jittery resource rjis: ETPrj=< (l1 j, l2 j..., lk j),(p1 j, p2 j, ...pk j)>where li jand pi jrepresent the different latencies of the resource rjand their associated probabilities of occurrence. This is shown375 in Figure 3(c). This could be the case of a cache access to a time-randomised cache, whose hit and miss probability depend on the (probabilistic) state left by previous cache accesses. Note that the probability of a given latency is different from the frequency with which it may occur. For instance, consider a resource R1with → t1= (t1 1, t2 1). Latency t1 1in the timing vector would have a true380 probability of occurrence p1 1= 0.5 if – in the implementation of that resource – on every request to it we tossed a coin and the request had latency t1 1if we saw heads and t2 1otherwise. In contrast, we could have a deterministic stateful resource R2with latency → t2= (t1 2, t2 2). If for R2we observed that, for a given program, 50% of the requests take t1 2and 50% t2 2, we would have a 50% observed385 frequency for each possible latency of that resource, but not necessarily a true 50% probability. For the purposes of MBPTA, the timing behaviour of jitterless and jittery 16
(either upper-bounded or time-randomised) resources can all be described probabilistically by ETP.390 4.3. MBPTA compliance via padding The ultimate goal of a MBPTA compliant architecture is to ensure that measurements taken during analysis at program granularity are subject to a probabilistic behaviour defined by an ETP that upper-bounds that of the program during operation. The previous three cases (jitterless, upper-bounded and time-395 randomised resources) – together with the proper control on input-dependent sources of jitter (e.g. execution paths) – define the canonical approach to reach MBPTA compliance. Notably, there are other ways to achieve MBPTA compliance such as execution time padding. With padding, a fixed value or a distribution is composed400 (added) to the program ETP at analysis such that the result of the composition is another ETP that upper-bounds that of the program during operation. This is better illustrated with an example. Let us assume we have a single path program comprising floating point operations. Further assume that all floating point operations can take a variable latency from lmin to lmax depending on the405 values operated. Controlling values operated is, in general, beyond the reach of the user. In this scenario padding can be used by adding to each of the measured execution times of the program nfpops ×(lmax −lmin). This approach makes the pessimistic assumption that during analysis measurements, each of the nfpops floating point operations of the program experienced a delay of lmin,410 while during operation each of them may take lmax. Hence, for each operation we increase the execution time observation by the maximum impact this can have lmax −lmin. Note that this is a form of enforcing the worst-case latency by software-only means. More sophisticated forms of execution time padding are possible. For in-415 stance, let us assume that the ETP of an instruction iat analysis does not upper-bound its ETP during operation. Further assume another instruction j for which its analysis-time ETP upper-bounds the operation one. If an argu- 17
ment can be built on the fact that the reduction in execution time caused by iis smaller than the increase caused by j, and both iand jalways execute,420 then the net impact is an analysis-time ETP upper-bounding the one during operation, which suffices for the application of MBPTA. 4.4. ETP of several execution components A composite ETP can easily be determined for every individual program component (ETPpc), e.g. a dynamic instruction, that uses processor resources,425 which has an associated ETP describing their latency. That is ETPpc = f(ETP1, ETP2, ..., ETPn), where ETPiis the probabilistic execution time of resource ri. •Sequential composition: the ETP, fs(ETP1, ET P2, ..., ETPn), resulting from sequential composition is one where latencies and probabilities are430 determined by the type of dependence across the input ETP (whether systematic or probabilistic, as shown later in Section 4.5). The reader should note that sequential composition as intended here is architectural, hence referring to execution, and not mathematical, hence related to abstract interpretation. The latter is employed in SPTA and uses the convolution435 operator for combining the ETPs of static instructions (e.g., instructions in the object code of the program). Let us assume two ETPs, ETP1=<(1,2),(0.5,0.5) >and ETP2=< (5,10),(0.5,0.5) >. Further assume that whenever ETP1takes latency 1, then ETP2=<(5,10),(0.8,0.2) >and whenever ETP1takes latency440 2, then the second ETP is ETP2=<(5,10),(0.2,0.8) >. In this case, ETP1+2 =fs(ETP1, ETP2), leading to ETP1+2 =<(6,7,11,12), (0.4,0.1,0.1,0.4) >. Still, ETP2takes, for instance, latency 5 with probability 0.5 because P(ETP1= 1) ×P(ET P2= 5) + P(ET P1= 2) × P(ETP2= 5) is 0.5×0.8+0.5×0.2=0.5.445 The key trait here is that the dependence that ETP2has on ETP1can be modelled probabilistically. As a result, the executions carried out during 18
analysis, capture the behaviour of this dependence and hence, cause it to be covered by the pWCET estimate derived to bound the execution time during operation.450 This is the typical case for the ETP of cache accesses since the ETP of a given cache access depends on what the previous accesses did. For instance, if a first access hits, it does not evict any data and the second access may have a given hit probability. However, if the first access misses, it will evict some data likely decreasing the hit probability of the second455 access. Still, the second access has an ETP since the dependence between the first and the second access is probabilistic given that the first access will hit or miss with a true probability when using time-randomised caches. •Parallel composition: processor resources may also be arranged in parallel. Examples of parallel resources are some particular designs of cache460 memories and translation lookaside buffers (TLB), where cache access and address translation can occur in parallel. With parallel arrangements, no dependence across ETP can exist, since for that to exist some sequential relation across ETP should occur, which should be addressed by sequential composition. The probabilities of the parallel composition465 (fp(ETP1, ETP2, ..., ETPn)) correspond to the multiplication of probabilities across ETP. However, the latencies correspond to the maximum latency of the probabilities multiplied. This is illustrated with the following example. Let the ETP for two program components be ETP1=< (1,4),(0.4,0.6) >and ETP2=<(2,3),(0.3,0.7) >respectively. The470 ETP from their parallel composition, ET P1+2 =fp(ETP1, ET P2), is ETP1+2 =<(2,3,4),(0.12,0.28,0.6) >. 4.5. Dependence across ETP The property of independence and identical distribution can be erroneously construed as needing instructions, and their associated ETP, to be indepen-475 dent of one another. This is incorrect: the i.i.d. property applies – in certain 19
conditions – to the observation of the execution time of individual dynamic instructions across multiple executions. Notably however, the i.i.d. properties may not apply across distinct dynamic instructions (that is to say, to fragments of program execution that contain more than one instruction). Instructions may480 in fact have dependences among them when the outcome of one random event that represents the execution of one dynamic instruction has an impact on the ETP of following instructions. We call causal dependence any dependence among two instructions in a given precedence order such that the execution of the earlier one affects the timing485 behaviour of the later one. Obviously, the execution time of the earlier one determines when the later one can start executing, but our notion of causal dependence actually means that the latency a given instruction not only affects the time at which the later one starts but also its duration. We differentiate two types of causal dependences among a source (preced-490 ing) instruction and a target (subsequent) instruction that do not prevent the latter instruction from exhibiting a MBPTA-compliant timing behaviour across program runs. •Systematic dependence: The ETP of the target instruction is affected by the execution of the source instruction. This effect may alter the ETP of495 the target instruction in any way like, for instance, shifting some latencies in its ETP or making new latencies appear in the ETP of that instruction. None of this however causes the target instruction to lose its MBPTA- compliant behaviour. This can be better understood with an example. Recall the goal of500 MBPTA is to control sources of execution time variability in such a way that the observations taken during the analysis stage can be used to upper bound probabilistically the timing behaviour of the program during operation. Let us consider two instructions, one source and one target, on a given basic block, bb1. Let us also assume that the ETP of the505 target instruction is ETPisol target =<(t1, t2, t3),(p1, p2, p3)>if it runs in 20
isolation. Further assume that the execution of the target instruction as part of the basic block bb1, hence in the presence of the source instruction, is ET Pbb1 target =<(t1, t2, t0 3, t4),(p1, p2, p0 3, p4)>. In this new ETP the probability of t3changes and a new latency t4can be experienced. In510 this example the target instruction, which in fact represents a dynamic instruction, is executed as part of the basic block. Such target (dynamic) instruction is attached to a single ETP, ETPbb1 target, irrespective of this being different from the ETP holding when the instruction was executed in isolation. Further, this ETP stays constant during analysis and operation.515 Therefore, all observations of the execution time of the target instruction as part of this basic block are observations of this ETPbb1 target. The key trait here is that the ETP must hold for every dynamic instruction over successive executions of the program. In the previous example, if the initial conditions are fixed, the target dynamic instruction in bb1 will have a520 single ETP. •Probabilistic dependence: The execution of the source instruction has a probabilistic effect on the ETP of the target instruction. This is the case of memory accesses to a time randomised cache. A probabilistic causal dependence causes that dynamic instruction to suffer a transformation in525 its ETP. However, given that the causal effect in the target instruction is probabilistic, this is equivalent to applying a transfer function transf() that takes as an input an ETP and provides as an outcome another ETP tranf(ETPisol target) = ETPbb target. Again, the key trait is that the target (dynamic) instruction is always subject to the same ETPbb target thus en-530 abling MBPTA to properly capture its timing effects at analysis time analogously as they will occur during operation. Overall, on a PTA-compliant platform, any hardware and software state with bearing on the execution time after of any dynamic instruction of the program is reached with a given probability. Therefore, one can build the ETP of every535 single program path that can be traversed by an observable execution by collect- 21
ing the execution time of each final state of that system and its corresponding probability of occurrence. Therefore, the execution time of the program as a whole (seen as the traversal of a given path) has an ETP and is, hence, a random variable with i.i.d. properties.540 4.6. More complex single-core processor architectures We have shown that jittery deterministic resources need to be redesigned to make their timing behaviour amenable to MBPTA by construction. This can be done by either randomising their timing behaviour or enforcing them to their worst-case latency. Resources with probabilistic latency perfectly fit the545 MBPTA principles. However, jittery processor resources exist that do not easily fit in the taxonomy we used in Section 4.2. This is the case of resource buffers, also known as first-in first-out (FIFO) queues or simply buffers. A buffer resource may stall if it gets full, which increases the latency of the requests that use it. Stalls across pipeline stages may for example occur owing550 to contention for buffer space; those stalls would be real enough to fear, but difficult to predict causally. The main characteristic of buffer resources, however, is that they are not sources of jitter but rather jitter propagators [21]. The intuition here is that if all jitter that occurs in a processor is probabilistic, that is, it is solely due to time-555 randomised resources, any combination of random events has a given probability of occurrence. Now, as every single combination of events causes the program to incur a distinct execution time, each execution time has a distinct probability of occurrence. For each combination of random events, resource buffers may get full and consequently increase the execution time of the program. However,560 buffers themselves do not introduce any change in the probability distribution of random events. The presence of buffers may well cause the execution time of the program to vary, but each execution time continues to have a true probability of occurrence, which is what MBPTA requires. In general, all hardware resources can be made MBPTA-compliant as long565 as they either do not introduce jitter on their own (hence they are fixed-latency 22
or else just jitter propagators), their jitter can be upper-bounded or else it can be randomised. 4.7. Multicore processor architectures In single-core architectures, the execution time of a software program is570 influenced by (1) the initial processor state when the program starts executing – which in turn is affected by previous execution, (2) the RTOS interferences that it may suffer during execution, (3) the input data that influence control flow or data-dependent jitter in jittery processor resources, and (4) the randomisation occurring in processor resources.575 The effect of initial conditions, (1) above, can be taken into account by flushing the state of all stateful resources (e.g., caches) prior to the execution of the program. For the RTOS, state-of-the-art solutions exist to make its interference amenable to probabilistic analysis [11]. The effect of input data on the control flow of the program is controlled by580 state-of-the-art techniques that work in unison with MBPTA [19]. For instance, authors in [19] show how to pad execution time measurements at basic block granularity to discount the benefit obtained by executing specific paths when that benefit would not be obtained through other paths. The effect of input data on the latency of processor instructions using resources with data-dependent585 jitter as well as the jitter introduced by the randomised hardware resources are controlled with standard PTA techniques [5]. In multicore architectures, in addition to all the sources of execution time variability that appear in a single-core architecture, a further one arises: intertask interference5.590 In general in single-core architectures, given two instructions ixand iyof the same program, where the subscripts determine the order in which each 5This term does not include the interference that in single core processor occurs in caches and TLBs owing to context switches. This is intentional as this overhead can be quantified probabilistically in the context of MBPTA [22]. 23
instruction is executed into the processor, iymay have a potential impact on the execution time of ixonly if y < x, meaning that iyexecutes prior to ix. In a multicore, when several programs run in parallel, the execution time of595 one instruction iT1 xin program T1may be affected by any other instruction iTj y from any program Tjthat may run at the same on any other available core. If precedence or exclusion constraints are set in the system such that Tjcan be asserted to not execute in parallel T1, then the inter-task interference generated by iTj ydoes not affect iT1 x. If no such assertion can be made instead, T1and600 Tjcan execute in any order. Hence they may execute in parallel on different cores, so that iTj ymay cause inter-task interference on iT1 x. It is evident that we cannot conceivably capture the effect that any single instruction of any task iTk jmay have on any other instruction of any other task iTm lin the system. Should this be required, MBPTA would become intractable. To prevent this,605 the design of MBPTA-compliant multicores must ensure that the worst effect that one program can have on the execution of any other program owing to inter-task interference can be probabilistically bounded. Interestingly, the MBPTA-compliant design principles already outlined for single-core processors extend quite well to the design of multicore architectures.610 The resources for which this approach is most advantageous are those that are shared upward the processor hardware architecture off the core, where they may cause massive inter-task interference. Next we review them in detail. Shared bus. The authors of [23] show that the arbitration latency of a shared bus can either be upper bounded at analysis time or randomised so that615 the timing behaviour observed at analysis matches or upper-bounds that which may emerge during operation. In fact, upper bounding the bus arbitration latency has been shown to be viable also for time-deterministic systems [24]. This approach ensures that the latencies and probabilities of the ETP derived for this resource already account for worst-case interaction in this shared resource. For620 instance, if latency is upper-bounded, the ETP accounting for arbitration delay will have the form ETPbus =<(latbusmax),(1.0) >, where latbusmax stands for the maximum bus arbitration latency. Alternatively, if random (lottery) or 24
random permutations arbitration is used, ETP can also be derived as already proven in [23].625 Shared memory controller. The same approach used for buses can be applied to the arbitration in the memory controller. Thus, the latency of a shared memory controller can be upper bounded, which is fine for MBPTA compliance. Again, that measure is in line with findings for time-deterministic systems [25]. Thus, if latency is upper-bounded, the ETP for the memory630 controller will have the form ETPmemctrl =<(latmemctrlmax),(1.0) >, where latmemctrlmax stands for the maximum memory controller arbitration latency. Note that random (lottery) or random permutations arbitration can also be alternatively used since ETPs exist for both policies [23]. However, memory latency can also vary based on the last operation performed due to the fact635 that the latency of a read (or write) operation varies depending on whether the last operation was a read or write operation. Authors in [25] describe how to upper-bound memory access latency, so an ETP can also be derived for this component with the form ETPDRAM =<(latDRAMmax),(1.0) >, where latDRAMmax stands for the maximum memory access latency. Note that in640 this case, latency cannot be randomised since it depends on non-probabilistic events such as the particular memory accesses performed by tasks running in other cores, which are unlikely to be known at analysis time. Shared cache. Cache partitioning has been proved to be a practical way to attenuate the interference effects from cache sharing. This solution was first645 shown for time-deterministic systems [24]. However, since it eliminates all cache conflicts among tasks running on different cores, it cancels out the multicore side of the cache problem, and allows using, for each multicore, the solutions devised for single-core processors. An alternative approach has been put forward in [26], where a hardware650 feature is proposed to limit the eviction frequency caused by individual tasks on a shared time-randomised cache. That mechanism allows controlling inter-task interference without resorting to cache partitioning, which reduces the pWCET against the partitioned case, as long as inter-task interference distributes ran- 25
This leads to what we term the ETP of the front-end (fend): ETPfend = fs(fp(ETPIL1, ETPIT LB ), ETPDRAM ). Then, the resulting ETP, ETPfend needs to be composed with the ETP of the buffer between the front-end and the back-end (ETPbuf1), the ETP of the decode stage (ETPdec), the buffer after decode (ETPbuf2), the register access stage (ETPra), the buffer after register800 access (ETPbuf3), the core operations (ETPexec), the buffer after execution (ETPbuf4), the memory operations stage (ETPmem), the buffer after memory operations (ETPbuf5), the exceptions stage (ETPexcep, the buffer after exceptions (ETPbuf6) and the write-back stage (ETPwb). While ETPdec,ETPra,ETPexec,ET Pmem,ETPexcep and ETPwb have the805 form <(l),(1.0) >for core operations, ETP for buffers have as many latencies as potential stalls they may produce, and their probability vector is 0.0 for all latencies but one, whose probability is 1.0. Which latency has probability 1.0 is determined by the state left by previous instructions. More details about how buffers increase execution time without expanding the number of probabilistic810 states can be found in [21]. If all actions occurred sequentially (thus omitting interactions in the buffer to memory), the ETP for core operations would be as follows: ET Pcore =fs(ET Pfend, ET Pbuf1, ET Pdec, ET Pbuf2, ET Pra, ET Pbuf3, ET Pexec, ET Pbuf4, ET Pmem, ET Pbuf5, ET Pexcep, ET Pbuf6, ET Pwb) (1) Memory operations have the same ETP as core operations for the different stages and buffers except for the memory stage (ETPmem). The memory815 latency, instead of depending on ETPmem, depends on the time of the data memory path (dmpath) composed by the data cache and the data TLB, which are accessed in parallel, and memory latency, which is accessed sequentially: ETPdmpath =fs(fp(ETPDL1, ETPDT LB ), ETPDRAM ). Therefore, the ETP for memory operations (still omitting interactions in the buffer to memory) is820 as follows: 32
ET Pmem =fs(ET Pfend, ET Pbuf 1, ET Pdec, ET Pbuf2, ET Pra, ET Pbuf3, ET Pexec, ET Pbuf4, ET Pdmpath, ET Pbuf5, ET Pexcep, ET Pbuf6, ET Pwb) (2) Finally, we must consider that the misses occurring in the DL1/DTLB and in the IL1/ITLB are serialised in the buffer that connects the core to the memory controller. Again, this buffer has an ETP of the same form as any other buffer (ETPbufDRAM ). Unlike previous buffers, where an instruc-825 tion could only be delayed due to activities of older instructions, here data requests from some instructions may get delayed by instruction requests of younger instructions. Still, the buffer can only have a finite number of states and each state will have a probability that, hypothetically could be derived by expanding the probability tree from the beginning of the execution of the830 program. Thus, ETPbufDRAM should be composed serially with the ETP of the memory accesses, so ETPfend and ETPdmpath should be ETPfend = fs(fp(ETPIL1, ETPIT LB ), ETPbufDRAM , ET PDRAM ) and ETPdmpath = fs(fp(ETPDL1, , ETPDT LB), ETPbufDRAM , ETPDRAM ) for a correct calculation of the ETP of core (Equation 1) and memory operations (Equation 2).835 6.4. Checking the i.i.d. hypothesis The existence of an ETP for individual instructions ensures that the program execution times exhibit the prerequisite i.i.d. property of MBPTA. With MBPTA, we empirically ascertain whether this claim holds, by using proper i.i.d. tests applied on the execution times of running EEMBC benchmarks [32]840 on the processor architecture. To assert independence we use the Ljung-Box test [35] (LB). The Ljung-Box test is a powerful method that tests autocorrelation for different lags simultaneously, so for each datum with the next one (lag 1), the one after (lag 2), and so on and so forth. In particular we test all lags up to 20 as shown appropriate845 by authors in [36]. 33
Table 3: Independence and identical distribution test results (2nd and 3rd columns), and average execution time and pWCET bounds of the complex MBPTA-compliant processor vs. an equivalent conventional processor (4th, 5th and 6th columns) Benchmarks Statistical tests Timing analysis results Inde- Identical Average Max pWCET pence distribution Exec. Time Exec. Time 10−15 a2time 0.31 0.34 0.10% 1.79% 8.44% basefp 0.85 0.91 0.00% 0.06% 0.36% bitmnp 0.97 0.77 -0.01% 0.12% 0.26% cacheb 0.87 0.06 0.02% 0.41% 3.27% canrdr 0.18 0.82 0.00% 0.00% 0.12% matrix 0.25 0.70 0.00% 0.01% 0.11% pntrch 0.79 0.93 0.00% 0.00% 0.12% puwmod 0.99 0.85 0.00% 0.00% 0.12% rspeed 0.16 0.50 0.00% 0.00% 0.12% tblook 0.75 0.86 0.07% 0.86% 2.80% ttsprk 0.36 0.80 0.00% 0.03% 0.24% To check that the identical distribution hypothesis stands, we use the Kolmogorov- Smirnov (KS) goodness-of-fit test [37]. We use a 5% significance level (a typical value for this type of tests), whereby absolute values obtained with both the LB and KS tests should be above the threshold (0.05) to assert independence and850 identical distribution respectively. In particular, both tests, LB and KS, deliver values in the range [0,1]. Any value below the significance level (0.05) rejects the hypothesis, and cannot reject it otherwise. For each benchmark, less than 1,000 runs were needed for each program, in line with previous experience [4, 31]. Running 1,000 times a program whose855 typical execution time is in the order of few milliseconds (as typical of CRTES) implies that pWCET estimates for that program can be obtained in a few sec- 34
onds altogether, which is a rather affordable overhead for an industrial development timescale. Under the heading ‘Statistical tests’ Table 3 reports the results of both tests for all benchmarks. Since values for both tests, LB and KS,860 are always above the significance level, 0.05, both tests are passed in all cases, which proves that the example architecture meets the i.i.d. requirement of our MBPTA approach. 6.5. pWCET In this section we show the type of probabilistic WCET estimates that can865 be obtained for the example architecture, with the method presented in [4]. The black line reaching arbitrarily low exceedance probabilities in Figures 5 and 6 plots the pWCET distribution obtained for the a2time and cacheb benchmark programs of the EEMBC suite, run on the example architecture. The red line (reaching only down to 10−3exceedance probability) plots the empirical 1-CDF870 of the 1,000 runs performed for these benchmarks. The X-axis shows the execution time and the Y-axis the probability of exceeding it. Assuming for the sake of argument that an exceedance event represents a timing failure in the system, we may concentrate on exceedance probabilities of 10−12 and 10−15 per run, well within acceptable probabilities of failure in the safety regulation of875 automotive and avionics systems. Increasing the exceedance probability (moving up in the Y axis) does not translate into large increases in the WCET estimates (moving right in the X axis); quite the contrary in fact, as the pWCET curves appear to have a very steep slope. In general, the larger the number of random events entailed in a880 run (e.g., the number of cache accesses), the less likely that abrupt performance variations occur other than (if at all) at extreme exceedance thresholds. Thus, execution time variation is moderate and the pWCET curve is steep. As the example processor architecture demonstrably meets the requirements needed for MBPTA, it can be argued that MBPTA can be applied to performance-885 aggressive hardware features. Interestingly, the MBPTA process stays unchanged in procedure and effort, while the pWCET estimates become consider- 35
Figure 5: pWCET estimates for the a2time benchmark program. Figure 6: pWCET estimates for the cacheb benchmark program. ably smaller (up to 9% in the specific experiment) than the engineering margin often applied in measurement-based deterministic timing analysis by industry (20%) in the case of [38].890 To the best of our knowledge, complex architectures including caches, TLB, and staged pipelines with buffers, have not been unrestrictedly used with static timing analysis, unless with cautionary restrictions that mitigate the rapid degradation in the tightness of the WCET estimates that arise from resources being used whose state cannot be determined exactly. MBDTA also is at a loss895 with those processor architectures, because no suite of observation runs can pos- 36
sibly cover the whole state space of all resources exhaustively. Those techniques are also known to be fragile even to the way the program is built, because small changes in the way program objects are allocated in memory, which are hard to capture in test suites, may lead to abrupt changes in execution time.900 6.6. MBPTA-compliant architectures performance The above results show that the proposed MBPTA techniques, united with the proposed modification to the design of processor resources, enable CRTES designers to aim at considerably higher levels of guaranteed performance. Notably, there is a further angle of interest to quantify the benefit of the905 MBPTA approach discussed in this paper. Under the heading ‘Timing analysis results’, Table 3 reports average execution times and pWCET estimates for an exceedance threshold of 10−15 per run, obtained for the EEMBC benchmark programs on the example processor architecture. The values are normalised against those obtained running the same programs on an analogous architecture910 that implements modulo placement LRU replacement caches and TLB instead of random placement and replacement, and where the latency behaviour of the FDIV and FSQRT operations had been set to operation mode, hence not set to the worst-case outcome as in the analysis mode. For instance, cacheb executes in 7,150,507 cycles in the non-time-randomised915 architecture. The 1,000 runs of cacheb on our time-randomised architecture take 7,152,211 cycles on average (0.02% more than without time randomisation) and 7,179,573 cycles at most (0.41% more than the actual execution time without time randomisation). The pWCET curve at an exceedance threshold of 10−15 per run is 7,384,084 cycles, as shown in Figure 6 (3.27% higher than the actual920 execution time without time randomisation). The average execution time of the MBPTA-compliant architecture is roughly the same as for the time-deterministic alternative, thus showing that time randomisation fares well even in the average case. If we compare the maximum observed execution time in the MBPTA-compliant architecture, it is only925 slightly above that of the time-deterministic alternative. Even more interesting, 37
pWCET estimates are, on average, only up to 9% higher than the average performance obtained for a processor architecture implementing modulo and LRU as the placement and replacement policies for all caches, and without upper bounding FDIV and FSQRT latencies.930 Whereas the WCET values for those programs on the time-deterministic architecture are not available (computing them would require the porting of static timing analysis tools, which was outside of the scope of this work), relevant literature shows that WCET values are intrinsically very conservative and can be many times greater than the average case [39]. Our study shows that, for our935 MBPTA-compliant design, the observed inflation was up to 8.44% for a2time, which allows arguing that MBPTA-compliant processors are viable for CRTES industry, thus below the usual 20% engineering margin applied on top of the maximum observed execution time [38]. The pWCET estimates are only up to 8.44% higher than the actual execution time on a time-deterministic architecture940 because the platform is properly designed so that the instruction and data sets of the programs fit in IL1 and DL1 caches respectively, thus experiencing very few misses, and FDIV and FSQRT operations are extremely infrequent in general, and in the EEMBC benchmarks in particular. It is worth noting that the ETPs for individual dynamic instructions in945 our processor are non-independent across them (see Section 4.5). This occurs because random-placement caches (as an instance of a state-sensitive timerandomised resource) create dependence across instructions in the same run since any (random) cache set conflict occurring during a particular run holds systematically across the whole run. Such dependence across ETPs for differ-950 ent instructions is captured in the observations taken at analysis time, and are accounted for in the pWCET estimate derived with MBPTA. 7. Related Work There is an increasingly rich literature on the problem of WCET analysis. One substantial part of the state of the art, with more history and tradition,955 38
addresses Deterministic Timing Analysis (DTA) techniques, which include its static and measurement-based variants, SDTA and MBDTA respectively. The state of the art in DTA is comprehensively surveyed in [2], so we omit discussing it here. The other, more recent, but rather vibrant, considers the various flavours of PTA.960 The static variant of MBPTA, known as SPTA, has been studied for relatively simple processor architectures that use time-randomised caches [5, 40, 41]. Authors in [42] present the first comprehensive comparison among SDTA, SPTA and MBPTA techniques showing that if enough information is had for the timing analysis, whether one technique is superior to the others depends on the965 particular characteristics of the program under analysis. Therefore, there is not a dominant technique. However, as detailed in [8], techniques such as SDTA and SPTA are more sensitive to the amount of information had for the timing analysis process, with effects on either tightness or reliability. This relates to the fact that SDTA and SPTA need a detailed timing model of the hardware970 and additional flow-facts describing the operation of the software such as value ranges and memory addresses. Conversely, MBPTA, the focus of this paper, requires amounts of information comparable to those obtained by end users in the context of MBDTA, but it scales to arbitrarily complex software running on top of high-performance975 hardware easing the collection of evidence usable for certification purposes [43]. MBPTA has been used in the context of time-randomised architectures for single-path programs [4, 44] and multi-path programs [6, 19]. At hardware level, random placement was proposed in [31] to enable the use of set-associative caches for MBPTA. [45] and [16] discuss the reliability of980 pWCET estimates obtained with MBPTA on top of random placement caches. In particular authors discuss representativeness related to the fact that some random events may have a low probability to be captured in the measurement runs, yet have a high impact on execution time. The latter work [16] and other recent works [17] conduct thorough analysis of those scenarios in the context of985 MBPTA and propose ways to address them. 39
EVT has been applied to time deterministic architectures to derive execution time bounds [46]. While randomisation – and creating deterministic bounds to jitter resources – is not needed for the application of EVT, deterministic architectures seriously difficult deriving a representativeness argument.990 That is, with EVT-only approaches, building a representativeness argument that analysis-time execution conditions capture those that can arise during operation is completely left to the user. Instead, with MBPTA-compliance – through randomisation and deterministic upper bounding – the space of potential execution conditions is automatically, transparently and randomly sampled as the user995 makes more runs. Hence, representativeness just requires the user to perform enough runs to probabilistically capture the impact of the different sources of jitter, rather than the user designing specific experiments to reach that goal [47]. 8. Conclusions and Future Work In this paper we have shown that in order for MBPTA to be usable econom-1000 ically and assuredly, the target processors should be designed such that every program instruction have a distinct probabilistic ETP. We have shown that this ETP can be built incrementally from the timing behaviour of the processor resources used by that instruction. Using MBPTA on MBPTA-friendly processor architectures, the timing in-1005 terference between competing applications, which is one of the key problems in mixed-criticality systems, can be studied from the angle of exceedance probability: the probability that the execution time of a program exceeds a given threshold. We have shown that this threshold is tight, owing to the natural attenuation of multiple worst-case events generated as i.i.d. random variables. We1010 have shown that the probabilistic worst-case execution time bounds obtained with the proposed technique are only marginally greater (around 12% in our case study) than the average-case performance of time-deterministic processor architectures. This allows achieving higher guaranteed (feasible) utilisation for mixed-criticality systems, because little would be lost, if at all, in raw proces-1015 40
sor performance, and a great reduction would be had in the pessimistic overprovisioning incurred with traditional techniques. The use of Extreme Value Theory allows setting bounds for execution-time budgets at levels of exceedance probability that satisfy the system assurance requirements. Normal mitigation measures (i.e. adding some form of redundancy, setting up a safe state, etc.)1020 can be taken if protection guarantees had to be provided for higher-criticality applications at conditions past the given exceedance threshold. Acknowledgment This work has received funding from the European Community’s Seventh Framework Programme [FP7/2007-2013] under grant agreement 611085 (PROX-1025 IMA, www.proxima-project.eu). Support was also provided by the Ministry of Science and Technology of Spain under contract TIN2015-65316-P and the HiPEAC Network of Excellence. Leonidas Kosmidis is funded by the Spanish Ministry of Education under FPU grant AP2010-4208. Jaume Abella has been partially supported by the MINECO under Ramon y Cajal postdoctoral fel-1030 lowship number RYC-2013-14717. The authors wish to acknowledge Michael Houston, Liliana Cucu-Grosjean and Luca Santinelli for contributing to the genesis of this work. References [1] P. Clarke, Automotive chip content growing fast, says gartner,1035 in: http://www.eetimes.com/electronics-news/4207377/Automotive-chip- content-growing-fast, 2011. [2] R. Wilhelm, J. Engblom, A. Ermedahl, N. Holsti, S. Thesing, D. Whalley, G.Bernat, C. Ferdinand, R.Heckmann, T. Mitra, F. Mueller, I. Puaut, P. Puschner, G. Staschulat, P. Stenstr¨oem, The worst-case execution time1040 problem: overview of methods and survey of tools, Transactions on Embedded Computing Systems 7 (3) (2008) 1–53. 41