Full text
Improving Time Predictability of Shared Hardware Resources in Real-time Multicore systems: Emphasis on the Space Domain Javier Jalle Ibarra Computer Architecture Department Universitat Polit`ecnica de Catalunya A thesis submitted for the degree of PhD in Computer Architecture 1st of January, 2016
ii
Improving Time Predictability of Shared Hardware Resources in Real-time Multicore systems: Emphasis on the Space Domain Javier Jalle Ibarra December 2015 Universitat Polit`ecnica de Catalunya Computer Architecture Department Thesis submitted for the degree of Doctor of Philosophy in Computer Architecture Advisor: Francisco J. Cazorla, PhD, Universitat Polit`ecnica de Catalunya Co-advisors: Luca Fossati, PhD, European Space Agency Eduardo Qui˜nones, PhD, Barcelona Supercomputing Center Jaume Abella, PhD, Barcelona Supercomputing Center The work reported in this thesis has been conducted at the Computer Architecture and Operating Systems Interface (CAOS) laboratory of the Barcelona Supercomputing Center (BSC), and has been financially supported by the Network Partnering Initiative (NPI) project 4000102880, between BSC, the European Space Agency (ESA) and Rapita systems Ltd. iii
Dedication This thesis is dedicated to the memory of my grandmother Amparo, which would have enjoyed this moment more than anyone else. I am also grateful to my loving parents that through their continuous support and sacrifice allowed me to get such success. To my partner, Coral, for making me a better person and light up my life. Finally, I must acknowledge as well my sister, family and friends, whose support and company helped me focusing on what is important in life. v
Acknowledgements This thesis is funded by the European Space Agency (ESA) under a Network Partnering Initiative (NPI) (project 4000102880), between ESA, Barcelona Supercomputing Center (BSC) and Rapita systems Ltd. The topic of the NPI project is ”‘Architectural solutions for the timing predictability of next generation multi-processors”’, which aims for easing the adoption of multicores by ESA and ultimately by European real-time industry. This thesis has also received funding from the European Communitys Seventh Framework Programme [FP7/2007-2013] under the PROARTIS (grant agreement 249100), the PROXIMA (grant agreement 611085) and parMERASA (grant agreement no. 287519) projects. Also the Spanish Ministry of Science and Innovation (grant TIN2012-34557), the HiPEAC Network of Excellence and European Space Agency under contracts 4000109680 and 4000110157. I would like to express my deepest gratitude to my advisors Eduardo Qui˜nones, Jaume Abella, Luca Fossati and Francisco J. Cazorla for their endless support and help. I would also like to acknowledge Marco Zulianello and the Microelectronics section from the European Space Agency, Guillem Bernat from Rapita Systems, Jan Andersson from Cobham Gaisler and Tullio Vardanega from University of Padua for their contributions to this thesis. Also thanks to all my colleagues/friends from the Barcelona Supercomputing Center for their help, support and friendship during this research. vii
Abstract Critical Real-Time Embedded Systems (CRTES) follow a verification and validation process on the timing and functional correctness. This process includes the timing analysis that provides Worst-Case Execution Time (WCET) estimates to provide evidence that the execution time of the system, or parts of it, remain within the deadlines. A key design principle for CRTES is the incremental qualification, whereby each software component can be subject to verification and validation independently of any other component, with obvious benefits for cost. At timing level, this requires time composability, such that the timing behavior of a function is not affected by other functions. CRTES are experiencing an unprecedented growth with rising performance demands that have motivated the use of multicore architectures. Multicores can provide the performance required and bring the potential of integrating several software functions onto the same hardware. However, multicore contention in the access to shared hardware resources creates a dependence of the execution time of a task with the rest of the tasks running simultaneously. This dependence threatens time predictability and jeopardizes time composability. In this thesis we analyze and propose hardware solutions to be applied on current multicore designs for CRTES to improve time predictability and time composability, focusing on the on-chip bus and the memory controller. At hardware level, we propose new bus and memory controller designs that control and mitigate contention between different cores and allow to have time composability by design, also in the context of mixed-criticality systems. At analysis level, we propose contention prediction models that factor the impact of contenders and don’t need modifications to the hardware. We also propose a set of Performance Monitoring Counters (PMC) that provide evidence about the contention. We give an special emphasis on the Space domain focusing on the Cobham Gaisler NGMP multicore processor, which is currently assessed by the European Space Agency for its future missions.
CONTENTS xvi
List of Figures 1.1 Basic notions concerning timing analysis of systems. Source: [180]. . 3 1.2 Basic notions concerning probabilistic timing analysis of systems. . 4 2.1 DDRx DRAM memory system. . . . . . . . . . . . . . . . . . . . . 21 3.1 NGMP architecture. Source [42]. ................... 26 3.2 LEON4 structure. Source [43]. .................... 27 3.3 Simulatorstructure........................... 30 3.4 Simulator architecture . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.5 RSK example with loads with4Koffset................ 33 3.6 Instructiontiming............................ 35 3.7 Memory hierarchy timing . . . . . . . . . . . . . . . . . . . . . . . . 36 3.8 Multicore contention with different number of cores . . . . . . . . . 37 3.9 EEMBC and ESA benchmarks accuracy results. . . . . . . . . . . . 38 4.1 AMBA AHB main components: Masters, slaves, arbiter and decoder. (Picture from AMBA Specification Rev 2.0) . . . . . . . . . 43 4.2 AHB transactions consist of an arbitration and a transfer phase. The latter is divided into beats with an address and control phase andadataphase............................. 44 4.3 Example of non time-composable behavior. . . . . . . . . . . . . . . 49 4.4 AHRB extended architecture with HMMODE and HSMODE signals. 58 4.5 Execution times of EEMBC benchmarks against 3 synthetic kernels that continuously access memory and the I/O controller for AHB and AHRB. The percentage indicates the amount of accesses to the I/Ocontroller............................... 61 4.6 Average IPC improvement of AHRB over AHB, for the 3 copies of the synthetic kernel when running in a 4-workload setup with each EEMBC. ................................ 63 4.7 WCET estimates comparison for resAHB and AHRB......... 64 xvii
LIST OF FIGURES 4.8 WCET estimates for AHRB with different master modes (1 and 4) and slave modes (2 and 4). . . . . . . . . . . . . . . . . . . . . . . . 66 5.1 BID figures for a request of core 1 arriving in different cycles under the TDMA setup: w= 16, Nc= 4, s= 4 and r=2 ......... 70 5.2 TDMA and IABA results with w= 16, s= 4, Nc= 4 and r= 2. . . 72 5.3 Memory accesses histogram inside a TDMA for several window sizes 74 5.4 BID for TDMA and IABA with Nc= 4,8 and r= 2,8,16...... 75 5.5 WCET increment when the bus access cycles are known for every request.................................. 78 5.6 WCET increment when the exact bus access cycle is not known. . . 80 5.7 WCET increment for ttsprk with different percentage of information. 81 5.8 Average performance improvement of IABA over TDMA . . . . . . 83 6.1 DCmc architecture. ABSchistands for Intra-Bank Scheduler for bank i. EBS stands for Inter-Bank Scheduler. Grey squares show the blocks that communicates with the OS. . . . . . . . . . . . . . . 95 6.2 Worst-case memory latency, in memory cycles, for tasks under private bank and sharing bank schemes under different control-task count. ..................................100 6.3 Normalized WCET under different mixed-criticality workloads under private and shared banks . . . . . . . . . . . . . . . . . . . . . . 101 6.4 Execution time for the payload benchmark under DCmc running along with real-time tasks with private and shared banks . . . . . . 102 6.5 Normalized WCET under different mixed-criticality workloads under private and shared banks. EEMBC Autobench. . . . . . . . . . 103 7.1 Original and proposed 64-bit memory-down system . . . . . . . . . 111 7.2 Equivalent transfers. . . . . . . . . . . . . . . . . . . . . . . . . . . 112 7.3 Normalized WCET for shared-bank, private-bank, private-channel andPDSC. ...............................115 7.4 Normalized Average Execution Time (AET). . . . . . . . . . . . . . 116 7.5 PDSC scalability results. . . . . . . . . . . . . . . . . . . . . . . . . 117 8.1 Block diagram of the PTA-compliant core architecture used in [110]. 125 8.2 Baseline multicore architecture considered in this chapter. ‘c’ stands for core, ‘s’ for switch and ‘mc’ for memory controller. . . . . . . . . 127 8.3 Probability of not being granted access as a function of the number of arbitration rounds for a bus with 4 cores. . . . . . . . . . . . . . 130 8.4 Measured execution times vs. ETPs. . . . . . . . . . . . . . . . . . 139 8.5 pWCET estimates for canrdr under different multicore setups. . . . 141 xviii
LIST OF FIGURES 8.6 pWCET reduction when using randomized permutation arbitration in the buses and in the memory controller with respect to using lottery and deterministic arbitration respectively. . . . . . . . . . . 144 8.7 Guaranteed IPC (Instructions Per Cycle) scalability . . . . . . . . . 144 9.1 Synthetic CCS for a given Task1 on a quad-core. Note that we usually represent the CCS vertically, though for space constraints this figure presents it horizontally. ..........................150 9.2 CCS module and input/output signals. . . . . . . . . . . . . . . . . 156 9.3 Simplified AMBA arbitration process. . . . . . . . . . . . . . . . . . 158 9.4 AMBA Signals and CCSm. . . . . . . . . . . . . . . . . . . . . . . . 159 9.5 EEMBC with different contention workloads. . . . . . . . . . . . . . 162 9.6 cacheb EEMBC in different workloads. . . . . . . . . . . . . . . . . 163 9.7 r-bsk under analysis against different bus contenders. . . . . . . . . 164 9.8 w-bsk under analysis against different bus contenders. . . . . . . . . 165 10.1 Execution time and ETB of l2h benchmark in different workloads . 179 10.2 ETB for each bus prediction model: UBD (fully time composable requests); And our approach with 1 and 4 request types. . . . . . . 183 10.3 ETBs for EEMBC when assuming a no cache misses. . . . . . . . . 184 10.4 ETBs for EEMBC under the optimistic, pessimistic and accurate scenarios. ................................186 xix
LIST OF FIGURES xx
List of Tables 1.1 Space software criticalities classification [58] ............. 9 2.1 Taxonomy of timing analysis techniques. Taken from [3] ...... 15 3.1 Benchmarks used in this thesis . . . . . . . . . . . . . . . . . . . . 28 4.1 List of AHB features analyzed . . . . . . . . . . . . . . . . . . . . . 46 4.2 ttran(0)-ttran(1)-ttran(2)-ttran(3)/tarb(0) under different master and slave modes in a 4-master configuration. tarb(0) is for master 0 and ttran(i) for master i............................ 56 4.3 WCET (in milliseconds) for three tasks under several mm/sm ...... 57 5.1 Arrival times of a bus request . . . . . . . . . . . . . . . . . . . . . 71 5.2 Summary of the properties of TDMA and IABA . . . . . . . . . . . 84 6.1 Worst-case access latencies for a DDR2-667 device (memory cycles). 99 6.2 List of memory controllers. RT stands for real time and HP for high performance. ..............................105 8.1 Independence and identical distribution tests results (outcome independence test / outcome i.d test). . . . . . . . . . . . . . . . . . . 140 8.2 pWCET estimate for 10−15 for each EEMBC under all setups w.r.t their pWCET estimate in single-core. . . . . . . . . . . . . . . . . . 142 9.1 Analysis of whether each processor contains PMC in each of the categories identified in our taxonomy (Detailed description provided in Section 9.6). .............................152 xxi
LIST OF TABLES xxii
Chapter 1 Introduction 1.1 Critical Real Time Embedded Systems Real-time Embedded Systems (RTES) are computing systems with a specifically designed function whose correctness does not only rely on their functional correctness but also on their timing correctness. RTES have to meet the timing restrictions on the execution time of the system, which are typically represented with a deadline. RTES are ubiquitous nowadays and can be found embedded in music players, TVs, cars, airplanes, satellites, spacecrafts (among others). These systems interact with the physical world, where time is a central property of systems, responsible of the evolution of its state and dynamics. Inside RTES, we can differentiate an specific branch of systems called Critical Real-Time Embedded Systems (CRTES) [116]. In this context, criticality relates to safety, security, mission or business aspects of the system. For instance, a failure or disruption in a mission critical system will cause a failure to accomplish the mission or goal of the system. Likewise, the consequences of a failure in a safety critical system involve human injury, environmental harm, or loss or severe damage to equipment/property. As an example, the guidance and navigation control from a spacecraft, which is in charge of the correct position and orbit of the spacecraft, involves critical failures if a deadline is missed, since a wrong position or orbit means the complete loss of the spacecraft, due to loss of power (not pointing to the sun for solar powered spacecrafts) or communication (antennas are directional and have to be properly oriented). Other types of CRTES can be found in avionics, space and automotive systems, among others, such as the brake system in a car or the flight control in an airplane. CRTES have stringent constraints in terms of size, weight, cost and power consumption, as many embedded systems, but also need to ensure timing correctness in addition to functional correctness. To do so, CRTES follow a verification and validation [3] process that provides a high level of assurance on the functional and 1
Chapter 1. Introduction timing correctness. The verification and validation process is specific to each domain, usually specified in safety-related standards, such as the ISO26262 [91] in automotive, DO-178B [152] in avionics or ECSS-E/Q-40 [57,56] in space. Verification is the process used to check that the requirements of a system are satisfied, which can be classified into functional verification and timing verification. The former checks that the system is functionally correct while the latter verifies that timing constraints are met. Validation checks that the system performs what it purports. 1.2 Timing aspects of CRTES To guarantee the timing correctness of CRTES, evidence has to be provided that tasks1do not overrun their deadlines. However, this is not an easy task since most programming models used on CRTES, such as C or Ada, do not have the notion of time [119]. As a result, assigning an execution time to a certain piece of code is not trivial and depends on many factors, such as programming language, compiler and ultimately depends on the underlying hardware architecture. For instance, a piece of code with different execution paths, such as those generated by control-flow (branch) instructions, may have different execution times depending on the input data of the software, which modifies the branch condition. On the other hand, there is a certain variation of the execution time of processor instructions depending on the input data and the execution history due to the fact that the hardware is not a stateless resource. For instance, the latency of a division in some hardware implementations depends on the input data (e.g., if the dividend is zero the result is delivered quickly) and also most cache memory designs completely depend on the execution history, which is exactly what they benefit from to obtain performance gains by exploiting temporal and spatial locality. As a result, the execution time of a task is not a fixed value but rather a complex distribution as seen on Figure 1.1. For that purpose, most systems use the Worst-Case Execution Time (WCET)2as an abstraction of the worst timing behavior of a task that reduces the complexity of providing evidence about the execution time. The WCET, or more precisely a bound to it (as discussed below) is computed for each software unit. This estimate is passed as input to the scheduler, which prioritizes the order of execution of the different software modules with the goal of asserting that from a timing perspective, the system behaves as expected, with no deadline misses. A summary of scheduling approaches, and the corresponding schedulability analy- 1In this thesis we use the terms task and application interchangeably. They both represent stand-alone software components able to run independently on a processor. 2Same for the Best Case Execution Time (BCET), although in this thesis we focus on the WCET. 2
1.2 Timing aspects of CRTES Figure 1.1: Basic notions concerning timing analysis of systems. Source: [180]. sis techniques, are discussed in [28,48]. Thus, the WCET must be computed to guarantee that task’s functionality finishes within its corresponding deadline. However, the exact WCET is very difficult or even unfeasible to obtain at all [180], because the test space is too big to be covered with all possible input sets and/or the system might not be completely predictable. The ability to derive WCET estimates requires time predictability, which stands for the property of being able to bound the execution time of a task or a component, so that none of the possible execution times, exceeds the bound. When the exact bound cannot be computed, some abstractions are made by the tool or method to be able to have a time predictable system or component, usually overestimating it by introducing pessimism. The amount of pessimism depends on the methods used and the hardware characteristics. For instance, if we consider a cache memory, a possible abstraction that makes the cache time predictable is to consider all accesses as cache misses. In that case, the obtained WCET bound is never exceeded because of the cache effect and we avoid the struggle of knowing the execution history. However, the pessimism introduced can be too high to be useful since we are completely removing the performance gains of cache memories in the worst-case. A better solution might be to lock the cache contents and consider each request as a hit or a miss depending on the address and not on the execution history [168]. Deriving WCET estimates is a known challenge, for which different methods have been proposed. These methods can be classified into Deterministic Timing Analysis (DTA) and Probabilistic Timing Analysis (PTA) [2]. DTA techniques assume that under the same input data and initial state a piece of software running on a processor has a defined execution time. Therefore, DTA derives a single bound for the execution time of each piece of software running on a processor. 3
Chapter 1. Introduction lack of availability of flight models. Nevertheless, ESA is on a unique position, with respect to real-time systems, because it is able to influence the design of future multicore processors derived from the NGMP family. 1.4 Thesis contributions This thesis proposes hardware designs to improve the timing predictability of shared resources in multicore processors in order to ease their adoption by the CRTES industry. This thesis covers solutions for both, deterministic and probabilistic timing analysis techniques. Proposed designs deliver both high average performance and low WCET estimates, thus increasing the number of functions that a single system can provide. Time composability is maintained by all of our proposals, in the sense that the WCET estimation computed for a task in isolation is not affected by the rest of the tasks running on the system simultaneously. The approach followed in this thesis is to bound or reduce the interference (contention) that appears when several cores try to access the same shared resource. This interference must have a guaranteed maximum impact in order to allow deriving WCET estimates. We note that the real-time industry has just started using small multicores with few cores, e.g. the Cobham Gaisler NGMP [42] architecture is four-core, the Infineon AURIX architecture [84] comprises 3 cores and the Freescale P4080 [70] 8 cores. For these core counts, the main shared resources are i) the interconnect that connects the core to ii) the shared cache hierarchy and finally the iii) memory controller that acts as an interface between the processor and the off-chip memory. On-chip buses suffice to provide the bandwidth needed in those architectures and provide more efficiency and simplicity than other interconnects for a low number of cores. Also several studies show that hierarchical bus configurations scale quite easily to large systems and provide a good areaperformance trade-off, while retaining many of the advantageous features of simpler bus arrangements [156] and that bus-based networks can significantly lower energy consumption and simplify network protocol design and verification, with no loss in performance [166]. Shared caches pose significant challenges for realtime systems, since running tasks can cause the eviction of cache lines owned by different tasks. To remove this effect partition mechanisms exist, either hardware [138,105] or software [122,131,103,172], that remove the cache interference. In this thesis, we focus on processors that have partitioning mechanisms to remove the interference on the shared caches. Current CRTES manage large working sets which requires the use of off-chip memories such as DDR2 and DDR3 [92] memories. The memory bandwidth, which is arbitrated by the memory controller, is one of the shared resources with the highest impact on systems’ performance and 10
1.4 Thesis contributions predictability [139,183]. This thesis focuses on two of the most critical shared resources in multicore processors: the interconnection bus [31] and the memory controller [139,183]. We use the NGMP processor as reference architecture, acknowledged as one of the multicores that can be used by the ESA. Nevertheless, most solutions can be applied to other processors and domains, like the Infineon AURIX [84] in automotive or the Freescale P4080 [70] in avionics. In this thesis, the impact of scheduling aspects is not considered and does not affect our solutions, in the sense that our solutions are transparent to them, enabling the time-composable WCET estimates, which are the input for scheduling algorithms. More concretely: •On-chip buses: –We analyze a specific implementation of a bus architecture, the AMBA bus, which is one of the most widely used on-chip bus interfaces in embedded processors and provide a classification of its features in terms of time predictability. We define a new bus based on AMBA which is time composable by construction, which greatly simplifies timing analysis. –We analyze and derive analytical models for the most relevant on-chip bus arbitration policies for real-time systems to be able to compare them in terms of time predictability and time composability. •Memory controller: –In the context of mixed-criticality systems, predictable latencies and high bandwidth must be satisfied for different tasks at the same time. We propose a memory controller that can satisfy both requirements. –We propose a novel contention free memory controller solution able to simplify timing analysis and reduce pessimism on WCET estimates introduced by memory accesses. •Probabilistic Timing Analysis in multicores: –We enable the use of PTA in multicore systems: In particular, we define probabilistically-analysable bus and memory controller designs for multicore processors, show their suitability for PTA and evaluate their hardware cost. •Performance Monitoring Counters 11
Chapter 1. Introduction –We propose a new set of Performance Monitoring Counters (PMC) aiming to measure the actual contention in shared resources. These PMCs provide evidence and allow to verify and test the outcome of the timing analysis. –For systems in which hardware cannot be modified, we propose an interference prediction model based on PMC. As a proof of concept, all the architectural solutions studied and proposed are tested on a space case-study consisting on a cycle-accurate simulation framework validated against a real implementation of the NGMP [41] processor and representative software of the ESA. The results will be used by the ESA to influence the future design of the NGMP processor. 1.5 Thesis structure This Thesis is structured as follows: •Chapter 2covers the background and state-of-the-art needed for this thesis. •Chapter 3explains the methodology followed in this thesis. •Chapters 4and 5cover the on-chip buses. More concretely: –Chapter 4proposes an on-chip bus architecture that is time composable by design. –Chapter 5analyzes bus arbitration policies that are appealing for realtime systems. •Chapters 6and 7cover the memory controller. More concretely: –Chapter 6proposes a dual-criticality memory controller. –Chapter 7proposes a contention-free memory organization. •Chapter 8enables the use of PTA in multicores by evaluating and proposing new arbitration policies for the bus and memory controller. •Chapters 9and 10 improve the timing analysis of multicore processor. More concretely: –Chapter 9proposes a new set of Performance Monitoring Counters that provide evidence about the contention. –Chapter 10 proposes a contention prediction model that factors the impact of contention in the timing analysis. 12
1.6 List of publications 1.6 List of publications 1. J. Jalle, M. Fernndez, J. Abella, J. Andersson, M. Patte, L. Fossati, M. Zulianello and F. J. Cazorla. “Contention-Aware Performance Monitoring Counter Support for real-time MPSoCs” (Chapter 9), 2016 IEEE Symposium on Industrial Embedded Systems (SIES). May 2016. 2. J. Jalle, E. Quiones, J. Abella, L. Fossati, M. Zulianello and F. J. Cazorla. “Bus Slicing for Contention-Free Multicore Real-Time Memory Systems” (Chapter 7), 2016 IEEE Symposium on Industrial Embedded Systems (SIES). May 2016. 3. J. Jalle, J. Abella, L. Fossati, M. Zulianello and F. J. Cazorla. “Validating a Timing Simulators for the NGMP Multicore Processor” (Chapter 3), Data Systems In Aerospace (DASIA), May 2016. 4. J. Jalle, M. Fernndez, J. Abella, J. Andersson, M. Patte, L. Fossati, M. Zulianello and F. J. Cazorla. “Bounding Resource-Contention Interference in the Next-Generation Multipurpose Processor (NGMP)” (Chapter 10), Embedded Real Time Software and Systems (ERTS2), January 2016. 5. J. Jalle, E. Quinones, J. Abella, L. Fossati, M. Zulianello and F. J. Cazorla. “A Dual-Criticality Memory Controller (DCmc): Proposal and Evaluation for a Space Case Study” (Chapter 6), IEEE Real-Time Systems Symposium (RTSS), December, 2014 6. J. Jalle, L. Kosmidis, J. Abella, E. Quiones and F. J. Cazorla, “Bus designs for time-probabilistic multicore processors” (Chapter 8), Design, Automation and Test in Europe Conference and Exhibition (DATE), March 2014. 7. J. Jalle, J. Abella, E. Quiones, L. Fossati, M. Zulianello and F. J. Cazorla. “AHRB: A High-Performance Time-Composable AMBA AHB Bus” (Chapter 4), Real-time and embedded Technology and Applications Symposium (RTAS), April 2014. 8. J. Jalle, J. Abella, E. Quiones, L. Fossati, M. Zulianello and F. J. Cazorla. “Deconstructing Bus Access Control Policies for Real-Time Multicores” (Chapter 5), 2013 IEEE Symposium on Industrial Embedded Systems (SIES). June 2013. 9. J. Jalle, E. Quiones, J. Abella, L. Fossati, M. Zulianello and F. J. Cazorla. “Contention-Free Multicore Real-Time Memory System by Data Bus Splitting and Command Bus Sharing” (Chapter 7), Work-in-progress Poster in Design Automation Conference (DAC), June 2015. 13
Chapter 1. Introduction 10. J. Jalle, E. Quiones, L. Fossati, M. Zulianello, F. J. Cazorla. “Threats to Time Predictability on AMBA Bus” (Chapter 4), ACACES 2012, Poster Abstracts. 8th International Summer School on Advanced Computer Architecture and Compilation for Embedded Systems (ACACES). Fiuggi (Italy), July 2012. Collaborations 11. G. Fernandez, J. Jalle, E. Quinones, J. Abella, T. Vardanega and F. J. Cazorla. “Resource Usage Templates and Signatures for COTS Multicore Processors” Design Automation Conference (DAC), June 2015. 12. G. Fernandez, J. Jalle, E. Quinones, J. Abella, T. Vardanega and F. J. Cazorla. “Increasing Confidence on Measurement-Based Contention Bounds for Real-Time Round-Robin Buses”, Design Automation Conference (DAC), June 2015. 13. D. Trilla, J. Jalle, M. Fernandez, J. Abella and F. J. Cazorla. “Improving Early Design Stage Timing Modeling in Multicore Based Real-Time Systems”, to Real-time and embedded Technology and Applications Symposium (RTAS), April 2016. 14
Chapter 2 Background and State-of-the-Art This chapter provides the background and state-of-the-art on timing analysis techniques we build upon, and on the existing hardware solutions to enable timing analysis of multicore designs. 2.1 Timing Analysis As mentioned before in this document, two main approaches are currently being followed [3] to derive WCET estimates: Deterministic Timing Analysis (DTA) [180] or Probabilistic Timing Analysis (PTA) [4] techniques. DTA derives a single WCET for each piece of software [180] and PTA generates a distribution function, or pWCET function, that guarantees that the execution time of a program only exceeds the corresponding pWCET bound with a probability lower than a given target probability (e.g., 10−15 per run) [32]. Both, DTA and PTA, can be applied in a static or measurement-based manner. In an intent to benefit from both, hybrid approaches try to combine static with measurement-based techniques. A summary of the different timing analysis methods is shown in Table 2.1 [3]. Technique Deterministic Probabilistic Static SDTA SPTA Measurement-based MBDTA MBPTA Hybrid HYDTA HYPTA Table 2.1: Taxonomy of timing analysis techniques. Taken from [3] 15
Chapter 2. Background and State-of-the-Art 2.1.1 Deterministic Timing Analysis DTA is a well-known and studied timing analysis technique, with consolidated commercial and academic research tools. DTA techniques can be classified in Static Deterministic Timing Analysis (SDTA), Measurement-based Timing Analysis (MBDTA) and Hybrid Deterministic Timing Analysis (HYDTA) [3]. SDTA relies on the construction of a cycle-accurate model of the system under test (not limited to the CPU), what we call hardware-model, and the construction of a mathematical representation of the machine code timing behaviour on that model, called flow-facts, that take care of loop bounds, infeasible paths and annotations. These mathematical representations are then processed with linear programming techniques to determine a safe upper-bound on the execution time. The main advantage of SDTA is that the application of provably mathematical techniques gives a strong emphasis to the soundness and safeness of SDTA [180], which allow in principle to meet all the requirements set by the highest criticality standards. However, the validity of the bounds depends on the correctness of the abstract models. Hardware models are difficult to develop and test, specially because of the lack of information about the processor implementation provided by the manufacturer, which is usually scarce and not accurate [179]. Even if the chip vendor explicitly provides this information in the manuals, documentation can be inaccurate or outdated with respect to the deployed chip implementation [3]. For instance, the FreeScale e500mc core documentation has already reached the third revision with details about non-negligible changes across revisions [72]. This forces SDTA to make assumptions, affecting the accuracy of the estimates and usually including more pessimism on them. All these difficulties have made that real-time industry and SDTA tool providers use measurement-based approaches to derive contention bounds [135]. On the other hand, flow-facts grow linearly/exponentially with code size and adding annotations is an error-prone process [3]. Only simple software running on top of simple and consolidated hardware designs have accurate abstract hardware models that can be subject to SDTA [3]. Examples of deterministic SDTA tools are aiT [60] and OTAWA [19]. MBDTA is based on executing the program on the real platform with different input sets and collecting measurements, which are later operated in order to derive WCET estimates. For instance, the outcome of recording the longest observed execution time and applying an engineering margin can be used as a WCET estimate. The advantage of MBDTA is that it does not require as much information as SDTA does which is why industry often relies on MBDTA [3]. In fact software/hardware testing always implies executing on the real platform even for functional testing, so measurements are always collected on the actual system to gain confidence. However, the main drawback of MBDTA is that its trustwor- 16
2.1 Timing Analysis thiness depends on factors such as the test conditions and input set, which cannot guarantee that they trigger the worst-case scenario, since it is usually not known and cannot be found due to the large input set space. An example of research on MBDTA techniques is shown in [177]. Hybrid approaches try to improve the confidence of measurements by combining it with static information that gives control flow and coverage information for unobserved execution paths. An example of a hybrid tool is Rapita Verification Suite [147], which is the one used in this thesis. RapiTime [146] uses path analysis techniques to build up a precise model of the overall code structure and determine which combinations of subpaths form complete and feasible paths through the code. RapiTime combines the measurement and control flow analysis information to compute measurement based WCET estimates in a way that captures the execution time variation on individual paths. 2.1.2 Probabilistic Timing Analysis PTA generates a distribution function, or pWCET function, that upper-bounds the execution time of the program under analysis, guaranteeing that the execution time of a program only exceeds the corresponding execution time bound with a probability lower than a given target probability (e.g., 10−15 per run). PTA can be applied either on a Static manner (SPTA) [32] or Measurement-Based (MBPTA) [46]. PTA requires that the events under analysis, program execution times for MBPTA or instruction latencies for SPTA, can be modeled with independent and identically distributed (i.i.d.) random variables1. Each PTA technique has its own methods to combine results from different execution paths. We refer the reader to those methods for further details [32] [46]. SPTA uses very simple processor models, not suitable for more realistic processor designs [129][9]. In this thesis we focus on MBPTA as it is closer to industrial practice, and obtained pWCET estimates have shown to be competitive with the estimates obtained with other timing analysis techniques [175][174]. MBPTA derives probabilities by collecting execution time observations of end-to-end runs of an application running on the target hardware. The observed execution times fulfil the i.i.d. properties if observations are independent across different runs and a probability can be attached to each potential execution time. Hence, taking measurements from a program is equivalent to rolling a dice, with each face having a probability of appearance. Making enough rolls is enough to apply MBPTA, which derives upper-bounds of the execution time distribution by means of the Extreme 1Two random variables are said to be independent if they describe two events such that the occurrence of one event does not have any impact on the occurrence of the other event. Two random variables are said to be identically distributed if they have the same probability distribution function. 17
Chapter 2. Background and State-of-the-Art Value Theory (EVT) [115,46]. The path coverage of MBPTA can be improved with techniques such as the ones proposed in [111,190]. Conventional hardware/software platforms fail to provide the features required by PTA so that pWCET estimates can be computed. PTA has been shown implementable for single-core processors, either by using random-placement and random-replacement [110] caches or by using software randomisation that changes memory allocation at runtime [112] or by using different compiled binaries [113]. Also PTA works with multilevel caches [109], buffer resources [114], shared caches [163] and faulty caches [162]. Solutions for single-core architectures show how processor cores with a similar processor architecture to the LEON3 and LEON4 [81] can be easily adapted to achieve PTA requirements. In particular, limited modifications are required in the cache placement and replacement [110] policies to make them PTA-compliant. PTA has emerged as a recent alternative to DTA, still some further steps are required before PTA can be used on real products [3]. To the best of our knowledge, no multicore PTA compliant architecture has been presented so far. In this thesis we propose and evaluate multicore architectures that fulfil PTA requirements. 2.2 Multicores Providing a meaningful timing analysis in multicores is difficult [106,128,3] due to contention on access to hardware shared resources [65]. A taxonomy of different works on the subject can be found in [62]. A possibility to deal with contention is to consider all possible interactions of any task in the workload when analyzing a task, which is called joint analysis. For instance, in [184,121,188,78] authors analyze all the possible effects a task may have onto another one in a shared cache. In [33] they integrate the shared cache and shared bus timing analysis with other architectural features like the pipeline or branch prediction. In reality, this type of analysis is complex and requires knowledge of the tasks running on the system, which breaks the time composability property and increases the complexity of the analysis [134]. Other solutions propose changes to the hardware that simplify the timing analysis, for instance [138] uses Round-Robin and [151] TDMA for managing shared resources. Based on the method in [138], authors in [159] use hardware support to artificially delay each request when measuring the WCET. The COMPSoC [77] multiprocessor achieves predictable and composable latencies by using TDMA arbitration and avoiding cache memories. PRET [123] architecture uses scratchpad cache memories and TDMA based memory scheduling [148] to achieve a predictable multicore processor. Also the time-triggered architecture [107] provides a predictable a composable hardware by making use of a time-triggered schedule, 18
2.2 Multicores similar to TDMA, and global synchronization. Existing solutions using Commercial-of-the-shelf (COTS) multicore processors assume the worst-case impact of contention [138], for instance in [135] they propose a method to compute an interference sensitive WCET and monitor its safeness at runtime on top of a COTS processor. Also in [63] and [102] the contention of a COTS multicore is bounded for the bus and the memory respectively. A methodology that replaces tasks with kernels that mimic their shared resource usage is used in [21] as a way to reduce the variability and improve measurementbased analysis. Authors in [64] abstract the contention tasks cause and suffer using signature and templates that allow bounding the contention [63] suffered by a task from its contenders. Finally, is it worth mentioning cache partitioning, either by software [122, 103,172,131,34] or hardware [105,138], is a common solution in the context of CRTES [29] due to the complexity of estimating WCET accurately on top of shared caches. Nevertheless, shared caches can be found in different contexts such as probabilistically analysable systems [163], static deterministic timing analysis [33], measurement-based techniques on top of COTS processors [61] and the joint analysis examples cited above. In this thesis we focus on hardware solutions that simplify the timing analysis for multicore processors with shared caches partitioned by hardware. In particular, this thesis focuses on providing solutions for the two following components: bus and memory controller. 2.2.1 On-chip buses Buses in real-time systems are used for off-chip and on-chip communication. Examples of off-chip buses are CAN [90] and FlexRay [66] used in automotive, Spacewire [55] used in space or the Time-Triggered Architecture [108]. Those buses are designed to connect different processing units and peripherals. Offchip bus contention can be handled with TDMA buses [158] assuming the worst possible alignment of the task requests with their TDMA slots or with dynamic arbiters [157] that consider the particular pattern of accesses of each task to the bus [50]. Transactions on those buses are visible to the software, which enables scheduling the requests of the different running tasks so that interferences in the use of the bus can be avoided. This thesis focuses on on-chip buses, which are used at much lower granularity than off-chip buses. For instance an on-chip bus is used to communicate cores and the L2 cache in the NGMP processor [42]. At this granularity, the requests (e.g., L2 cache accesses) of the different tasks cannot be efficiently scheduled to prevent interferences. The responsibility to handle interferences is left to the hardware, in this case to the arbiter of the on-chip bus. 19
Chapter 3. Methodology Figure 3.1: NGMP architecture. Source [42]. AHB Processor Bus: The 128 bit AMBA AHB bus [14] connects the LEON4 cores to the L2 cache and the I/O bridges. The first consideration to make in the case of the bus is that there are different types of requests that have different behavior: bus reads (loads) that either hit (l2h) or miss (l2m) on the L2 cache and bus writes (stores) that either hit (s2h) or miss (s2m) on the L2 cache. These accesses behave differently because hits hold the bus while they are served. Instead, misses wait on a miss queue and are split, i.e. the L2 cache releases the bus while processing the miss, so that other cores can use the bus. Also writes are immediately responded by the L2 cache, that keeps them in a queue until they are processed. In the NGMP, the AMBA AHB bus implements round-robin arbitration. L2 cache: The 256 KiB, 4-way, write-back second-level cache is shared across the four LEON4 cores. In this thesis we use the master-index feature of the NGMP that partitions the L2 assigning one L2 cache way to each core. Hence, a given core suffers no contention interference in the L2 due to other cores’ evictions. Each of the request types identified before (l2h,l2m,s2h and s2m) has its own L2 access latency. Interestingly, the latency of requests of the same type can be variable. That is, for each request type access there is jitter, which is caused by the previous requests, despite they might belong to a different task and hence go to a different cache partition. Memory Controller The memory controller acts as an interface between the processor and the DRAM memory and can be modelled as a FIFO queue that uses a close-page policy to access the memory. We differentiate two types of request in the memory: read and write. According to the DRAM protocol, each 26
3.2 Benchmarks Figure 3.2: LEON4 structure. Source [43]. request has a different latency to be responded depending on whether it is a read or write request respectively. The off-chip memory used is DDR2 [96] memory. 3.1.1 NGMP implementations We use two different processor boards, the commercially available GRN2X [41] and a FPGA prototype of the GR740 [39] which was provided directly by the designer company. These boards have two different uses, the most important one is to provide a reference model for the validation of the simulation platform, as it is explained on Section 3.3.1. The second one is to test and account contention as shown in Chapters 9and 10. To use the boards, the GRMON2 [37] commercial debug tool is used to interface with the boards and obtain the measurements from the available Performance Monitoring Counters (PMC). 3.2 Benchmarks We use three families of benchmarks: representative for the real-time community: EEMBC [143], real space applications obtained from the ESA and microbenchmark or synthetic kernels that are designed to stress certain behaviors on the processor. The individual benchmarks are described in Table 3.1. 27
Chapter 3. Methodology 3.2.1 EEMBC automotive benchmark The EEMBC automotive benchmark suite is a well-known benchmark suite for CRTES in the automotive domain, and it is particularly useful for evaluating the capabilities of embedded microprocessors, compilers, and the associated embedded system implementations. Experiments shown in [143] illustrate the diversity of the EEMBC benchmark suite as well as the specifics of each workload’s activity. This diversity ensures that designers can use combinations of EEMBC workloads to represent most real-world workloads and use this characterization data as a starting point to make effective design choices. Table 3.1: Benchmarks used in this thesis EEMBC Autobench a2time Angle to Time Conversion basefp Basic Integer and Floating Point bitmnp Bit Manipulation cacheb Cache ”Buster” canrdr CAN Remote Data Request aifft Fast Fourier Transform (FFT) aifirf Finite Impulse Response (FIR) Filter aiifft Inverse Fast Fourier Transform (iFFT) aiirflt Infinite Impulse Response (IIR) Filter matrix Matrix Arithmetic pntrch Pointer Chasing puwmod Pulse Width Modulation (PWM) rspeed Road Speed Calculation tblook Table Lookup and Interpolation ttsprk Tooth to Spark Space applications obdp Near infrared HAWAII-2RG detector algorithm aocs Attitude and Orbit Control System (AOCS) from the EagleEye project debie DEBIE instrument control software from PROBA-1 satellite vega Thruster vector control of the Vega launcher Microbenchmarks rsk Synthethic kernels to trigger different processor behaviors 3.2.2 ESA real applications As real applications we use some software provided by the ESA. As payload applications we use the On-board Data Processing (OBDP) and DEBIE benchmark. OBDP contains the algorithms used to process raw frames coming from the state- of-the-art near infrared (NIR) HAWAII-2RG detector [97], already used on real 28
3.3 Simulator projects, like the Hubble Space Telescope to detect cosmic rays. DEBIE is the software that controls an instrument, which was carried on PROBA-1 satellite, to observe micro-meteoroids and small space debris by detecting impacts on its sensors, both mechanically and electrically. As control application we use the Attitude and Orbit Control System (AOCS) from the EagleEye project [23] and the thruster vector control of the Vega launcher (VEGA). The AOCS contains the Guidance and Navigation Control system from the spacecraft in charge of the correct position and orbit of the spacecraft. It is one of the most critical systems of a spacecraft, since a wrong position or orbit could mean the complete loss of the spacecraft, due to loss of power (not pointing to the sun for solar powered spacecrafts) or communication (antennas are directional and have to be properly oriented). 3.2.3 Microbenchmarks We use microbenchmarks or Resource-Stressing Kernels (RSK) [144][31] comprising a single loop with instructions of the same type that are chosen to stress a certain resource: either an instruction or a hardware resource. The reason to use a loop is to avoid icache misses and exercise the latency or certain behaviors in the processors long enough to be able to minimize the overhead of instrumenting and measuring the execution time. Each loop iteration will contain Ninstructions. RSKs are designed to reduce the overhead to a minimum by developing them in assembly code and compiling for bare-metal execution, which means that no OS is present. 3.3 Simulator We build a model of the NGMP simulator upon the SoCLib [164] simulation environment, which we properly modify to resemble the NGMP processor. The purpose of the simulator is to have a cycle accurate simulator environment, in order to correctly measure the execution cycles. However, our goal is not to model all the complexity of the processor, because there is a tradeoff between complexity (or simulation time) and accuracy. In case some accuracy has to be traded off for a more simple model, simplicity is achieved by modelling the most common case. The simulator is conceptually designed to separate the functional part from the timing behavior, which creates two different design spaces: (1) the functional emulator (emulator from now on) and (2) the timing simulator. The simulator structure is shown in Figure 3.3. The emulator part executes the instructions according to a particular Instruction Set Architecture (ISA) and provides all the information about an instruction like the instruction address, registers, type, re- 29
Chapter 3. Methodology Figure 3.3: Simulator structure sults and memory address in case it is a memory operation. The timing simulator (simulator from now on) simulates the timing behavior of the instruction for a given hardware implementation, for instance, if it is a cache hit or miss and the delay introduced by the bus access in case it has to reach a higher level cache or the memory. The architecture of the simulator serves two purposes: 1) to resemble the actual processor structure which helps to have a more accurate modeling of its behavior and 2) to ease implementation of new hardware features such as bigger caches. The simulator architecture, as shown in Figure 3.4a, consists of 4 cores with their respective private caches, connected through a bus to a shared L2 cache and the shared memory. All the caches are configured to resemble the caches in the NGMP. The bus behaves as a 128-bit, round-robin AMBA AHB bus. DRAM- sim2 [171] is used for the memory, which is a well known C-based memory system simulator developed by the University of Maryland. It is highly configurable, parameterisable and implements detailed timing models for different types of existing DRAM memory systems. With DRAMsim2 we model the memory controller and a 2-GB one-rank DDR2-667 [104] with 4 banks, burst of 4 transfers and a 64-bit memory data bus, which provides 32 bytes per access, i.e. a cache line, as in the real processor setup used along this thesis. The internal structure of the core is depicted in Figure 3.4b, which comprises the 7-stage pipeline with private caches and a write-buffer. Both pipelines, integer and floating point, are embedded in the execution stage, that assigns latencies to instructions. The timing of an instruction consists of the instruction latency, that is defined by the pipeline, and the memory hierarchy latency for the instruction access and data access, in case of load and store operations. The memory hierarchy latency includes a third contributor, the multicore contention, which involves the effect that the rest of the cores can have on the timing of the core being analyzed, such as waiting for the bus because it is being used by another core. 30
3.3 Simulator (a) Multicore architecture (b) Single core details Figure 3.4: Simulator architecture 3.3.1 Validation Methodology Our validation methodology is based on microbenchmarks or RSK (see Section 3.2.3) with a tow-fold objective: Providing confidence on the fact that the timing simulator is accurate by comparing their execution time on the simulator and the real board, and if the execution time is different, it helps adjusting the timing parameters of the simulator to improve accuracy for the specific components used by the microbenchmark. General RSK. Each RSK comprises a single loop with instructions of the same type that are chosen to stress a certain hardware resource or a set of them. The first step is factoring out the execution time of the loop overhead in both, the timing simulator and the real board1. This overhead is removed from all the execution time readings to obtain the exact latency of the operations performed in the loop body. The latency of the body helps tuning the latencies of the different parts of the processor with very high accuracy. The loop overhead is measured with a loop containing only the loop-related instructions, which include roughly an arithmetic instruction to compute the loop index and a branch instruction, and also possibly a comparison instruction in other ISA. The latencies of these instructions can be obtained from the datasheets, if available. Otherwise, they can be derived empirically. For that purpose, we use a loop containing Ntimes the instruction whose latency is to be measured, that is programmed in a way that IL1 misses can only occur in the first loop iteration, i.e. the loop fits in the 1When we talk about real board, a RTL level cycle-accurate simulation could also be used. 31
Chapter 3. Methodology IL1. This way we can approximate the latency of the instruction analyzed very accurately, since the overhead of the loop is minimized. Once each instruction latency is obtained we can set up the simulator with the appropriate latency for each instruction type. In terms of implementation, we proceed as follows. Instruction timing. We (automatically) create a set of RSK, each one having a different instruction type under analysis in the loop. All instructions are forced to incur cache hits in order not to include the memory hierarchy latency on the execution time. First, we measure the execution time of the empty-loop RSK. This execution time needs to be substracted from the execution time of any of the RSK that we produce to analyze any instruction. Then, the execution time difference between the specific RSK and the empty-loop RSK is divided by N·M, where Nis the number of instances of the instruction under study in the loop and Mthe number of iterations carried out. In order to validate the behavior of each instruction type, as we will see in the results Section 3.3.2, the execution time of the loop obtained in the simulator and the real board have to match for each type. For branch instructions, in case there is a different latency for taken and nontaken branches, the RSK can be adjusted to use non-taken or taken branches by setting the branch address to the exactly sequential instruction so that the control flow is exactly the same and they can be modeled separately. In our case, both cases behave equally. For input-dependent instruction latencies, as it might be the case for divisions or multiplications, several tests covering the different cases can be used to profile the different instruction latencies of that instruction type. Memory hierarchy. As next step, we address the memory hierarchy by testing all types of hits and misses on it. For that purpose, the instruction loop generates hits or misses on the instruction, data L1 and L2 caches. The same procedure followed here can be extended for processors with more hierarchy levels. All caches in our processor have LRU replacement policy, which is the most common in practice. To generate misses we perform W+ 1 accesses, being Wthe number of cache ways, to the same set on each loop iteration. For instance, in the NGMP, caches have 4-ways so performing 5 accesses to the same set for different addresses causes that the first 4 accesses fill the 4-ways of the set and the 5th one evicts the 1st one from the set. When the access sequence repeats, the 1st address misses and evicts the 2nd address, which misses in turn and evicts the 3rd address and so on and so forth. The memory accesses systematically evict subsequent data to be accessed next and thus all accesses miss in the cache systematically. An easy way to access the same set is making cache accesses have an address offset equal to the way size of the cache, i.e., for the 16K L1 cache, 16K/4 ways = 4K. The resulting RSK is shown in Figure 3.5. By doing this we guarantee that we miss on that cache, but we hit on the bigger next level cache. To generate hits 32
3.3 Simulator Figure 3.5: RSK example with loads with 4K offset on a certain level of cache, we use the same procedure, making a loop that misses on the previous level. In the case of the L1 caches, accesses to the same address generate hits. For instruction misses, we use five branches physically separated by the required offset that jump sequentially. For data misses we use load and store operations with the given address offset. This benchmark structure is particularly devised for LRU and FIFO replacement policies. For other types of replacement policies similar structures can be built to produce systematic cache misses. Multicore contention. As last step, we address the multicore contention on the shared bus. To that end, we use a recently published method [63] that allows to derive the latency caused by the contention on the bus. This method allows us to expose the interference that the cores generate for different types of request in a given shared resource. We use two different RSK at the same time, a sensitive RSeK and a stressing RStK. Both RSK perform continuous accesses to the shared resource under analysis by using the same technique presented before to miss in the appropriate cache levels. The RSeK runs on the core under analysis and the RStK run on the rest of cores, thus creating a high contention scenario. The method explained in [63] shows that round-robin arbitration behaves as a time-multiplexed scheme under a high contention scenario. In this situation, the access time of the RSeK accesses with respect to the time-multiplexed window can be varied by inserting a variable amount of nops between RSeK accesses to the shared resources. For each access time, the interference experienced has a different value and follows a sawtooth behavior. The maximum interference delay matches the frequency of the sawtooth. Similar analysis can be carried out in the memory, however, in our case, the interference occurs mostly on the bus because the bus serializes the traffic by stalling accesses until the request being processed is served2. After the contention on the bus is properly adjusted, we run tests based on a RSK that uses a large fraction of the L2 cache on each core to create interference 2This is caused because the board used for the experiments does not use split transactions on the processor bus. Other boards, such as the GR740 [39] use split on the bus. In general, we assume that the processor uses split on the bus despite such processor was not available for the validation. 33
Chapter 3. Methodology between the cores. These can be adjusted to interfere only on the bus or the memory by exceeding L1 and L2 capacity respectively only when run together. For instance, given Ncores, each RSK can be designed so that the cache space used, Ci, matches the following constraint: L2size N< Ci≤L2size. 3.3.2 Validation Results In this section we describe the process followed to adjust the timing parameters and the validation procedure. The processor we use as real reference, a.k.a. board, is the commercially available GRN2X [44] board. In order to get an accurate measure of the execution time, we use hardware PMC that are available in almost every processor architecture. More precisely we use the “execution time” counter, which is one of the most common PMCs. Additional counters that are useful are cache hit and miss counters and cache, bus and memory access counters. These counters can be read directly using GRMON [37] debug tool from the processor vendor3. In all cases, we measure the PMC of interest for the execution of the loop, that is, removing all the overhead of the rest of the program. This can be done by reading the PMCs strictly before and after the loop. The difference between both readings corresponds to the value of the loop itself. Instruction timing As first step in our methodology we run one RSK for each instruction in the SPARCv8 ISA in the simulator and the board. Available parameters from the processor manual [42] have been used to adjust the instruction latencies before the experiments. We group the instructions according to their different nature: load, store, integer/float, short/long and branch. Figure 3.6 shows the results of the instruction validation test for the different instruction types. All results are normalized with respect to the nop case. We performed tests for all instructions, except for the ones classified as special due to their complexity, impact or dependency on the processor. Furthermore, special instructions, such as writing into special processor registers, appear infrequently on a normal execution. We also did not include the detailed analysis of the floating point instructions since they have their own hardware component (FPU), present a much more complex behavior than the rest of instructions and their common-case behavior is well documented in their specification. We can observe that the simulator can accurately model instructions executed within the core incurring all cache hits. There is a significant difference not shown in the figure for division instructions, classified as int long 3Note that these types of PMC and mechanisms to access them can be found in most processor designs, thus allowing to port our methodology to other architectures and processor models. 34
3.3 Simulator Figure 3.6: Instruction timing (together with multiplications), due to input data dependencies. In our case we take the worst-case value, to provide an upper-bound of the execution time, in case some inaccuracy is introduced. This can also be mitigated, if needed, by building a table of latencies indexed with the input values for division (i.e. dividend is zero, divisor is 1). In our case we decided to keep the simulator simple. Memory hierarchy In this step we validate the behavior of the memory hierarchy using RSKs that hit or miss on a given cache level. There are two metrics involved for each memory hierarchy level: number of accesses, such as hits, misses and bus accesses, which are used as a sanity check to see that the RSK does what was expected; and latency measurements used to validate the timing behavior. For the sake of convenience, we only show the latency analysis but similar analysis was done for the accesses, given that both analyses provided analogous conclusions. We begin with L1 instruction and data caches. Figure 3.7a shows the results for load hit and misses in both L1 caches, normalized w.r.t. the execution of nop operations. Store operations in the L1 data cache, which is write-through, behave exactly the same whether they hit or miss since data are forwarded to the next level anyway. There is a source of inaccuracy from our model that can be seen on this figure. Store operations are not exactly modelled due to the presence of one or more writebuffers that are not accurately described in the documentation. Nevertheless, most of the time the latency of a store is equal to a nop operation because the writebuffer is effectively masking store latency, so we only model one write-buffer. In the L2 cache, we have four different types of accesses: loads and writes that either hit or miss. Loads can be instruction or data requests, since the L2 cache is unified. Figure 3.7b shows the values obtained for the different RSKs that generate each type of request. We can observe again the difference for store operations. The 35
Chapter 4. Time-Composable Bus be computed, so fulfilling the time-composability property. The main advantage of resAHB is that it is compliant with the AMBA AHB specification, providing the same functionality as the original one. Our results show that this solution is attractive only when the AHB-connected components have a considerably higher latency than the AHB arbitration itself. Contribution 3. We extend resAHB by introducing a new set of operation modes currently not specified in the AMBA AHB specification. We call this new AHB specification, Advanced High-performance Real-time Bus specification or AHRB. AHRB efficiently isolates the timing behavior of the different components connected to the AHRB, allowing to derive tight and trustworthy WCET estimates. AHRB specification ensures that if all connected components follow it, they will enjoy tight and time-composable bounds for their bus access latency. As a result, although the timing behavior of any IP component1may be unknown, its effect on the bus is bounded under AHRB without any information or requirement from the component at hardware and software levels because timing requirements are already included in the specification. This is of paramount importance in the context of future multi-IP mixed-criticality MPSoC. AHRB extends AHB by adding master and slave modes that allow specifying the use of the bus that each master and slave does, in such a way that it can be taken into account by other master/slaves at design time. This results in tighter (and bound) access times to the bus, which in turn leads to tighter WCET estimates for the applications running on the MPSoC. Our results show that, unlike the original AHB, both resAHB and AHRB enable obtaining time-composable WCET estimates for all tasks running in the MPSoC. Those estimates are independent of the other tasks being run simultaneously. WCET estimates resultant of using AHRB are tighter than those for resAHB, reducing WCET estimates by 3.5x on average. We also observe that in our setup inter-task interferences cause an average performance degradation on the EEMBC benchmarks ranging from 6% to 35% depending on the workload when using a conventional AHB bus. Such degradation reduces with resAHB and AHRB to 1%-5%. The chapter is organized as follows: Section 4.2 describes AMBA. Section 4.3 analyzes the effects of AMBA AHB features on timing and provides examples of how AMBA challenges time composability. Sections 4.4 and 4.5 describe resAHB and AHRB respectively. Section 4.6 shows the experimental results. Sections 4.7 presents the summary of this chapter. 1An IP (intellectual property) component is a block of logic or data that is designed to be ported and reused across different products (ASIC or FPGA). 42
4.2 The Advanced Microcontroller Bus Architecture Figure 4.1: AMBA AHB main components: Masters, slaves, arbiter and decoder. (Picture from AMBA Specification Rev 2.0) 4.2 The Advanced Microcontroller Bus Architecture The Advanced Microcontroller Bus Architecture (AMBA) is a standard bus interface for high-performance embedded microcontrollers, aimed at high-bandwidth, low-latency, high-frequency and low-complexity on-chip communication. Several studies have shown that hierarchical buses scale, in terms of performance and energy consumption, to systems with processor counts in the range 32-64 cores [156, 166]. Thus, AMBA is expected to remain in the near future as one of the standard bus interfaces for real-time MPSoCs. The AMBA specification [14] defines three distinct buses: the Advanced Highperformance Bus (AHB), the Advanced System Bus (ASB) and the Advanced Peripheral Bus (APB)2. In this chapter we focus on the AHB, which is used in several existing architectures such as the Cobham Gaisler GR712RC and the NGMP. AHB has been designed to be a high-performance backbone bus that efficiently connects cores, on-chip memories and IP components. The AHB basic architecture, shown in Figure 4.1, comprises four different components: a set of masters, a set of slaves, an arbiter and a decoder. These components use or control three main buses: the address and control (HADDR in the Figure), read data (HRDATA) and write data 2AMBA 3 specification also includes Advanced eXtensible Interface (AXI), an interconnection protocol independent from the interconnection network topology used. It is later covered in Section 4.5.5. 43
Chapter 4. Time-Composable Bus Figure 4.2: AHB transactions consist of an arbitration and a transfer phase. The latter is divided into beats with an address and control phase and a data phase. (HWDATA) buses. Figure 4.2 shows an AHB transaction between a master and a slave. A master initiates a read/write transaction to a slave by requesting to the arbiter the access to the address and control bus. During the arbitration phase, the arbiter handles the contention across masters by granting access to the bus only to one master at a time according to a predefined arbitration policy (not defined by the AMBA specification), so that concurrent transfers are not allowed. Once a master is granted access to the bus by the arbiter, the transfer phase starts. The transfer is split into several beats if data cannot be sent through the bus all at once (i.e. burst transfers). For instance, the transfer in Figure 4.2 requires three beats. Every AHB transfer beat consists of two subphases that overlap across beats, as defined in the specification: an Address-and-Control phase that lasts for one cycle in the absence of contention, and a Data phase that lasts one or more cycles (in case the master/slave cannot provide the data at that moment). The decoder controls the multiplexers to send the address to the appropriate slave, and two data buses are used to send/receive data to/from the slave. When the transaction finishes, the master relinquishes the buses. 4.3 AMBA AHB and Time Composability As MPSoCs integrate an increasing number of IP blocks coming from different suppliers and the functionality provided by MPSoCs keeps diversifying, the trend towards MPSoC comprised of multi-party IPs will further exacerbate. Moreover, it is also the case that real-time system IPs may be subject to different safety and security levels. Hence, in order to enable mixed-criticality functionalities to be run on the same MPSoC, the impact that one IP component can create on the timing behavior of the others must be limited and this cannot be left to the IP provider, especially to those subject to less-restrictive criticality levels. The safety of the integrated system in terms of timing behavior should be provided by design (construction), in our view, and thus by the bus protocol specification itself. Since time composability is the central element for reducing timing verification and 44
4.3 AMBA AHB and Time Composability validation costs, it should be provided by design. Time composability imposes that the maximum time any request of any task waits to be granted access to the bus is bounded and the bound does not depend on the particular co-running tasks in the MPSoC [138,139]. This requires that (1) the arbitration phase for every transaction is bounded and this bound does not depend on the behavior of other components; and (2) the duration of the transfer phase of every transaction is also bounded. Note however, that the arbitration-time and transfer-time bounds may depend on hardware implementation details, such as the number of cores contending for the bus. This however does not jeopardize time composability, since those features are known at design time, when WCET estimates are computed for each task. If every access to hardware shared resources fulfills the time composability property defined above, WCET estimation for a task, either with static timing analysis or measurement-based techniques [180], is independent of the accesses that other co-running tasks may do on the same hardware shared resources. This effectively enables the computation of WCET estimates for each task in isolation, bringing the benefits of reducing time validation and verification costs as explained in the previous section. Unfortunately, at the time AHB was released, time composability was not one of its design goals. As a result, AHB-compliant master/slaves lead to non time-composable behavior that makes difficult analyzing the timing properties of an AHB-based MPSoC. In this section we review AHB features and classify them according to their effect on timing. Table 4.1 summarizes the features we analyze. 1) Number of masters: AHB allows up to 16 bus masters contending in one bus. The number of masters does not break time composability because it is a feature known at design time, like the number of cores in a multicore platform. However, it affects the tightness of WCET estimates. In real-time scenarios, the worst-case situation to consider happens when, on the event of a master trying to get access to the bus, all the other masters want to access the bus the same cycle, all of them having higher priority. 2) Handover: Changing the ownership of the bus from one master to another is called handover. AHB has a one-cycle master handover, so a master being granted access to the bus in a given cycle, gets the bus in the next cycle, so the minimum arbitration time is one cycle. This effect can be taken into account for each request of a task by adding this extra cycle of delay to the arbitration time. This feature is time-composable and has negligible effect on timing tightness. 3) Back-to-back execution: Back-to-back execution occurs when two transfers from different tasks are executed consecutively one after the other, without any idle cycle in between. This is feasible because of the pipelined execution of AHB, where address and data phases of different transfers overlap. This feature has 45
Chapter 4. Time-Composable Bus Table 4.1: List of AHB features analyzed ID Feature Breaks TC? Affects WCET bounds? 1 Number of Masters No Yes 2 Handover No No 3 Back-to-back No No 4 Burst operation Yes Yes 5 Flow control Yes Yes 6 Split transactions No Yes 7 Locked transfers Yes Yes 8 Bus width No Yes 9 Protection control No No 10 Error response No No 11 Retry response No No 12 Idle transfers No No 13 Early burst termination No No 14 Arbiter Yes Yes neither an effect on timing nor on time composability. 4) Burst operation: Burst operation allows to perform transactions composed of more than one beat. AHB allows to have undefined-length bursts, 4-beat, 8- beat or 16-beat burst transactions. Undefined-length burst can be of any length, although its limit is constrained by the fact that the address cannot cross a 1 KB boundary. The burst length affects WCET estimates since, to compute them, it is needed to assume always the maximum burst length allowed in the system, even though it might be too pessimistic to be useful. 5) Flow control: Flow control in AMBA AHB can be performed by both the master and the slave. The slave can extend the data phase of a transfer by inserting wait states if, for instance, it needs extra time to process the transaction. Similarly, the master can insert busy transfers with the same purpose of extending the time between data transfers. The original AHB specification states that the number of wait states is limited, but it does not set any specific limit. The absence of a specific limit breaks time composability because it eliminates the possibility of computing how long a transaction can take, so how many other tasks in the system can be delayed because of such transaction. Further note that both, wait states and busy transfers, increase WCET estimates since for every transaction, the maximum number of wait states and busy transfers must be assumed. 6) Split transactions: Split transactions provide a mechanism for slaves to release the bus when they need some more time to respond. This allows other 46
4.3 AMBA AHB and Time Composability masters to get access to the bus rather than waiting for the slave to finish. When a slave signals a split transaction, the arbiter masks the request of its corresponding master until the slave indicates that the response is ready, so the master is considered again in the arbitration. Note that the master has to wait again for arbitration, and only when the arbiter grants the bus access, the slave can respond to the request. Signaling a split transaction needs a two-cycle response. This effectively adds two cycles to the size of a transfer for WCET estimates. Therefore, a split transaction only affects the timing behavior of the master that received it, as two arbitration phases occur: the first one when the request is issued, and the second one when the slave is ready to respond. This is not the case for the rest of masters, in which a split transaction is seen as two independent transactions. It is important to remark that, although the master can keep the slave component busy during a split transaction, thus affecting others, this contention is not because of the bus, but because of the slave. 7) Locked transfers: Locked transfers allow a master to keep the ownership of the bus until the locked sequence has been completed. Locked transfers ensure that a transfer is done without disturbance, which is necessary, for instance, in the case of read-modify-write requests to an AHB connected cache or memory device. However, locked transfers can be very harmful for time composability, because a master can issue a locked transfer and keep the bus busy indefinitely, thus affecting other masters. Section 4.4.1 provides a discussion of how the functionality provided by locked transfers can be implemented avoiding the issue of affecting the other tasks in a timing unpredictable way. 8) Bus width: AMBA AHB allows different bus widths: 8, 16, 32, 64, 128, 256, 512 and 1024 bits-wide buses. It is recommended a minimum of 32 bits. This feature does not affect time composability but it has an effect on timing, because the wider the bus, the fewer the number of transfers needed. Note that the bus width is known at design time, like the number of masters. 9) Protection control: AMBA AHB has protection control signals that provide information about a bus access, to be used by any module that implements some level of protection. These signals indicate whether the access is instruction or data access; user or privileged access; bufferable and cacheable. Since no functionality is attached to these signals, because it is something optional and for higher level protocols, it is completely harmless for time composability. 10) Error response: A slave can respond to a transfer with an error, to indicate that something went wrong. Although errors may break timing behavior of a task, it is a responsibility of the master-slave higher level communication protocols to take care of errors and it does not affect other masters. Hence, it does not affect time composability. Errors require two extra cycles for signaling, as in the case of split transactions. 47
Chapter 4. Time-Composable Bus 11) Retry response: A slave can respond also with a retry response, to indicate the master to perform the transfer again. Like error responses, retries may also break timing behavior of a task, but this is again responsibility of the master-slave higher level communication protocols and does not affect other masters. Hence, it does not affect time composability. Retries also require two extra cycles for signaling, as in the case of error responses and split transactions.Retry responses can also be used as an alternative to split transactions when the slave is unable to provide the response (e.g., due to its high latency). The difference is that with retry response, the normal arbitration priority scheme will be maintained. With split transactions, the arbiter masks the request of the split master until the slave indicates that the response is ready, which improves performance, since that master will not be granted access unless the response is ready. 12) Idle transfers: Idle transfers are used to indicate that no data transfer is required. AMBA uses a default master when all other masters are unable to use the bus. When granted, the default master must only perform idle transfers. Idle transfers can also be used in case a master cannot continue a burst. It is completely harmless for time-composability. 13) Early burst termination: Early burst termination is a mechanism that allows slaves to detect when a burst transfer is incomplete. If during a burst transfer, a slave detects an idle transfer or a non-sequential transfer, it means that the previous transfer finished before it was completed. This may occur if the arbiter changes the ownership of the bus, or if the master cannot finish the burst. This feature is completely harmless for time composability. 14) Arbiter: AMBA does not define any restrictions on the arbiter, which means that any arbitration policy can be used. This can completely break time composability as we show in the example in Section 4.3.1. The arbitration policy affects the timing behavior of all masters, because it defines how much time a master has to wait to be granted access to the bus, which indirectly depends on the other masters’ behavior. 4.3.1 Example of Non Time-Composable Behavior Unfortunately, at the time AHB was released, time composability was not one of its design goals. As a result, AHB-compliant master/slaves lead to non timecomposable behavior that makes difficult analyzing the timing properties of an AHB-based MPSoC. Figure 4.3 shows an example that illustrates three AHB- compliant non-time composable behaviors of a master/slave communication. Concretely, it shows the timing diagram of an AHB bus of two masters, M1 and M2, each sending transactions Aand Brespectively, both with a burst transfer size of 4 beats. The transfer part of the transaction from master M1 occurs between cycles n+ 2 and n+ 6. In those transfers, phases overlap across beats. For instance, 48
4.3 AMBA AHB and Time Composability Figure 4.3: Example of non time-composable behavior. address phase of transfer A1 overlaps with the data phase of transfer A0 given that they use separate buses. Non time-composable behaviors are as follows: a) M1 requests the bus in cycle n+ 1 and gets it in cycle n+ 2, thus having an arbitration time of 1 cycle. Master M1 issues a locked transaction at cycle n+ 2. As defined in the AMBA specification the arbiter cannot relinquish the bus during a locked transaction, so that this transaction from M1 can affect the timing of other masters in an unpredictable manner potentially preventing them from using the bus indefinitely (4 cycles in the example). Hence, the existence of locked transactions is a feature that breaks time composability. b) Masters can issue unspecified-length burst transfers, which does not allow bounding the latency of a transaction. For instance, in Figure 4.3,M1 issues a burst length of 4, which means that for WCET estimation we have to assume that every possible transaction from M1 is at least 4 beats long. However, if a new master is connected with a burst-length of 8, it invalidates the previous analysis. c) Finally and more revealing, AHB specification does not put any requirements on the arbiter behavior, and only the arbiter interface is specified. For instance, the arbiter can take away the bus grant from a master, as occurs in cycle n+ 2 when M2 is sending a burst transfer and the arbiter changes the bus ownership to M1. This can happen due to the fact that any arbitration policy to select the next master to grant access to the bus can be used. Under some arbitration policies, there may not be an upper bound on the time one master can delay the others to access the bus, thus, breaking time composability. For instance, if M1 has higher priority than M2 and both tasks attempt to access the bus simultaneously, M2 is stalled until M1 finishes. However, if before the first request from M1 finishes, another request from M1 becomes ready, M2 will also wait for the second M1 49
Chapter 4. Time-Composable Bus request to finish as well. Thus, the bus contention that M2 suffers depends on M1. Even though this effect can have an upper bound and be computed knowing M1, it breaks time composability, because if we change M1 behavior (e.g., the task running on top of such master) it invalidates the timing analysis for M2. In summary, in order to achieve time composability several features of AMBA AHB must be either limited or disabled. In particular, unrestricted locked transfers must be avoided, only time-composable arbitration policies must be considered, and burst length, wait states and busy cycles must be limited. 4.4 Restricted Time Composable AHB As shown in previous section, AMBA AHB specification does not guarantee time composability at bus transaction level. This section defines a restricted usage of a subset of the AHB features, such that if every master and slave follow this restricted AHB specification (resAHB), time composability can be guaranteed by construction at transaction level. The main goal of resAHB is to derive tight upper bounds for every bus transaction, regardless of the actual behavior of other master/slaves components, while keeping AMBA AHB functionality. In order to achieve time composability, the AHB features that must be considered are burst length, wait states and busy cycles (i.e. flow control), locked transfers and the arbitration policy. Burst length: AHB allows defining burst sizes of 4-beat, 8-beat, 16-beat and undefined length. Undefined burst sizes break time composability as they prevent bounding the impact of a bus transaction on other transactions belonging to different tasks. Therefore, we enforce maximum burst length to be 16 beats, which will be compatible with existing AHB components. Components needing bus transactions larger than 16 beats must split the transaction in several transactions. It is important to remark that the burst sizes of undefined length can still be set assuming any length smaller than 16 beats. If the burst length of an undefined transaction is above 16 beats, the corresponding master or slave will have to split the transaction. Flow control: Flow control defines the number of wait states and busy transfers. As we have seen in the previous section, the original AHB specification states that the number of wait states has to be limited, recommending not to insert more than 16 wait states but it does not specify any limit. In order to provide timecomposable AHB transactions, we restrict the number of wait states to 16, which is the maximum recommended by the specification and corresponds to 16 bus cycles. In case a slave needs more than 16 wait states, it can signal either a split transaction or a retry (in case the resource is busy). On the master side, busy transfers need also to be limited. Similar to wait 50
4.4 Restricted Time Composable AHB states, we enforce masters not to introduce more than 16 busy transfers, which corresponds to 16 bus cycles. If a master needs more than 16 busy transfers, e.g. it cannot continue the current transfer, it will have to signal an early burst termination which releases the bus. The transaction can then be performed once the master is ready. It is worth noting that both, wait states and busy transfers, introduce pessimism in WCET estimates as the worst-case scenario must be considered, i.e. every transfer incurs 16 wait states and busy cycles. Arbiter. The AMBA AHB specification does not put any restriction on the arbitration; this is not suitable for time composability, so resAHB constraints the timing behavior of the selected arbiter. On the one hand, resAHB restricts the arbitration policy to those that allow to derive upper bounds on the time a master needs to wait to be granted to use the bus, e.g. TDMA (Time Division Multiple Access) and Round-robin [138]. For example, under round-robin arbitration policy, in the worst case a master waits N−1 rounds of arbitration before it gets the bus, where Nis the number of masters. Hence, the longest arbitration latency a master suffers due to inter-task interferences is bounded by BoundRR = (N−1)×(ttran −1), where ttran is the bus transfer time from which one cycle is subtracted because in consecutive transfers address and data phases overlap. Any other arbitration policy that allows to derive time composable upper bounds on the arbitration time can be considered. We elaborate more on this topic in Chapter 5. On the other hand, the arbiter must not change bus ownership during a transaction. That is, under resAHB a master cannot be preempted once it has been granted access to the bus. Locked transfers. Under resAHB, locked transfers are not allowed to take longer than the maximum transaction latency, that is 50 cycles as shown in Section 4.4.2. Locked transfers are used to eliminate disturbance when doing an access or a sequence of accesses. If the accesses can be served with a single transfer, locked transfers are not needed, since, as pointed above, bus transactions are not preempted, i.e., other masters cannot use the bus until the current transaction finishes. In the case of a sequence of accesses that require more than one transfer, e.g. read-modify-write accesses, the atomicity provided for individual transfers does not suffice to provide the same functionality as locked transfers. In Section 4.4.1 we present a mechanism to provide this functionality without requiring locks. 4.4.1 Providing the same functionality as AHB resAHB restricts the use of locked transfers to avoid masters to lock indefinitely the bus, which would simply kill time composability. However, locked transfers provide 51
Chapter 4. Time-Composable Bus Figure 4.4: AHRB extended architecture with HMMODE and HSMODE signals. current processor architectures. We introduce two new signals that define the master mode, HMMODE, and the slave mode, HSMODE. These signals are generated in the arbiter and reach the master or slave component respectively. The extended bus architecture is shown in Figure 4.4. 4.5.5 AHRB principles in other AMBA specifications AXI is a specification in AMBA3 which only defines interfaces between (1) the master and the slave, (2) the master and the interconnect and (3) the slave and the interconnect, allowing the chip designer to use potentially any interconnect. On the one hand, in order to determine whether time-composable access delays for the interconnect can be achieved, a specific interconnect has to be defined and analyzed. For instance, crossbars are time-composable by design. However, the fact that AXI does not define the timing aspects in the master-slave-interconnect communication provides full freedom to define an AXI-compliant time-composable interconnect (tcAXI ). In our view, this offers an excellent opportunity to real-time industry to define atcAXI enjoying a well-defined and standardized interface such as AXI, while adding specific restrictions to make it time-composable. The principles that rule the definition of tcAXI should be in line with those we define in this chapter. Besides AHB and AXI, the AMBA specification defines other interfaces that we qualitatively analyze next in terms of time composability. AHBLite/APB. APB and AHBLite are intended for a single master, which prevents inter-task interferences and hence the need of time-composable access delays. ASB. ASB was designed to be the main system bus, like AHB. However, 58
4.6 Evaluation AMBA recommends AHB for all new designs because AHB provides improved features. Anyway, the same approach explained in this chapter can be carried out in ASB. ACE. ACE adds system-level coherence support to AXI, which does not have any impact on timing. ATB. ATB is a trace bus for on-chip debug, which is free of real-time constraints. 4.6 Evaluation In this section we quantitatively compare the time composable AHB proposals, resAHB and AHRB against the original AMBA AHB in terms of time composability, WCET estimates and average performance. Simulator Setup. We use the simulator, explained in Section 3.3, to model a multicore architecture with 4 cores connected through a bus to the L2 cache and a I/O controller. Each core is a pipelined processor core comprising fetch, decode, execute and commit stages. Each core has its own private instruction (IL1) and data (DL1) caches, which is common in current high-performance and real-time embedded processor designs [42,84]. 16KB 4-way 16-byte-line IL1 and DL1 caches have been considered. The shared second level (L2) cache is 256KB with 8 banks, 8 ways and 16-byte lines. IL1 and DL1 hit and miss latencies are 1 and 2 cycles respectively. L2 hit and miss latencies are 4 and 6 cycles respectively. DL1 is write-through and L2 write-back. All caches use LRU replacement policy. The bus connecting the cores to the L2 and the I/O device is 128-bit wide, which means that a cache line can be transferred in a single-beat transfer and no burst transfers are needed. The I/O controller has 20 cycle latency. The L2 cache deploys a cache partitioning technique, way partitioning, that deals with inter-task interferences [138] and has been implemented in real chips like the NGMP [42] or the ARM Cortex A9 [15]. For the memory controller we use the low-overhead solution proposed in [139], which upper bounds the effect of inter-task interferences on the requests of a core to the memory controller. Overall, the only source of inter-task interferences that jeopardizes time-composability, potentially affecting WCET estimation, is the AMBA AHB bus. Benchmarks. We use the EEMBC Autobench suite [143] as reference programs (see Section 3.2.1). In particular we use: a2time,aifftr,aifirf,aiifft,basefp, cacheb,canrdr,idctrn,iirflt,matrix,pntrch,puwmod,rspeed,tblook and ttsprk. We also develop a set of synthetic kernels that carry out a fixed number of accesses to the bus, either to the L2 or to the I/O device. We vary the percentage of accesses of the benchmark to the L2 and to the I/O device, such that, if a kernel 59
Chapter 4. Time-Composable Bus makes X% of access to the I/O, the remaining 100% −X% of the accesses go to the L2. 4.6.1 Achieving Time Composability As MPSoCs integrate an increasing number of IP blocks coming from different suppliers and those IPs may be subject to different safety and security levels, enabling mixed-criticality functionalities to be run on the same MPSoC requires limiting the impact that one IP component can create on the timing behavior of the others. Leaving this to the IP provider, especially to those subject to lessrestrictive criticality levels, may jeopardize the whole system time composability property. AHRB is precisely designed to provide trustworthiness in terms of timing behavior by design (construction), so that any misbehaving IP component does not affect the time composability of the other components. Hence, we evaluate our proposal in a setup in which time composability can be broken, as it is shown to happen with AHB. In our experimental setup, the I/O controller has 20-cycles latency and, under AHB, it benefits from unrestricted timing by keeping the bus busy for those 20 cycles when needed. In the case of the time composable AHRB, we configure the slaves in slave mode 4 (L2 hit latency is 4) and masters in master mode 1 (only 1 beat is required to transfer a cache line), so that all L2 hit requests are served with only one bus transaction. The I/O component has to relinquish the bus on each request because the bus is configured in slave mode 4, which means that a component can only insert 4 wait state cycles, which is less than the latency of the I/O component (20 cycles). Hence, the I/O component issues a split transaction on every access, and so every request goes through two arbitrations. In order to understand the potential contention that a transaction can suffer in the bus, we run one EEMBC benchmark in one core while the other three cores run 3 copies of the synthetic kernel that continuously accesses memory and the I/O controller, so that they affect significantly the EEMBC benchmark execution time. Different fractions of memory and I/O accesses are considered for this synthetic kernel. Figure 4.5 shows the normalized execution time of each EEMBC benchmark when running against 3 copies of the synthetic kernel with respect to its execution time in isolation (running alone in the MPSoC). Results are shown for both the regular AHB and the time-composable AHRB scenarios. Note that the execution times in isolation are the same under both setups since cache hits are handled in one transaction while misses require two transactions using split transactions. The I/O device is not accessed by EEMBC benchmarks which only access the L2 cache. Bars show the results as we increase the percentage of I/O requests sent by the synthetic kernel. Figure 4.5a shows the results for the standard AMBA AHB. As 60
4.6 Evaluation (a) Normal AHB (b) Time composable AHRB Figure 4.5: Execution times of EEMBC benchmarks against 3 synthetic kernels that continuously access memory and the I/O controller for AHB and AHRB. The percentage indicates the amount of accesses to the I/O controller. shown, bus contention significantly affects the execution time of EEMBC benchmarks (6% to 35% in average). This occurs because every I/O access keeps the bus busy for 20 cycles and as the percentage of I/O accesses grows, this saturates the bus, thus delaying L2 cache accesses for EEMBC benchmarks due to bus contention. Note that for cacheb, which makes the most intensive use of the bus across all EEMBC benchmarks, the impact of the synthetic kernels is high (up to 72%) when the percentage of I/O accesses grows. Eventually, a slave component could be in place with unspecified or arbitrarily long latency. In such case no WCET estimate could be provided for any program, or such estimate would be so high that it would be of no use. 61
Chapter 4. Time-Composable Bus Figure 4.5b shows the results for the time-composable AHRB. We observe that bus contention becomes negligible (1% to 5% in average), since I/O accesses become split transactions, thus letting L2 cache accesses of the EEMBC benchmarks to proceed. As the fraction of I/O accesses of the 3 copies of the synthetic kernel increases, their bus access frequency decreases. This occurs because for this kernel, the accesses to L2 frequently hit so they have shorter latency than I/O accesses. As a result, with low L2 access rate, and hence with high I/O access rate, the kernel access less frequently to the bus. Hence, in the presence of I/O intensive kernels, the EEMBC benchmark is granted access to the bus quickly and competes with fewer requests in memory in case of a L2 miss, thus executing faster. This effect is particularly noticeable for cacheb and canrdr that have slightly higher execution time when the kernels execute low percentage of I/O operations. Our results show that the potential effect that tasks can suffer due to inter-task conflicts can be reduced using AHRB.AHRB also provides time-composable upper bounds by construction, without any requirements on the components at hardware or software level (apart from being compliant with the AHRB specification), which significantly simplifies WCET estimation. This allows using components that otherwise would degrade significantly WCET estimates or simply would not allow to obtain such estimates. The main limitation of the standard AMBA AHB is that WCET estimates depend on the actual behavior of components in place. If such timing behavior changes, for example due to a firmware update that changes the I/O component latency to 25 cycles, or simply other applications make a different use of the component triggering higher latencies, the timing analysis of all tasks running on the system is invalidated, even if those tasks do not ever use such component. By putting the timing restrictions on the bus interface instead of on the components, we avoid this issue because the timing upper bounds are set by the bus interface itself and not by the IP component. 4.6.2 Average performance With time composable AHRB, I/O transactions are split into two transactions. This, on the one hand, increases the latency of each transaction as it has to pay two arbitration rounds. On the other hand, however, each arbitration round is much shorter since the bus cannot be locked for long time. Our results show that the benefits of shorter arbitration rounds largely offset the extra latency due to the fact that I/O transactions have to pay two arbitration rounds. Figure 4.5 show that EEMBC benchmarks have higher average performance, i.e. shorter execution time, under AHRB than under AHB. To complement the average performance study, we measured the performance of the synthetic kernel under all percentages of I/O and L2 operations (i.e. 0%, 20%, 40%, 60% and 80%). Figure 4.6 shows the average throughput improvement of AHRB over AMBA AHB, 62
4.6 Evaluation Figure 4.6: Average IPC improvement of AHRB over AHB, for the 3 copies of the synthetic kernel when running in a 4-workload setup with each EEMBC. i.e., the average of IPCAHRB/IPCAHB (IPC stands for instructions per cycle) for all 3 kernels, when they run with each EEMBC under all I/O-L2 percentages. Results confirm the benefits of short arbitration periods over several arbitration phases, hence making AHRB to provide higher average performance than AMBA AHB. These improvements range from 4% to 9%. 4.6.3 WCET estimates Regular AMBA AHB does not allow deriving time-composable WCET estimates. Instead, they can only be derived with resAHB or AHRB. For both, resAHB and AHRB, we have to assume that every access to the bus experiences the maximum arbitration latency [138] and also every memory access experiences the longest request inter-task delay [140] (i.e., the maximum possible delay due to requests from the other cores), since they are the only sources of inter-task interferences in our platform. For the bus, we take 148 bus cycles as the maximum arbitration latency for resAHB as explained in Section 4.4.2 and 19 for AHRB, applying Equation 4.2 with master modes being 1 and slave modes 4 (also shown in Table 4.2). Figure 4.7 shows the normalized WCET estimates of each EEMBC benchmark with respect to its WCET when running in isolation for both resAHB and AHRB. It can be clearly seen that AHRB leads to much tighter WCET estimates than resAHB, in average 3.5x tighter. This occurs because the arbitration latency bound is high for resAHB, whereas such bound is much tighter for AHRB since we fit the bound to the master and slave characteristics with the master and slave modes. Although resAHB allows deriving WCET estimates, those estimates are so high (above 4x the ones in isolation) that it would be better to use just one core in the platform to schedule all tasks. Instead, AHRB provides WCET estimates largely 63
Chapter 4. Time-Composable Bus Figure 4.7: WCET estimates comparison for resAHB and AHRB. below 4x, thus providing higher guaranteed performance when exploiting the 4 cores in the 4-core platform than when using just one core. 4.6.4 AHRB: Master & Slave modes In order to show the effect of the master and slave modes on WCET, we compute WCET estimates for EEMBC under AHRB with different modes. In particular, we show results for slave modes 2 and 4. With slave mode 4 (equal to the L2 hit latency) we cover each hit request with one transaction. Instead for the slave mode 2, we need to issue split transactions and pay two arbitrations for every L2 hit. Hence, in slave mode 2, L2 accesses suffer lower bus contention due to the shorter transactions in the other cores, but suffer higher arbitration delay in case of a hit due to the split transaction. Therefore, depending on the L2 access frequency and L2 hit rate, the net effect in WCET estimates will vary. The maximum arbitration time also depends on the other masters’ mode. The lower the other masters’ mode is, the smaller the arbitration time is. In this evaluation we assume that the master that runs the EEMBC is in master mode 1 and it runs with three other masters, either in mode 1 or mode 4, which correspond to masters that need only 1 transfer per access (e.g., cache line size matches bus width) and masters that need 4 transfers per access (e.g., cache line size is 4 times larger than bus width so a 4-beat burst is needed)5. In this case it is clear that the lower the addition of the transfer sizes of the other masters, the tighter the WCET estimate we will be able to derive. The possible combinations and the associated maximum arbitration time computed with Equation 4.2 are shown in Table 4.2. Figure 4.8 shows the results of two slave modes (2 and 4) for the EEMBC 5Note that a high master mode might be useful to enable efficient (large) DMA transfers performed by a DMA master. 64
4.7 Summary benchmarks, varying the master modes, shown as MM x-x-x-x in Figure 4.8. The first master, which is used by the EEMBC benchmark, is always in mode 1. We observe that WCET estimates depend on the rest of the masters modes. The higher the other master modes, the larger the WCET estimate is. We also observe that there are benchmarks that are barely affected by the modes, like matrix, because of the reduced use of the bus, and others are, however, significantly affected like cacheb. Finally, our results show that under sm 2, WCET estimates increase by 6% to 19% on average for the different master setups, because L2 hits, which are very frequent for many benchmarks, need 2 transactions to be completed, because the slave (cache) needs to perform split transactions. For instance, we observe that cacheb is severely affected when lowering the slave mode to 2 because it makes an intensive use of the L2 cache. For matrix the effect is negligible because it barely accesses L2 cache. 4.7 Summary MPSoCs have become a must in critical real-time embedded systems (CRTES) since they deliver high performance needed for increasingly computational intensive applications. Integrating different IP components in those processors requires a standard specification for the communication bus, and AMBA AHB has been proven to be a suitable interface in embedded systems. Unfortunately, the need for incremental qualification poses requirements regarding time composability in the AMBA AHB. In this chapter we thoroughly review AHB features identifying those that make AHB fail to provide time composability and those that, although time-composable, lead to non-tight WCET estimates. Then, we propose a time-composable AHB (resAHB) specification, which enables computing application’s WCET, though with large overestimations. Finally, we introduce a new bus specification based on AHB, AHRB, which achieves both, time composability and tight WCET estimates. Our experiments show that WCET estimates can be derived on top of resAHB and AHRB, and AHRB improves WCET estimates by 3.5x w.r.t. resAHB with negligible average performance degradation over single-core execution. 65
Chapter 4. Time-Composable Bus (a) Slave Mode 2 (b) Slave Mode 4 Figure 4.8: WCET estimates for AHRB with different master modes (1 and 4) and slave modes (2 and 4). 66
Chapter 5 Bus Arbitration Policies 5.1 Introduction The contention among several cores attempting to access the bus simultaneously, generates inter-task interferences in the bus that are handled by the arbitration policy. The choice of the policy affects the whole system because the time a bus request takes to be completed, depends on the amount of time that the request waits to be granted access by the arbitration policy, which intrinsically depends on the other running tasks (or system’s workload). In order to be able to provide WCET estimates, the effect of inter-task interferences has to be known or, at least, upper bounded for every possible workload (ideally this bound is independent of the workload) and introduce as little pessimism in the WCET estimate as possible. As seen in Chapter 4, if that upper-bound depends on the set of running tasks, the WCET analysis has to consider all possible interactions within every workload, thus challenging time composability, which significantly complicates the analysis and integration of the system. Thus, using an appropriate arbitration policy will help (1) simplifying WCET analysis for multicore systems and (2) providing tight WCET estimates. To our knowledge, two main policies have been proposed to deal with intertask interferences on on-chip buses that satisfy these requirements: Time-Division Multiple Access (TDMA) and Interference-Aware Bus Arbiter (IABA) [138]. TDMA applies time sharing between the requests of the different contenders. Time is divided into windows, in each of which a contender is assigned a slot. When a request of a given contender becomes ready in that contender’s slot, the request gets immediate access to the bus. If the request becomes ready out of the contender’s slot, it waits until the contender’s next slot. IABA, instead of timesharing the access to the bus, allows tasks to contend for the bus using a given access policy such as round-robin, and bounds the delay that a request can suffer 67
Chapter 5. Bus Arbitration Policies (a) 128-cycle window (b) 64-cycle window (c) 32-cycle window (d) 16-cycle window Figure 5.3: Memory accesses histogram inside a TDMA for several window sizes to the cycles in which the request is in its slot. The second interval, containing the rest of the cycles, forms a linear decay that goes from the maximum BID value, i.e., (Nc−1)s+ (r−1) down to 1. The average expected BID for both intervals can be expressed as shown in Equation 5.3. In the first addend BID equals 0 for s−r+ 1 cycles and the second addend corresponds to the linear decay, both addends divided by the number of cycles of the window, Nc·s: BIDT DMA expected = 0×(s−r+ 1) + (Nc−1)·s+(r−1) P i=1 i Nc·s(5.3) Overall, Equation 5.3 allows us to compare IABA and TDMA for any setup including the core count accessing the bus and the bus latency. As an illustrative example, Figures 5.4(a)-(d) show different values for TDMA and IABA. Interestingly, in all cases the cross-point between BIDT DMA expected and BIDIABA worst occurs when the slot size sis equal to 2 ·r, i.e., TDMA offers better worst-case performance 74
5.4 Empirical comparison of TDMA and IABA (a) Nc= 4, r= 2 (b) Nc= 4, r= 8 (c) Nc= 4, r= 16 (d) Nc= 8, r= 16 Figure 5.4: BID for TDMA and IABA with Nc= 4,8 and r= 2,8,16 than IABA when the TDMA slot size s < 2·r, as we show in our experiments later. 5.4 Empirical comparison of TDMA and IABA In this section we qualitatively and quantitatively compare TDMA and IABA using different metrics: required changes at hardware and software level (i.e. analysis tool), WCET estimates obtained, prioritization capabilities, average performance and time composability. The quantitative metrics have been obtained using the simulator explained in Section 3.3. We model four and eight cores architectures in which each core has private instruction and data caches, which is common in current high-performance and real-time embedded processor designs [42,84]. The cache hierarchy comprises 75
Chapter 5. Bus Arbitration Policies first-level 4KB instruction cache and 4KB data cache. The shared L2 cache is 256KB in size with 8 banks and 8-way associativity. The cache line size is 16 bytes in all caches. Hits on the data and instruction caches take 1 cycle and misses 2 cycles. Hits to L2 take 3 cycles and misses 1 extra cycle. The access to main memory is 100 cycles. The bus request latency is 2 cycles. With the aim of evaluating TDMA and IABA, we make the bus the only resource for which tasks in different cores compete. To that end, we deploy existing solutions that partition the L2 cache. The memory bandwidth is partitioned using the techniques proposed for the memory controller in [139,7]. We used twelve benchmarks of the EEMBC Autobench suite [143] as reference for the analysis of single-path programs. We used: a2time,aifirf,basefp,cacheb, canrdr,idctrn,matrix,pntrch,puwmod,rspeed,tblook and ttsprk. 5.4.1 WCET analysability: feasibility and required changes at hardware level and in the WCET analysis tool Next we show the main changes required by TDMA and IABA when using Static and Measurement-based timing analysis. Static Deterministic Timing Analysis (SDTA) SDTA techniques rely on (1) the construction of a cycle-accurate model of the system and (2) determining a trustworthy upper-bound on the WCET. At the hardware level, it is necessary for every resource to have a bounded access latency that is provided as input to the model. The same principle applies to the bus: On the one hand, the time it takes a request to access the bus must be boundable, even in the presence of inter-task interferences. On the other hand, the tighter this bound is, the tighter the obtained WCET estimates. If the bus uses IABA, no change is required in the SDTA tool: Basically, the access latency of each request to the bus is augmented with the BIDIABA worst . IABA requires changes only in the configuration of the processor parameters given to the tool but not in the tool itself. For TDMA, using BIDTDMA worst as bound is pessimistic since for any given cycle BIDT DMA worst ≥BIDT DMA exact . If the exact cycle in which each request accesses the bus could be known by the SDTA tool, we could use for each request its BIDTDMA exact , thus eliminating the pessimism on the estimate. However, imposing that the STA tool provides the exact cycle in which each bus request occurs is complex [101] or even unfeasible [165]. In reality, for each request, rather than an exact cycle, it can be estimated a time interval [101] in which it can access the bus. This inaccuracy comes from the fact that the structure of the program includes branches, loops, etc., which complicate the estimation of exact cycles, since the time at which one request accesses the bus may depend on the path followed to get to the basic block 76
5.4 Empirical comparison of TDMA and IABA in which the request is. Note that as soon as the estimated time interval for a request to access the bus is longer than the window, the SDTA tool has to use BIDT DMA worst as the bound. Measurement-Based Deterministic Timing Analysis (MBDTA) MBDTA techniques rely on extensive testing performed on the real system, recording the so-called high watermark execution time, i.e. the longest observed execution time. The high watermark observed during this testing phase is multiplied by an engineering margin. The outcome is used as WCET estimate for the task during deployment time. Both TDMA and IABA require hardware changes in order to enable the use of MBDTA tools: With IABA, during the testing phase the program under study is run in isolation. Every time a request to the bus is ready it is artificially delayed by the architecture by BIDIABA worst cycles, which requires changes in the bus arbiter [138]. From traces obtained during this execution in isolation, a WCET estimate for the task is obtained. At deployment time, the hardware is instructed not to introduce any artificial delay. The key point of this solution is that the artificial delay introduced during testing upper bounds the inter-task interferences that the task can suffer during deployment time [138]. For TDMA, it is critical that every request gets access to the bus exactly in the same cycle during both testing and deployment time, otherwise losing trustworthiness on the results. One possible solution is to synchronize the start cycle of a task with a fixed point of the TDMA window in each execution, by means of some hardware support. 5.4.2 Worst Case Performance In this chapter we use RapiTime [146], a commercial measurement-based WCET analysis tool. RapiTime uses path analysis techniques to build up a precise model of the overall code structure and determine which combinations of subpaths form complete and feasible paths through the code. RapiTime combines the measurement and control flow analysis information to compute measurement based WCET estimates in a way that captures the execution time variation on individual paths. For TDMA, we assume two different scenarios: a scenario (1) in which the exact cycle of every bus access is known by the SDTA tool and the scenario (2) in which the exact cycle is unknown and we always have to assume the worst case to give safe bounds. Note that, these two scenarios do not affect the IABA case, which always assumes the worst case, but make a big difference in the case of TDMA. Case (1) Exact bus access cycle known: Figure 5.5a shows the WCET degradation (increment) obtained for each EEMBC under a 4-core configuration 77
Chapter 5. Bus Arbitration Policies (a) Nc= 4 cores (b) Nc= 8 cores Figure 5.5: WCET increment when the bus access cycles are known for every request using IABA and different TDMA setups. As a reference case, we use the WCET estimate obtained when the benchmark runs in isolation in the processor so BID = 0. We observe that some benchmarks are barely affected by the bus policy, like a2time,aifir,basefp,idctrn,puwmod or tblook due to their low memory traffic (most of them fit in the L1 caches). 78
5.4 Empirical comparison of TDMA and IABA For the rest of the benchmarks, which show some WCET variability depending on the slot size, selecting the best TDMA slot size is tricky. A short slot size makes the overall window size smaller, so regardless of the cycle in which a requests is ready, it has to wait less to get access to the bus. On the other hand, long slot sizes favor bursty requests, i.e., several requests one after the other, since they can be processed consecutively. In general, TDMA performs better with smaller slot sizes because the access latencies are smaller. More specifically, when slot sizes are such that s < 2r(as we have seen in Section 5.3), which corresponds to s= 2 and 4 in our experiment, the WCET improvement is around 5% for memory-intensive benchmarks. An interesting case is the matrix benchmark for which with s= 6 its WCET is 15% worse than when s= 8, s= 2 and s= 4. This high increment can be explained by the bursty access pattern generated by the benchmark: if more than one request fits into the slot, when we have a burst of requests the second and subsequent requests can access the bus immediately after the first one finishes. As a result, bursty requests take advantage of larger slot size. However, if the second and subsequent requests do not fit into the remaining cycles of the slot, they have to wait till the end of current slot and for other core slots, 3 in this case. The burst pattern generated by matrix fits when the slot size is s= 8, but not for s= 6. This behavior is magnified by the repetitive nature of the benchmark, exacerbating the WCET degradation. We also observe that IABA is close to the best TDMA setup despite the access time of all requests is known, which is useful for TDMA but not for IABA. On average TDMA leads to WCET estimates around 2% lower than IABA, being cacheb the benchmark leading to the highest difference (5.7%). For the 8-core setup, shown in Figure 5.5b, we observe the same trend. The main difference with respect to the 4-core setup is that the WCET variations are greater because of the higher number of bus contenders. We also observe that there is no benefit of that burst-like behavior mentioned before because the beneficial effect of augmenting the slot size is masked by the higher latencies due to the longer window size (now for the same slot size, the window size is doubled in comparison with 4-cores). We also observe the same trend as for 4-cores that for slot sizes s < 2rTDMA performs better than IABA. More precisely up to 6% and 17% on average. Case (2) Exact bus access cycle unknown: If the cycle in which requests arrive to the bus cannot be determined, for instance because the SDTA tool cannot be changed or because it cannot be determined with enough accuracy to provide any benefit, we have to use BIDworst TDMA = (Nc−1) ·s+ (r−1) in the case of TDMA for SDTA. In general, the smaller the value of sis, the better the result. In the best case, s=rand BIDworst TDMA is (Nc−1) ·r+ (r−1). For our 4-core 79
Chapter 5. Bus Arbitration Policies (a) Nc= 4 cores (b) Nc= 8 cores Figure 5.6: WCET increment when the exact bus access cycle is not known. setup BIDworst TDMA = 3r+ (r−1) = 4r−1. With IABA, every request waits for all the other contenders to access the bus, i.e., 3r. Figure 5.6a shows the WCET increment for the 4-core scenario. In general, we observe that IABA is better than TDMA in all cases (7.6% on average), being the improvement in the case of puwmod,cacheb,canrdr,rspeed and a2time higher than 10%. For the 8-core setup, the same trend is observed. Figure 5.6b shows that 80
5.4 Empirical comparison of TDMA and IABA Figure 5.7: WCET increment for ttsprk with different percentage of information. IABA outperforms TDMA by up to 18% and 10% on average. Also for TDMA, as expected, the smaller the slot size the better since a larger slot size means also increasing the worst-case BID. To complete our study, Figure 5.7 shows the WCET increment for the ttsprk benchmark as the percentage of known bus access times varies. This will be the case if the WCET analysis tool can not provide the exact bus access cycle for all the request but only for a percentage of the total number. The 0% case corresponds to the always worst-case scenario (Figure 5.6) and the 100% one to the exact cycle known scenario (Figure 5.5). We observe that the WCET increment for TDMA is inversely proportional to the percentage of access times known. We observe that at least 50% of the exact access times are needed to obtain some gains with TDMA. We observed similar trends when analysing the other EEBMC benchmarks. 5.4.3 Time-bounded Prioritization From Figure 5.5, we observe that some tasks are not affected by the duration of BID while others are significantly affected. This knowledge can be used to reduce the WCET estimate for those tasks more affected by BID (e.g. cacheb) by granting them access to the bus more often, or prioritizing them1. We notice that in this context, prioritization does not mean to flush or stop in-flight requests, or to obtain the bus access immediately, it means only to have more resources assigned than other tasks. With TDMA, prioritization is done by assigning different slot sizes to each task: long slots are assigned to the bus-intensive tasks, leaving the rest of tasks with 1This can be done at hardware level identifying each core, which means that we are not actually prioritizing tasks, but rather cores. 81
Chapter 5. Bus Arbitration Policies shorter slots. For example, we can divide the window in one big slot and several small slots and assign the big slot to a memory-intensive task and the smaller slots to low memory demanding tasks. With IABA, the resource management can be obtained by using a hierarchical round-robin policy, first proposed in [138] and analyzed in [25]: Tasks are divided into groups and subgroups. For example, if we want to prioritize one task T1over other three tasks T2, T3and T4, we make 2 groups, the first one containing T1, and the second group containing T2, T3and T4. Then the arbitration algorithm chooses one of the groups in a round robin fashion. Inside that group tasks are selected also using round robin. The result is that, applying the IABA philosophy, the high priority task, T1only has to wait for one round to get access to the bus (i.e. it obtains the bus once every two rounds), and the other three tasks, have to wait for the accesses of the other two tasks in the second group which are interleaved between the corresponding three accesses of the high priority task. Hence, T2, T3 and T4get access to the bus once every six rounds. Overall, both IABA and TDMA enable thread prioritization. However, TDMA offers finer granularity than IABA. With IABA tasks can access the bus with a frequency limited by the number of groups and subgroups, and the number of tasks in each group and subgroup. For TDMA we can simply adjust the slot size for each of the tasks, at bus cycle granularity. 5.4.4 Time Composability In this thesis, we consider time composability in the sense that the WCET estimate for a task τican be computed in isolation and it is not affected by the other tasks that may run concurrently with τi. Note that time composability and prioritization are somehow opposed metrics. If we prioritize one task’s accesses to the bus, we make this task faster, but the WCET estimates of the other tasks depend on the resources allocated to the prioritized task. It is up to the system designer to define a system cost function to determine which metric is more important, prioritization or time composability. With TDMA, if we keep the window size fixed, time composability is not affected. For example, let’s assume that the case of two tasks, T1and T2, both having a slot size (s) of 5. Further assume that the bus latency of 1 cycle (r). Under this scenario, the worst-case BID is (10 −5) = 5 cycles, no matter what is the schedule of the rest of the tasks. However, if the window size depends on the other tasks’ slot sizes, for example, T2increases its slot size to 6, which makes a window of (6 + 5) = 11, then the worst-case BID for T1is (11 −5) = 6 which affects its WCET. In the case of IABA, if we keep the groups and number of tasks within the groups fixed, time composability is not affected. Otherwise, for example, if we 82
5.4 Empirical comparison of TDMA and IABA Figure 5.8: Average performance improvement of IABA over TDMA change one task with one priority for another one with different priority, then the WCET estimates for the other tasks change, thus losing the time composability. 5.4.5 Average Performance In order to measure the average performance of IABA and TDMA, we run eight 4-thread randomly generated workloads under IABA and TDMA, comparing the performance of each benchmark in terms of IPC (Instructions Per Cycle) under both policies. Note that with TDMA, both at analysis and deployment time tasks are not allowed to use the bus out of their slots. With IABA, instead, at analysis time, each bus access of a task is artificially delayed by BIDworst IABA cycles. At deployment time, when several tasks run simultaneously, no artificial delay is introduced. The only delay tasks suffer accessing the bus are due to actual inter-task interferences. Figure 5.8 shows the average performance improvement of IABA over TDMA in terms of the average IPC improvement of all benchmarks in a workload. IABA provides better performance in all workloads than TDMA because it is a workconserving policy. The improvement ranges from 4% to 16% with an average of 10%. 5.4.6 Discussion Table 5.2 summarizes the different properties analyzed in this chapter for TDMA and IABA. In this table, we use the following symbols: ++ (very high), + (high), −(low), and −− (very low). 83
Chapter 6. Dual-Criticality Memory Controller requests and is defined in Equation 6.7. The ACT-to-ACT time can be limited by the row-cycle constraint, tRC, which defines the interval between ACT to the same bank. In the case of read requests, the time between CAS and PRE commands has to satisfy the read-to-precharge constraint, tRTP , and the minimum tBURST to be able to send the data before precharging. For writes, the write recovery time, tWR, needs to be satisfied before precharging. Annex I in [95] provides a graphical description of the ACT-to-ACT latency depending on the type (read or write) of the previous request. ∆close =max(∆write,∆read) (6.7) ∆write =max(tRCD +tCW D +tBURST +tW R +tRP , tRC ) (6.8) ∆read =max(tRCD +max(tRT P , tCAS +tBURST ) + tRP , tRC) (6.9) Definition 2 Inter-request worst-case interference under open-page, ∆open. The highest (worst) interference that a request suffers from another request in an openpage scheme, ∆open, manifests when both are row-misses and the latter hits a different row in the same bank as the former. ∆open maximizes when all accesses are row-misses. In that scenario, every memory request accesses a row different to the one active in the row buffer, making each request to send PRE, ACT and CAS/CWD commands. The interference corresponds to the PRE-to-PRE time, which has the same timing constraints as the ACT-to-ACT time under close-page. This occurs because the sequence of commands is essentially the same for close-page and open-page when all accesses are row-misses. Thus, close-page and open-page policies have the same worst-case interference [140], i.e. ∆open = ∆close. 6.2.2 Memory Mapping Scheme (MMS) The MMS defines the banks accessed by a request based on its memory address, hence impacting the conflicts that requests have in the access to memory banks. A bank conflict happens when a request waits for another one that is accessing the same bank. The interference that the former suffers, called intra-bank interference, manifests when several requests share a bank. When those requests do not share a bank, they can still have bus conflicts when accessing the memory command and data buses. In that case, the interference is called inter-bank interference. In real-time designs, the MMS is selected to reduce the conflicts among requests, and so reduce request’s interference in the access to memory. To do so, one common choice is the use of a private bank scheme in which each core has exclusive access to certain banks, effectively removing intra-bank interferences across tasks [148]. 90
6.2 Analysis of Memory Access Latency Definition 3 Inter-request worst-case interference under private bank, ∆private. Under private bank, the worst-case interference that a request from a given task suffers from a request of a different task, ∆private, is the inter-bank interference on the access to the command and data buses. Under private bank, assuming that each request comprises the commands PRE, ACT, and CAS/CWD(R/W), commands from different banks are scheduled independently. The inter-bank interference that such a request suffers can be split into the interference that each of those commands suffers independently when accessing the command and data buses [102]: ∆private = ∆P RE + ∆R/W + ∆ACT (6.10) A PRE command can only be interfered by other commands using the command bus, which is given by the time between commands, tCMD. A CAS/CWD command is delayed in the worst-case by another column command sent to another bank, which corresponds to the write-to-read, tWTR, and read-to-write, tRT RS, timing constraints. Annex I in [95] provides a graphical description of the ∆R/W latency. The ACT command is interfered in the worst-case by other ACT commands, due to ACT-to-ACT timing constraints. The time between two ACTs to different banks is limited by tRRD, and a maximum of four ACTs can be issued during the tFAW time-frame, to restrict the peak current. In the last case, the worst-case interference happens when the other command is an ACT command that is the fourth consecutive ACT so that tF AW does not allow the actual ACT to be scheduled: ∆PRE =tCMD (6.11) ∆R/W =max(tCW D +tBURST +tW T R, tCAS +tBURST + tRT RS −tCW D (6.12) ∆ACT =max(tRRD, tF AW −3tRRD) (6.13) However, the use of the private bank scheme in shared memory models makes more difficult the communication among cores. Moreover, with private banks the memory is partitioned regardless of the specific application requirements, so applications with very small memory footprint allocate one bank, resulting in a waste of memory. Finally, the private bank scheme has scalability problems due to the limiting number of memory banks (up to eight in case of DDR3 memories). This can be partially mitigated by using more memory ranks, which allows to have more banks [117]. Under interleaved bank scheme [139,7], data are mapped across all memory banks so that every request accesses all banks simultaneously in a pipelined fashion 91
Chapter 6. Dual-Criticality Memory Controller exploiting bank-level parallelism, and hence removing bus conflicts, or inter-bank interference, among memory requests. For example, in a four-bank interleaved access, four pipelined memory accesses to different banks will be sent per memory request. This scheme is not optimal when the length of a memory request is smaller than the bandwidth of all memory banks because all banks are accessed anyway. We discuss this point in detail in the next section. Definition 4 Inter-request worst-case interference under interleaved bank, ∆interleaved. Given a request, the worst-case interference that another request generates on the former in an interleaved bank scheme, ∆interleaved, is given by the intra-bank interference between command sequences accessing all banks. In the case of an interleaved bank scheme, every request consists of the same precomputed sequence of commands that access all Nbanks banks. The interference that a request generates on another one is given by the time from one sequence of commands to the next one, i.e., the ACT-to-ACT time from requests going to the same bank, which matches Equation 6.7. We need to consider also the timing constraints on the data bus for the different bank access that each request does, tBURST , and the limitation of ACT commands that is imposed by tRRD. For illustration purposes, Equations 6.14 and 6.15 show a simplified version of the exact interference, without considering tF AW , read-to-write and write-to-read effects. The exact interference can be found in [6,139]: ∆interleaved =max(∆ACT BNbanks,∆close) (6.14) ∆ACT B =max(tRRD, tBURST ) (6.15) Definition 5 Inter-request worst-case interference under shared bank, ∆shared. The worst-case interference that a request suffers from another one in a shared bank scheme is the intra-bank interference generated by the latter if both share the same bank, or the inter-bank interference generated by the latter if it goes to a different bank. Equation 6.16 defines ∆shared, where ∆inter, the inter-bank interference, is equivalent to the interference of private bank and ∆intra, the intra-bank interference, is equivalent to the interference of interleaved bank, considering only one bank access. ∆shared =max(∆intra,∆inter) (6.16) ∆intra = ∆interleaved(Nbanks = 1) (6.17) ∆inter = ∆private (6.18) 92
6.2 Analysis of Memory Access Latency Note, that ∆shared is the interference caused by only one request. In the case when several requests can be scheduled concurrently, for instance, requests going to different banks, the worst-case interference includes both, intra-bank and interbank interference, as we show in Section 6.3.2. In that case, both terms are not independent between them and depend on the memory scheduler. 6.2.3 Memory Scheduler The memory scheduler selects the next request to access the memory. It is probably one of the most important components of the memory controller, and the one making the difference between real-time and high-performance designs. In multi-core real-time designs, the scheduler is designed to bound the impact of interferences across requestors, by using predictable arbitration policies, e.g. round-robin [140]. Definition 6 Inter-requestor worst-case interference under round-robin scheduler, ∆rr. The worst-case interference that a request from a requestor i,ri, may suffer from the requests of other requestors under round-robin memory scheduler, ∆rr, corresponds to the case in which all requestors get a request ready in the same cycle and rigets the lowest priority. Assuming Nreq requestors under round-robin arbitration, a request has to wait in the worst-case for Nreq −1 requests, one for each of the other requestors. The effect that each of these other requests has on the former is given by the interrequest interference (∆private, ∆interleaved or ∆shared). For instance, with a private scheme, the worst-case inter-request interference is given in Equation 6.10. For shared bank and interleaved bank, ∆rr is computed by changing ∆private by ∆shared and ∆interleaved respectively. ∆rr private = (Nreq −1) ·∆private (6.19) If instead of a real-time amenable scheduler policy, such as round robin, a high-performance scheduler policy is used, such as FR-FCFS, bounds can still be derived on the memory latency [102], though these are less tight. It is required a reordering term to be introduced in Equation 6.20, which in order to be able to derive meaningful bounds on latency, has to be limited by hardware. In fact, this is the case for the COTS processor analyzed in [102]. That limit is also useful to prevent memory performance attacks [130]. ∆FR−F CF S = ∆reordering + ∆0 intra + ∆0 inter (6.20) 93
Chapter 6. Dual-Criticality Memory Controller Further, with FR-FCFS the prioritization of ready requests when scheduling between banks can have unbounded latency, due to an unbounded ∆0 inter, as shown in [183]. For instance, whenever there are two requestors sending write requests continuously, a read request can have unbounded delay due to the write-to-read constraint. If the write-to-read constraint is bigger than the write-to-write constraint, writes will be ready before the read, thus being sent before the read and delaying every time the read with the write-to-read, tW T R constraint. In [183], authors change the FR-FCFS policy with a FIFO policy to remove this effect. FR-FCFS is a clear exponent of opposing metrics between time-predictability and high-performance, since it improves performance [150] on the average-case, however, the effects that it introduces on the interference bounds affect the predictability of the memory controller in the worst-case. 6.3 Dual-Criticality memory controller (DCmc) High-performance and real-time behavior are somehow opposing goals, since the latter requires reserving hardware resources (either temporally or spatially), which negatively impacts the former. In our space system, these two objectives are structured hierarchically. DCmc focuses on providing time predictability to real-time tasks for their correct operation. Once real-time guarantees are satisfied, available resources are used to maximize the average performance of high-performance tasks. DCmc design pursues the same two hierarchical goals: providing predictable and tight memory access-latency bounds for real-time tasks and maximizing the average memory performance of high-performance tasks. DCmc is driven by two design principles DP.DP1, reducing the interference that high-performance (payload) tasks introduce on the real-time (control) tasks. And DP2, during those periods in which no real-time memory request is processed, maximize the throughput of high-performance memory requests. DP1is achieved by virtually dividing the banks into those serving requests from/to real-time tasks and the rest which serve high-performance tasks’ requests. Bank separation between both application types reduces the interference that highperformance applications introduce on real-time ones. However, bank separation affects Bank Level Parallelism. Interferences across application types are also reduced by prioritizing real-time banks over high-performance ones, such that only if a high-performance request is in-flight by when a real-time request arrives, the latter is delayed by the former. Other than in this case, high-performance requests execute transparently, i.e. without delaying, real-time ones. DP2is achieved by having a memory controller structure in which, during those periods where no real-time requests are processed, high-performance requests can proceed as fast as in high-performance memory controllers, e.g. FR-FCFS. 94
6.3 Dual-Criticality memory controller (DCmc) Figure 6.1: DCmc architecture. ABSchistands for Intra-Bank Scheduler for bank i. EBS stands for Inter-Bank Scheduler. Grey squares show the blocks that communicates with the OS. Hence, instead of arbitrating high-performance and real-time requests with a single scheduling policy, which would trade both metrics, DCmc makes them going to different banks and hence allowing real-time and high-performance requests to be scheduled differently. DCmc architecture is shown on Figure 6.1. The MMS allocates each request into different per-bank request queues. Each bank is defined as real-time or highperformance. The intra-bank scheduler (ABsch) determines the particular commands and their schedule for each bank. The inter-bank scheduler (EBsch) grants access to the memory bus to one intra-bank scheduler at a time. Instead of having a fix separation of banks among real-time and high performance, which intrinsically incurs in inefficiencies in real-time guarantees and high performance, DCmc enables the operating system to configure bank separation at runtime, i.e. to configure each bank as real-time or high-performance. As a result, on each system instantiation the operating system may distribute banks in a different manner to increase efficiency. 6.3.1 DCmc: MMS, RBP, and Scheduler Memory Mapping Scheme. As we have seen on Section 6.2, we can choose between interleaved, private and shared bank schemes. Equations 6.10 and 6.14 show that private and interleaved bank schemes can reduce the interferences, suffering only from inter-bank or intra-bank interferences respectively. Despite its advantages, an interleaved scheme is not compatible with the MMS required to separate the real-time banks from the high-performance ones, since a given request 95
Chapter 6. Dual-Criticality Memory Controller would not be able to access all banks, as required in an interleaved scheme. Also, the interleaved bank scheme is not suitable when the data needed by a request, usually a last-level cache line, requires only one access to a bank, as it happens in most systems [102,42]. In particular, for our system, the NGMP multicore processor, generates requests of 32 bytes [42] and the DDR2 system used provides 32 bytes per bank. This makes more efficient to access only one bank at a time, rather than accessing all of them as it would happen with an interleaved scheme. The hardware-based private scheme lacks scalability due to the reduced number of banks and also has problems with memory usage and enabling the communication among cores as stated on Section 6.2. For DCmc we use a shared bank scheme which is more flexible. With DCmc, as opposed to what was shown in Equation 6.16, a request suffers both, inter-bank and intra-bank interferences, since it competes in the intra-bank scheduler and in the inter-bank scheduler. To be able to enjoy the flexibility of shared bank and the reduced interference of private bank, DCmc uses software bank partitioning [124] by exposing the MMS to the OS. This makes the OS aware of the address-to-bank mapping, which can allocate tasks into a given bank [187,102] with the help of an MMU. For instance, in a system with four memory banks, addresses starting with 0x00, 0x01, 0x10 and 0x11 go to banks 0, 1, 2 and 3 respectively. The OS will map any real-time application data and code into real-time banks so that they enjoy predictable latencies. If a single task is assigned to a given real-time bank, it enjoys the benefits of a private bank scheme. Alternatively, if several real-time tasks are assigned to a given bank, they have a shared-bank scheme. Intra-bank schedulers. The intra-bank scheduler selects the order in which the requests targeting a given bank are prioritized. For real-time banks we use a policy that allows deriving bounds on the interference that requests generate on each other. In particular we use round-robin as in [139], since it is implemented very efficiently on hardware, it has predictable and composable bounds, as shown on Equation 6.19, with small hardware support [138] and also is work-conserving, providing better average case performance than other predictable policies like TDMA [93]. In order to exploit both, Bank Level Parallelism (BLP) and Row-Buffer Locality (RBL) in high-performance banks, DCmc schedules requests per bank, so that it can effectively exploit BLP, and prioritize requests that target open rows, i.e. row hits. Our choice is to use the FR-FCFS [150,102] as scheduling policy, which chooses first row hits (First Ready) and then in arrival order (First Come First Served), that is also used in nowadays COTS processors [102]. This allows high-performance tasks to benefit from open-page policies, that in turn benefit from locality of accesses. Inter-bank scheduler. The inter-bank scheduler is round-robin, which is 96
6.3 Dual-Criticality memory controller (DCmc) applied across the commands selected by the intra-bank scheduler, having realtime banks priority over high-performance ones. Round-robin is applied to ready commands in the case of ACT and PRE commands, but for CAS/CWD commands it will be applied for all commands, whether they are ready or not, with the scheduler waiting in the latter case (instead of issuing the next command in case it was ready). This prevents very high latencies as explained in Section 6.2 and in [183] for FR-FCFS policy. Row buffer policy.DCmc uses open-page in both, real-time and highperformance banks. For high-performance banks, open-page is required to exploit RBL. For real-time banks, we have seen in Section 6.2 that in the worst-case open-page and close-page policies are equivalent in terms of interference (see Equation 6.7). Open-page has predictable latencies and also enables to exploit RBL when using a private bank scheme. Under a shared bank scheme, for real-time banks, all accesses need to be assumed as row misses, since a requestor is not able to know which accesses perform the rest of requestors sharing the bank. 6.3.2 Memory-access latency analysis under DCmc The ultimate purpose of the real-time banks is to enable deriving WCET estimates in the presence of contention in the access to memory. This requires being able to derive upper-bounds on the interference that do not depend on the rest of requestors (tasks), especially the high-performance ones. Under DCmc, Equation 6.1 is redefined as shown in Equation 6.21. The latency of a request, τDCmc, is divided into the intrinsic request latency, τDCmc req , and the interference delay, ∆DCmc. The interference delay is further divided into the interference generated by the real-time banks, ∆rt, and the one generated by the high-performance ones, ∆hp. The real-time interference can be further split into inter-bank interference, ∆rr inter, which manifests in the inter-bank round-robin (rr) scheduler; and intra-bank interference, ∆rr intra, in the intra-bank round-robin scheduler: τDCmc =τDCmc req + ∆DCmc =τDCmc req + ∆rt + ∆hp = τDCmc req + (∆rr inter + ∆rr intra)+∆hp (6.21) The different latencies of a request under an open-page policy are shown in Equations 6.2,6.3 and 6.4. In case other requestors use the same bank or when the analysis tool is unable to analyze the state of the row-buffer, all accesses have to be considered row-misses. If we denote by NRthe number of requestors in the bank: τDCmc req = τhit−row NR= 1 and row-hit τclosed−row NR= 1 and closed-row τmiss−row otherwise (6.22) 97
Chapter 6. Dual-Criticality Memory Controller Following a similar analysis like the one in [102] we upper bound the interference that any memory request can have in DCmc. The inter-bank interference affects the commands sent by the request. In the worst-case, and access consists of ACT, CAS/CWD (R/W) and PRE commands, which under round-robin scheduler, generate a worst-case interference when all the other real-time banks accessing the memory have higher priority. If we have NBreal-time banks, the interference will be NB−1 times the interference suffered by each command independently, equivalent to the interference derived in Equation 6.19: ∆rr inter = (NB−1) ·(∆ACT + ∆R/W + ∆PRE) (6.23) The value of ∆ACT , ∆R/W and ∆P RE is the same as the ones derived for private bank in Equations 6.11,6.12 and 6.13. The intra-bank interference is caused by the intra-bank scheduler, that in our case is round-robin. If we have NRrequestors in the bank, for a round-robin scheduler, the worst-case corresponds to waiting for all the rest of requestors, i.e., NR−1. The worst-case request time that other requests might take is a row-miss also considering the possible inter-bank interference. We need to take into account the row-cycle time, tRC , which is the time between ACT commands to different rows in the same bank, which is also affected by the ∆ACT and ∆P RE inter-bank interference. That is: ∆rr intra = (NR−1)∆lid−req (6.24) ∆lid−req =max((NB−1)∆ACT + (NB−1)∆P RE + tRC,∆rr inter +τmiss−row) (6.25) With DCmc, high-performance banks incur low interference on real-time banks, however, a high-performance request can still cause some interference. The worstlatency, ∆hp, appears when the high-performance memory request is issued just one cycle before the real-time request arrives. If NB< Nbanks, so there are highperformance banks, this may happen. ∆hp causes the same inter-bank bank interference as a real-time request but removing tCMD cycles for each command: ∆hp =Q(∆ACT + ∆P RE + ∆R/W −3tCMD) (6.26) Q=1NB< Nbanks 0 otherwise (6.27) It is clear that the only input parameters of τDCmc are the number of real-time banks, NB, and the number of requestors sharing the same bank, NR, which both are known by the OS at the moment of scheduling the task. It is important to notice that the request latency bound does not depend on the specific behavior of 98
6.4 Evaluation Table 6.1: Worst-case access latencies for a DDR2-667 device (memory cycles). NR 1 2 3 4 NB 127 50 73 96 240 70 100 130 353 96 139 182 456 112 168 224 the rest of contenders, thus enabling deriving time-composable WCET estimates. In Table 6.1 we derive worst-case latencies for different scenarios of NBand NR, assuming that all accesses are row-misses. 6.4 Evaluation In this section, we provide quantitative evidence of the real-time and high performance properties of DCmc. We use the validated simulator presented in Section 3.3 that models the NGMP. The shared second level (L2) cache is split among cores, each receiving one way of the L2, so that inter-task contention only happens on the memory controller. DL1 is write-through and all caches use LRU replacement policy. The bus connecting the cores to the memory controller uses a round-robin arbitration scheme.We model a 2-GB one-rank DDR2-667 [104] with 4 banks, burst of 4 transfers and a 64-bit bus, which provides 32 bytes per access, i.e., a cache line. To derive WCET estimates we use the upper bound delay for the bus, as presented in [138], and the worst-case latency derived in Section 6.3 for memory accesses. The memory access latency analysis can be applied either directly with static timing analysis techniques or by means of a worst-case mode [138] in case of measurement based techniques. Since the L2 is split among cores, it does not have any contention. Space Applications. For the space case study we use a real payload and control applications. As payload we use the OBDP benchmark. As control application we use the AOCS benchmark. Both were presented in Section 3.2.2 Automotive Benchmarks. For the evaluation of DCmc in another application domains we use the EEMBC Autobench suite [143] (see Section 3.2.1). 6.4.1 Intra-bank scheduler DCmc uses a different scheduler per bank type. For the high-performance banks we FR-FCFS, which is deployed in current high-performance architectures due to 99
Chapter 6. Dual-Criticality Memory Controller 106
Chapter 7 Contention-Free Memory System 7.1 Introduction In high-performance domains, memory systems are usually organized into pluggable memory modules which require little space on the motherboard, ease expansion and allow replacing memory modules in case of failure. The main timing characteristic of memory modules is that they are divided into several – up to 8 in current designs – ranks that can be exploited to control contention in memory [117]. However, pluggable memory modules are not common in embedded real-time systems. For instance, in the space domain, having pluggable elements would negatively affect reliability due to the harsh conditions in which these systems are often deployed – e.g. with high vibrations and acceleration. Further, in many real-time systems, including the space domain, it is infeasible to extend or replace failing memory modules once the system is deployed, which diminishes the need for pluggable modules. As a result, memory is usually organized into different memory chips that are soldered to the board. This memory organization typically implements a single rank. Motivation: Our proposal builds on the observation that, when memory is shared (sliced) in time, the impact of memory contention on WCET estimates is high. This occurs because in a mixed-criticality environment where tasks are likely developed by different partners and under different criticality levels, although a task enjoys exclusive access to the memory bus, when the bus is relinquished and assigned to a new task, the latter can make no assumption on the state left in memory by the previous task. For instance, the new task does not know whether the previous access was a write or a read, and since write-to-read and read-to-write timing constraints are greater than read-to-read and write-to-write, the new task has to assume that the previous task made an operation on the opposite direction (i.e., the previous task carried out a read and the new one a write or vice versa). 107
Chapter 7. Contention-Free Memory System As a result, the new task makes – for each request – worst-case time allowances to account for the memory state left by the last task using it. This maintains time composability though increases the allocations made in the new task’s WCET estimate. Contribution: Instead of allowing that each task accesses all memory devices simultaneously to enjoy a wide data bus and time-sharing the memory system, which leads to pessimistic WCET estimates, our proposal uses narrower data buses (private to each task) each providing access to different memory devices, while the address bus is shared. With our space-sharing approach we heavily reduce the memory contention among tasks by dividing the available memory data bus to provide independent memory data buses accessing different memory chips that do not interfere each other. Dividing the data bus requires no changes on the memory device but only few extra processor pins. This approach requires more memory transfers to complete a memory transaction which reduces available percore bandwidth when compared with wider data buses. However, this penalty is reduced since the locality of the memory row-buffers is completely exploited because the extra transfers needed are always sequentially ordered. The net result is a small reduction on average performance that pays-off for having a heavily reduced memory contention, leading to tighter WCET estimates. Tight WCET estimates are key in critical real-time systems, since they are directly related to hardware provisioning made to ensure that time critical tasks finish before their deadline. The main properties of our memory organization are as follows. (i) It significantly reduces the impact of memory-contention on WCET estimates, which are less affected by high core counts and processor frequency in comparison to time-sharing approaches; (ii) it uses standard memory technology, i.e. commercial off-the-shelf (COTS) memory chips, deployed in other domains; (iii) it maintains time composability allowing to use single-core timing analysis tools; and (iv) it provides flexibility for mixed criticalities such that the memory can be easily configured to satisfy different real-time and performance needs. We assess the benefits of our proposal and compare it with state of the art memory controllers both analytically and quantitatively in the context of a space case study with real space applications on a simulator validated against real boards. We focus on an on-board-soldered memory setup where chips are organized as a single rank and are accessed in parallel through a single channel. Our proposal reduces contention by 35% and 51% with respect to private and shared memory schemes respectively, having a 2% average performance penalty with respect to other memory controllers. The rest of this chapter is organized as follows: Section 7.2 presents the motivation of our work. In Section 7.3, PDSC is proposed. Section 7.4 presents 108
7.2 Motivation the evaluation. Sections 7.5 and 7.6 explain the related work and the summary respectively. 7.2 Motivation Memory modules are usually plugged on the board to reduce the amount of space on the mother board dedicated for memory while easing memory expansion and replacement of failing modules. However, memories in real-time systems, as happens in many space, avionics or automotive systems, are neither designed to be upgraded nor fixed in case of failure once the system is in operation, so there is no need for interchangeable modules. Also modules and their connectors suffer mechanical stress due to severe vibration/acceleration environments, challenging their suitability for this kind of systems. As a result, in many real-time systems memory is not organized into modules but memory chips are directly soldered on the board. This setup is called memory-down [82] and is shown in Figure 7.1a. Furthermore, the use of multiple ranks is challenged in embedded memory-down systems since it requires extra space and weight on the board [88], critical parameters for embedded systems. For these reasons, single-rank memory-down configurations are used in the space domain which is the focus of this chapter. In the absence of multiple ranks, we observe bank-conflicts and channel-conflicts. Bank-conflicts are caused by the timing constraints between commands going to the same bank, like the act-to-act constraint (tRC), precharge time (tRP ) and by row-misses when using an open-page policy. Channel-conflicts are caused by the timing constraints between commands going to different banks in the same devices, thus, using the same channel. For instance the write-to-read (tW TR) and read-to- read (tBURST ) constraints affecting the timing of read/write requests even if they target different banks. When using a shared-bank scheme [140], in which tasks are mapped into the same banks, bank-conflicts dominate over channel-conflicts. When using a private-bank scheme, in which tasks use their own banks, as proposed in [183,148], bank-conflicts are removed. However, the WCET degradation is still high because of channel-conflicts. Authors in [117] identify the problem of channel-conflicts and propose a memory controller that reduces them by using multiple ranks. However, such an approach based on multiple ranks cannot be applied to many embedded systems using a memory-down setup since they often implement only one memory rank. An effective way to remove conflicts would be by deploying a multi-channel memory system [73] in which each task uses a private channel with different memory interfaces and devices. In this case, the memory system is neither shared in time nor in space, since each task uses different interfaces and devices at the same time. However, such a solution would require hundreds of processor signals to 109
Chapter 7. Contention-Free Memory System have separate memory interfaces. For instance, the NGMP processor [42] uses a 625 pins package, out of which around 300 are usable to manage processor I/O whereas the remaining pins are devoted to power/ground, etc. A complete multichannel solution would require 544 pins which is completely out of reach. Hence, for scalability reasons, a unique memory interface (channel) needs to be shared between cores due to the limited amount of processor signals. To reduce the impact of contention on shared memory interfaces, current solutions time-share it among the tasks running in the multicore. 7.2.1 Requirements Memory-down systems face several requirements to enable their safe use in multicore systems. Although these are presented in a space-centric manner, other domains such as automotive have similar ones, and hence similar solutions apply. Tight WCET estimates. As seen before, bank and channel conflicts have high impact on WCET estimates, specially bank-conflicts. These conflicts should be avoided in order to derive tight WCET estimates. Factoring memory contention in WCET estimates. The memory system has to simplify factoring the impact of memory contention in the WCET estimates provided by timing analysis tools without requiring the latter to be changed. Mixed-criticaility. In the space domain, on-board systems comprise two criticality levels [142], control and payload. Control tasks have real-time constraints and require meeting tight WCET estimates. Meanwhile, payload tasks have soft or no real-time constraints, which makes them high-performance driven. The memory design has to provide mixed-criticality flexibility, so that it provides high average performance when no real-time execution is required and guaranteed performance for real-time tasks. COTS technology. In general the use of COTS technology helps reducing non-recurring costs. In the space domain, while processor design can be changed to accommodate hardware support for real-time systems [40], non-customised (COTS) memory devices are preferred in order to reduce costs. Although these requirements are specific of the space domain, other domains such as automotive and avionics have similar constraints, thus, similar solutions apply to all of them. 7.3 Private-Data bus Shared-Command bus We propose Private-Data bus Shared-Command bus (PDSC) memory organization, which removes contention between tasks by dividing the available data bus into private independent data buses for each task, that target different memory 110
7.3 Private-Data bus Shared-Command bus (a) Original setup sharing CS and DQS (b) Proposed setup with different CS and DQS Figure 7.1: Original and proposed 64-bit memory-down system devices, while sharing the command bus. PDSC removes contention between tasks since they are prevented from sharing the same data bus. The split of the data bus is done in a smart way such that COTS memory chips can be used. In particular, in our reference processor, comprising four cores and a 64-bit memory interface, PDSC divides the 64-bit data bus into four 16-bit buses, one for each core. The command bus is time-multiplexed for the different data buses, which means that the address and command bus is shared between cores, so that contention, or inter-task interferences, only happens on the command bus. Such contention is minimal, since only 1 bus cycle (tCMD = 1) is needed to send commands. Hence each memory device can receive one command every four cycles. Dividing the data bus incurs low overhead in memory-down configurations. The Chip Select (CS) and Data Query Strobe (DQS) signals indicate to a DRAM device when a command and the data are ready respectively. In the original 64-bit bus design, one CS and DQS signal is used for all the 4 devices so that they work simultaneously, as seen in Figure 7.1a. In our 16-bit design with four buses, each 111
Chapter 7. Contention-Free Memory System (a) 64-bit data bus (b) 16-bit data bus Figure 7.2: Equivalent transfers. one accessing one memory device, we only require to wire three extra CSiand DQSisignals, one for each extra data bus added, as presented in Figure 7.1b, which follow the same physical route as the original CS and DQS signal. These extra signals require few extra processor pins, that in our case incur a small cost since the processor we model, the NGMP [42], has about a dozen pins available. This is in contrast to a complete multichannel solution that in the NGMP would require 544 user-defined pins, hence making it infeasible. PDSC requires more transfers to complete a memory transaction: A memory transaction brings 256 bits, which corresponds to a last-level cacheline, and requires only one transfer on the 64-bit bus since the memory has a burst of 4, i.e., 4×64 = 256 bits, as seen in Figure 7.2a. With a 16-bit bus PDSC needs four memory transfers to get the 256 bits, i.e., 4 ×(4 ×16) = 256 bits. For instance, with a 64-bit bus we need one transfer to get the 256-bit memory block at 0x00 (bytes 0x00 to 0x1F). With a 16-bit bus we need four transfers, at 0x00,0x08,0x10 and 0x18 that bring 64 bits each. Hence, for every memory transaction, PDSC performs four sequentially ordered transfers, which allows exploiting the memory locality that offers the row-buffer using an open-page policy [183]. The first transfer can be a row-hit or row-miss, depending on the previous transaction, while the following three transfers are always row-hits. Since they are always row-hits, their latency tCAS = 6 (memory cycles) overlaps with the first transfer, thus performing those transfers immediately one after the other. Note that we rely on the fact that any cacheline is mapped consecutively on a single memory row. In this case, every extra transfer only has to consider the command bus multiplexing and the transfer time on the bus (tBURST = 2 cycles), since the read or write latency is overlapped between sequential transfers. An example of these accesses is shown in Figure 7.2b for a read. The hardware cost of PDSC is similar to most tailored memory controllers [140, 183,7], also requiring multiple queues and a command translator, which converts requests into the corresponding commands and keeps track of the open rows and refresh counters. PDSC deploys a command bus scheduler to share the command 112
7.3 Private-Data bus Shared-Command bus bus and a command translator to keep track of the open rows for each data bus. Despite the use of multiple ranks is not common in memory-down setups, PDSC can also work with multiple ranks. While having ranks reduces channel conflicts [117] there are still conflicts that are caused because of the rank switching time. PDSC would allow to further remove contention, while having multiple ranks on each private data bus, which allows increasing memory bandwidth. 7.3.1 Configuration Options PDSC can be configured to provide either increased average performance or increased guaranteed performance to respond to the asymmetric needs of mixedcriticality applications. We propose different configurations (modes) for PDSC, that use different addressing schemes and are configurable by software: RT,HP and MIX. RT uses four independent 16-bit data buses to provide guaranteed performance, intended for real-time tasks. PDSC causes, in this mode, an average performance penalty for dividing the data bus as stated before. In HP the average performance penalty of RT is reduced by interleaving the four 16-bit data buses [73]. When the four 16-bit data buses are interleaved, the four accesses needed per transaction are carried out by interleaving one access per data bus, thus using all of them at the same time. In this scenario, average performance is the same as with the original 64-bit bus, except for the time switching of the command bus that introduces a small penalty (2% in our setup). Under the MIX configuration, we can have half of the memory working with independent channels, and the other half working with interleaved channels, so that tasks targeting guaranteed performance can be scheduled with tasks targeting average performance. For that purpose, two of the data buses are accessed as a private data bus each one, and the other two data buses are interleaved. The latter two data buses are accessing the same data and suffer interference. As explained before, the memory space is divided into four equal segments, one for each data bus in the system. The data bus partitioning is done by software, similarly to the software bank partitioning [124] and requires a Memory Management Unit (MMU). The OS configures the MMU so that each core targets the appropriate memory region: real-time applications target their own data bus. For other applications the OS decides which data bus they can access by configuring the MMU. The flexibility obtained by interleaving the data buses incurs a small hardware cost due to the complexity introduced in the data path that connects the data bus with the corresponding memory request. Further, PDSC modes can be easily configured at boot time: Each processor instance is used as part of a different system function. Each of those functions may have different high performance 113
Chapter 7. Contention-Free Memory System and real time requirements that can be accommodated with PDSC through its modes. PDSC could also be configured dynamically though this would cause data movement among memory regions. 7.3.2 Scalability The presented PDSC memory controller fits the needs of our space case study. Processor designs [99,137] with higher core counts usually deploy clustered architectures, which organize processor resources into “islands of execution”, i.e., subsets of processors. In general, clustered architectures provide better scalability than flat architectures, higher degree of isolation across clusters, which is good for real-time, and reduced complexity. For this reason, when it comes to scaling to larger systems, we consider a clustered processor design. We divide the available memory interface into several data buses and assign one bus per cluster of cores. Each cluster has a private data bus, so contention occurs between cores within a cluster but not across clusters. Contention between cores within a cluster can be handled by using predictable arbitration policies such as round-robin [140] and reduced by using private-bank schemes [183,148], since these techniques are orthogonal to our proposal. It is worth highlighting that PDSC also applies to other real-time domains, besides space, with needs for high memory mixed-criticality performance (e.g. automotive and avionics domains). PDSC, with its flexibility and scalability, would help handling the memory contention issue. 7.4 Evaluation We use a solid evaluation setup based on a simulator validated against a real NGMP implementation (see Section 3.3). We use real space applications, control and payload [142]. As control application we use the AOCS and as payload we use the OBDP. For the evaluation in other application domains we use the EEMBC Autobench suite [143] (all benchmarks are described in Section 3.2). We derive WCET estimates using measurements with hardware support to force requests to work on their longest latency for the on-chip bus [138]. The L2 cache has fixed access times, since it is split among cores. Single-core timing analysis tools can be used with PDSC since it offers composable memory access latencies. Thus, the memory has the same behavior as in a single-core system. Worst-Case Performance. We compare PDSC with the most relevant related work: a shared-bank approach [140] and a private-bank approach [183] (details on these approaches are provided later in Section 7.5). We also consider a multichannel solution in which each core has its own 64-bit memory channel, i.e., 114
7.4 Evaluation Figure 7.3: Normalized WCET for shared-bank, private-bank, private-channel and PDSC. private-channel, thus no memory contention (i.e., bank and channel) is observed, only the bus contention is present. Despite such a solution would require hundreds of extra processor pins – posing an unaffordable cost for our reference processor – we use it as an optimal reference design since it removes contention because channels are completely independent1. Figure 7.3, shows the WCET normalized with respect to the WCET obtained with the original memory system, i.e., 64-bit data bus, when running in isolation without interference. These WCET are obtained in isolation for each task and take into consideration the worst-case that any workload this task runs in could generate. Results are shown for AOCS kernel, three representative EEMBC with varying cache behavior (aifftr with low L2 miss rate, puwmod with high L2 miss rate and cacheb with a L2 miss rate close to the average) and the average for all EEMBC benchmark suite. We observe that PDSC obtains 33% tighter WCET estimates for AOCS in comparison with a private-bank scheme and a 49% with respect to a shared-bank scheme. In comparison with the private-channel, PDSC is only 10% worse than this ideal solution. Interestingly private-channel WCET is 20% bigger than when the application runs in isolation which is caused by the contention on the on-chip bus. Similar results are obtained for EEMBC on average. The private-bank suffers a slowdown of 110% because, despite banks are private to each task (each one pinned to a different core), tasks suffer contention on the data bus – removed with PDSC. On average, including all EEMBC benchmarks and AOCS, PDSC leads to 35% tighter WCET estimates than the private-bank scheme and 51% than the shared- 1Even a 16-bit multichannel solution would require more than hundred pins due to the percore 32 bit address and control signals. 115
Chapter 8. A Probabilistically Analyzable Multicore Processor In this chapter, we describe for the first time a complete PTA-compliant multicore processor design. In particular, we propose new low-cost PTA-compliant bus designs that break (1) the deterministic behavior of the bus and (2) the dependence of a given application execution time’s on the behavior of co-hosted applications by means of randomized arbitration policies. Analogously, following the same principles we propose a memory controller design with randomized selection of memory requests. The contributions of this chapter are as follows: •Lottery arbitration bus: Under this bus arbitration [118], on every round the arbiter selects one core to access the bus randomly. This breaks any dependence between applications, but makes that a request may have to potentially wait an infinite number of arbitration rounds to be granted access to the bus. •Randomized-permutation arbitration bus: We propose this new bus arbitration policy under which every Nrounds, where Nis the number of bus contenders, the arbiter generates a random permutation for the contenders. That sequence determines when each contender can use the bus. This arbitration provides an upper-bound to the number of rounds a request has to wait and leads to tighter pWCET estimates than the lottery arbitration bus. •Memory: We identify the two factors that affect the execution time of requests in memory, namely, the memory issue delay and the intrinsic execution time of a memory request. While the latter can be easily upper-bounded based on the DRAM memory parameters, the former depends on the number of cores sending requests to a given memory controller and the arrival time of requests from all cores. To probabilistically model the effect of the issue delay, we apply both lottery and randomized-permutation arbitrations in the policy that selects from which core the next memory request is to be processed. Overall, our results prove that our proposed multicore designs (i) fulfil PTA requirements by using proper independence and identical distribution tests, (ii) allow deriving pWCET estimates with exactly the same methods and tools as for single-core processors, thus keeping timing verification costs low, and (iii) achieve much higher guaranteed performance than single-core processors. In particular, our sensitivity analysis shows that the hardware block with the largest impact in guaranteed performance for our multicore architecture is the number of cores that contend for a memory controller. If the core count per memory controller does not exceed 4, we can achieve reasonable scalability in guaranteed performance: 2.6x average (up to 4.0x) in an 8-core architecture and 4.9x (up to 7.9x) in a 16-core architecture with respect to a single-core baseline architecture. 122
8.2 Background The rest of this chapter is organized as follows. Section 8.2 provides background on PTA and the current hardware designs for single-core PTA-compliant architectures. Section 8.3 introduces PTA for multicores. Section 8.4 presents our PTA-compliant bus designs. Similarly, Section 8.5 presents our PTA-compliant memory controller design. Section 8.6 presents the main results of this chapter. Finally, Sections 8.7 and 8.8 present the related work and the summary of this chapter. 8.2 Background 8.2.1 PTA The probabilistic timing behavior of a program or an instruction (or in fact any component) can be represented with an Execution Time Profile (ETP). An ETP defines the different execution times of a program (or latencies of an instruction or a particular resource) and their associated probabilities. That is, an ETP represents a probability distribution function, see Equation 8.1, where piis the probability of the program/instruction/component to take latency li, with Pk i=1 pi= 1. ETP ={→ l,→ p}={{l1, l2, ..., lk},{p1, p2, ..., pk}} (8.1) The convolution function is used to combine ETPs, leading to a new ETP in which all possible pairs of execution times from the two ETPs are added and the probabilities multiplied. For example, let E1={(2,101,200),(0.1,0.4,0.5)}and E2={(2,101),(0.6,0.4)}be two ETPs. Then their convolution is: Er={{2+2,2 + 101,101+2,101+101,200+2,200+101}, {0.1×0.6,0.1×0.4,0.4×0.6,0.4×0.4,0.5×0.6,0.5×0.4}}. And given that 101 + 101 = 2 + 200 we collapse duplicate pairs resulting in: Er={(4,103,202,301),(0.06,0.28,0.46,0.2)}. 8.2.2 PTA requirements on hardware design PTA techniques require that the events under analysis, program execution times for MBPTA and instruction latencies for SPTA, can be modelled with i.i.d. random variables [32]: two random variables are said to be independent if they describe two events such that the occurrence of one event does not have any impact on the occurrence of the other event. Two random variables are said to be identically distributed if they have the same probability distribution function. 123
Chapter 8. A Probabilistically Analyzable Multicore Processor The existence of an ETP ensures that each potential execution time of the program (for MBPTA) or instruction (for SPTA) has an actual probability of occurrence, which is a sufficient and necessary condition to achieve the desired i.i.d. execution time behavior [32]. A difference between SPTA and MBPTA, besides the level of abstraction at which ETPs are to be constructed, is that while SPTA requires ETPs for each instruction to be determined, MBPTA simply needs those ETPs to exist, but not necessarily to be known. How to use those ETPs in the context of SPTA and their meaning in the context of MBPTA is beyond the scope of this thesis. We refer the interest reader to [4] for further details on this topic. Summary: Overall, a SPTA- and MBPTA-analyzable multicore must provide the following properties: SPTA: SPTA requires the i.i.d. hypothesis to strictly hold at the instruction level. Hence SPTA requires deriving ETPs for each instruction and that the timing probability distribution captured by the ETP of an instruction jfrom a task Tk (iTk j) is independent of the behavior of any other instruction from any other task iTm l. If we use the core design in [110], which has been proven to be PTA-compliant, inter-core resources (e.g. bus and memory controller) have to be designed such that each potential latency that a memory access may experience must have an associated probability of occurrence, and this probability has to be independent of the accesses generated by other tasks. MBPTA: The observed execution times fulfil the i.i.d. properties if observations are independent across different runs and a probability can be attached to each potential execution time. To that end, it is enough if we make the events that may affect the execution time of a program random events whose probabilities are independent of the execution of any other program. Hence, taking measurements from a program is equivalent to rolling a dice, with each face having a probability of appearance. Making enough rolls is enough to apply MBPTA, which derives upper-bounds of the execution time distribution by means of Extreme Value Theory (EVT) [115,46]. For MBPTA, it is also enough to show the existence of ETPs for each instruction, since the existence of the ETPs for each instruction ensures that any different execution time of the program have an associated probability and therefore MBPTA can be applied. ETPs, however, cannot be derived with standard (deterministic) processor architectures since events affecting execution time (e.g., bus access policy) on those architectures cannot be attached a probability of occurrence. In a multicore, ETPs cannot be obtained due to the deterministic nature of the bus arbitration policy and the deterministic processing order of requests in the memory controller. This impedes execution times of memory instructions (e.g. load/store) to be modelled with i.i.d. random variables, thus preventing the use of PTA. Hence, the focus of 124
8.2 Background Figure 8.1: Block diagram of the PTA-compliant core architecture used in [110]. this chapter is devising bus and memory controller designs amenable to PTA. 8.2.3 Single-core Probabilistically analysable hardware designs The basic principle to design probabilistically analyzable hardware is to control the sources of execution time variation (i.e. jitter) [32,46]. Jitterless resources have a fixed latency, independent of the input request or of the previous history of requests accessing that resource. Jitterless resources (e.g. integer adders) are easy to model: its ETP has a single latency with probability 1. Resources with jitter, or jittery resources have a variable latency. Their latency depends on the execution history of the program or on the particular request sent to that resource. Jittery resources have an intrinsically variable impact on the WCET estimate for a given program. Jittery resources are either (i) enforced to always respond on their worst-case latency, so their upper-bounded timing behavior also becomes i.i.d., or (ii) redesigned so that their timing behavior depends on random events. Following this approach [110] proposes a PTA-compliant single-core pipelined core architecture, see Figure 8.1. The architecture comprises fetch (F), decode (D), execute (E) and write-back (WB) stages. In between all stages there are latches or queues. Additionally, the WB stage comprises a write buffer in which stores are put until they are sent to cache. Loads are processed in program order in the execute stage. The accesses to the instruction and data caches happen in the fetch and execute stages respectively. Note that this pipeline design is similar to LEON3/LEON4 designs given that core operations have a fixed latency. Data and instruction caches deploy random placement and random replacement policies [110] as needed to satisfy PTA requirements. A fixed-latency memory controller (mc) serves as the bridge between caches and memory. 125
Chapter 8. A Probabilistically Analyzable Multicore Processor 8.3 PTA in multicore systems Multicores offer better performance per watt than single-core processors while maintaining a relatively simple processor design. Moreover, multicore processors enable co-hosting applications with different requirements (e.g., high data processing demand or stringent time criticality), reducing the overall size, weight and power costs. Despite these advantages, multicores have not been widely adopted yet in embedded markets with real-time needs due to the difficulties to analyze the complex timing behavior of applications on top of multicores. These difficulties emanate from inter-task interferences when accessing shared resources. Inter-task interferences appear when two or more threads sharing a hardware resource, access it simultaneously. An arbitration mechanism determines which contending task is granted access to the shared resource, which affects the execution time and the WCET of running tasks. Our objective is to design a multicore processor in which we can probabilistically model inter-task interferences as a way to enable probabilistic timing analysis of multicore processors with the same degree of complexity as in single-core ones. Therefore, our designs must also work with existing PTA tools [46]. Finally, we want to maintain simplicity in our hardware designs. 8.3.1 Clustered multicore architectures Historically, clustered architectures have been considered in computer architecture. At the processor core level, execution pipelines are split into clusters (e.g. the IBM POWER7 [98]) to decrease hardware cost while efficiently exploiting instructionlevel parallelism. At the chip level, processor implementations of many-core architectures (e.g. ARM Cortex A15 MPCore [12]) may group several cores into clusters as a means to reduce implementation costs. Besides, clusters enable voltage and frequency scaling as well as power-gating at the granularity of several cores, since having those mechanisms on a per-core basis has high hardware cost [132,87]. In both clustered and non-clustered multicores the interconnection network is one of the most critical resources affecting the performance of tasks. In this chapter, we use a baseline clustered architecture as shown in Figure 8.2, where cores are equipped with private data and instruction caches. We evaluate our designs in a wide range of setups in which we vary the number of clusters and the number of memory controllers. 8.3.2 Inter-task interferences In single-core architectures, the execution time of a task is influenced by (1) the initial processor state when the task starts its execution –which in turn is affected 126
8.3 PTA in multicore systems Figure 8.2: Baseline multicore architecture considered in this chapter. ‘c’ stands for core, ‘s’ for switch and ‘mc’ for memory controller. by previously executed tasks–, (2) the Operating System (OS) interferences, (3) the input data of the task and (4) the randomization carried out in some processor resources. The effect of initial conditions can be taken into account by flushing the state of the stateful resources (e.g., caches) prior to the execution of the task. At OS level, solutions have been shown to make the OS-induced jitter probabilistically analyzable [128], hence covering (2). The effect of input data on the execution paths followed by the program or data-dependent instructions, (3) above, is also under control by PTA techniques [32,46]. Analogously, the jitter introduced by the randomized hardware resources is also taken into account by PTA techniques [32, 46]. In multicore architectures, in addition to all these sources of execution time variability, an additional one arises: inter-task interferences. In single-core architectures, given two instructions ixand iyof the same program, where xand ydetermine the order in which each instruction is fetched into the processor, iy may have a potential impact on the execution time of ixonly if y < x, meaning that iyexecutes prior to ix. In a multicore, when several tasks run in a multicore architecture, the execution time of one instruction iT1 xbelonging to task T1may be affected by any other instruction iT2 yfrom a task T2. If there is precedence ordering in task execution such that T2executes after T1, then the inter-task interferences generated by iT2 ydo not affect iT1 x. If there is not precedence execution ordering, T1and T2can execute in any order. In particular, they can execute concurrently in different cores, so iT2 ymay introduce inter-task interferences affecting iT1 x. It becomes then evident that we cannot take into account the effect that any instruction of any task iT k j, may have on any other instruction of any other task iTm l. This would simply make the usage of the probabilistic approach intractable. To break this dependence we design our multicore such that we make that the worst effect that one task can have on the execution of any other task due to inter-task interferences can be probabilistically bounded. This makes our design time composable, meaning that the pWCET estimate obtained for a given task is 127
Chapter 8. A Probabilistically Analyzable Multicore Processor independent of the tasks that may run concurrently in the processor. Overall, our multicore platform is designed so that every individual processor instruction can be characterized by a distinct ETP that has no dependence on any instruction of any other task. Next, we present the proposed bus and memory controller designs, which allow deriving an ETP for each instruction independently of any other task. 8.4 On-chip interconnection network As we have seen, in the processor core architecture proposed in Section 8.2, core operations have a fixed latency except for the access to the instruction cache (IL1). Memory operations, in addition to the execution time variation they have due to their instruction cache access, are also affected by the access to the data cache (DL1). For each access to the DL1 or IL1 we can derive a probability of hit [110]. In general, for a cache with Ssets and Wways, given the sequence < Ai, B1, ..., Bk, Aj>, where Aiand Ajcorrespond to accesses to the same cache line and no Bl(where 1 ≤l≤k) accesses the cache line where Ajis, the probability of Ajto hit in the cache can be approximated as [110]: PhitAj(S, W)= 1−W−1 W l=k P l=1 PmissBl · 1−S−1 Sk!(8.2) Such hit probability is used to compute the ETP of each cache access as follows where lathit and latmiss are the cache hit and miss latency respectively: ETPcache ={{lathit, latmiss},{PhitAj(S, W),1−PhitAj(S, W)}} (8.3) On the event of a miss in the instruction or data cache, the missing instruction generates an access to the shared bus hierarchy. Next, we present several bus architectures and their corresponding probabilistic analyzes. The resulting ETP for each bus should be composed with the miss part of the ETPcache. For instance, if the ETP of the bus is ETPbus ={{l1, l2, l3},{p1, p2, p3}}, the resulting ETP of composing cache and bus effects would be: ETPcache ={{lathit, latmiss +l1, latmiss +l2, latmiss +l3}, +bus {Phit,(1−Phit)·p1,(1−Phit)·p2,(1−Phit)·p3}} (8.4) 128
8.4 On-chip interconnection network 8.4.1 Lottery bus We define an arbitration round or simply round as the number of processor cycles that a core needs to send any request to the bus. In this approach, on every round the arbiter selects one core to access the bus using a random policy. A similar bus was analyzed in [118]. However, unlike [118] we assume that all bus contenders have always pending requests, although in a given cycle, only a subset of the contenders may have pending requests. This assumption makes our design time composable, and hence independent of the traffic generated by each contender. Otherwise, ETP for memory operations of one task would depend on the traffic generated by other tasks, breaking the desired i.i.d. timing behavior. In a Ncore single-bus processor, the probability of a request to be selected in round k+ 1 is given by Equation 8.5, where the first element is the probability of the request not being granted access in the first krounds and the second element the probability of being selected in the k+ 1 round. pk lotarb =1−1 Nk ·1 N(8.5) Blue diamonds in Figure 8.3 show the probability of a bus request not to be granted access after karbitration rounds for a bus shared by 4 cores. We observe that the larger the number of rounds in which a contender participates, the lower its probability not to be selected. There is a probability the contender not to be granted access after a large number of rounds. However, this probability decreases exponentially and more importantly, it is probabilistically computable. If arbitration rounds have durations longer than 1 cycle, say Lcycles, then a request may become ready in the middle of a round. In that case, the request has to wait until an arbitration round boundary before it can compete to get access to the bus. Equation 8.6 shows the ETP for a bus access. (1) The first element convolved in the equation is the delay to align the request with the cycle at which the next round starts. A bus access request is initiated on a miss to the data or instruction cache. Given that the event ‘cycle in which an access misses in the data or instruction cache’ is a random event (and hence so is the cycle in which the access to the bus happens), the probability of a bus request to arrive in a particular cycle can be computed. In particular, every request to the bus may arrive in any cycle of the arbitration round (0, ..., L −1) with a given probability pcyci to arrive in cycle i with 0 ≤i≤L−1. Note that for the ETP it does not matter whether pcyci follow any particular distribution as long as it is probabilistic. (2) The second element convolved is the number of rounds that the request waits. Each round has Lcycles and Equation 8.5 is used to compute the probability 129
Chapter 8. A Probabilistically Analyzable Multicore Processor Figure 8.3: Probability of not being granted access as a function of the number of arbitration rounds for a bus with 4 cores. of a request to be selected in a given round. (3) Finally, the last element convolved is the actual latency of the bus access request: it takes L cycles with 100% probability. ETPbuslot ={{0,1, ..., L −1},{pcyc1, pcyc2, ..., pcycL−1}} ⊗ {{0, L, 2L, ...},{p0 lotarb, p1 lotarb, p2 lotarb, ...}} ⊗ {{L},{1}} (8.6) 8.4.2 Randomized permutations An arbitration window or simply window refers to Nconsecutive bus arbitration rounds. Under this arbitration policy, in each window one round is randomly assigned to each of the Ncontenders. Each round has a duration of Lcycles, the maximum bus cycles that any request may take. In this approach, at every window boundary the arbiter generates a random permutation for the Ncontenders (cores). This sequence determines the order in which contenders can use the bus. Analogously to the fact that the arrival cycle of a request in a round follows a given probability distribution function, there is a probability defining the round in a window in which requests arrive. This occurs since the accesses to the bus are initiated on random events: miss to the data or instruction caches. As explained before, we do not care which particular distribution function this is as long as it is probabilistic. Without lost of generality and for the purpose of this explanation we assume that the probability function describing the arrival round of each request is 130
8.4 On-chip interconnection network uniform, that is, there is a probability 1 Na request to arrive in a particular round1. We identify the following extreme cases: •The shortest delay (0 cycles) occurs when a request becomes ready right when the core it belongs to gets its round. •The worst delay occurs when (i) a request belongs to a core that gets the first round in the current permutation and (ii) the last round in the next permutation, and (iii) the first round of the current permutation has just elapsed. In this case, the request should wait 2N−2 rounds corresponding to the N−1 remaining rounds of the current permutation and the first N−1 rounds of the next one. The probability of a request to wait krounds to get access to the bus, with 0≤k≤2N−2 is as follows: pk perarb =max(N−k, 0) N2+ min(N−1,2N−k−1) X i=max(1,N−k) i N3(8.7) The first addend in the equation is the probability of finding the appropriate round in the remaining part of the current permutation, whereas the second part stands for the probability of finding the appropriate round in the next permutation if and only if such round was not found in the current permutation. Figure 8.3 shows the probability of a bus request not to be granted access after karbitration rounds. We observe that after 2N−2 rounds, the probability not to be selected is 0. The ETP of the random permutation bus, see Equation 8.8, is obtained as the convolution of three components, as for the lottery bus. The first component in the convolution is the time and associated probability to align the request to the start of the next round; the second one stands for the waiting rounds until the request is granted access, and the final one stands for the actual bus access latency of the request. ETPbusper ={{0,1, ..., L −1}{pcyc1, pcyc2, ..., pcycL−1}} ⊗ {{0, L, ..., k ·L, ..., (2N−2) ·L}, {p0 perarb, p1 perarb, ..., pk perarb, ..., p2N−2 perarb}} ⊗ {{L},{1}} (8.8) 1With a similar processor setup, our results show that the arrival of bus requests across rounds in the window is uniform (see Figure 5.3 in Chapter 5). 131