scieee AI-readable full text Open interactive document viewer

Design and implementation of approximate computing systems

Pérez Hernández, Sergio

Abstract

Grado en Ingeniería Informática

Full text

Universidad de Valladolid Escuela de Ingeniería Informática TRABAJO FIN DE GRADO Grado en Ingeniería Informática (Mención en Computación) Design and Implementation of Approximate Computing Systems Autor: D. Sergio Pérez Hernández Tutor: D. Quiliano Isaac Moro Sancho 1 Resumen Este trabajo se centra en el dise˜no y creaci´on de sistemas computacionales aproximados, los cuales aceptan una determinada tasa de error para mejorar otras caracter´ısticas, como la velocidad, o reducir costes. Para este proceso se utilizar´a la herramienta UPPAAL SMC. Abstract This thesis is focused on the design and implementation of approximate computing systems. This kind of systems allows some errors but improving other aspect, such as speed, or reducing resources. For this proccess, UPPAAL SMC will be used. Acknowledgements I would like to than Mr. Josef Strnadel, teacher of the Information Technology Faculty at Brno University of Technology,for his effort and dedication in helping me throughout the proccess of creating my thesis. 2 Contents 1 Introduction and objectives 5 2 Background: Approximate Computing 7 3 Selection of Implementation Areas and Means 11 3.1 ImplementationAreas ................................. 11 3.1.1 Approximate logical multiplier . . . . . . . . . . . . . . . . . . . . . . . . 11 3.1.2 DRAMmemory ................................ 13 3.2 ImplementationMeans................................. 14 3.2.1 UPPAAL4.0 .................................. 14 3.2.2 UPPAAL4.1(SMC).............................. 15 3.2.3 Otherversions ................................. 16 4 Proposed solutions 17 4.1 Approximate logical multiplier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.1.1 Gate Network approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.1.2 TruthTableapproach ............................. 20 4.2 DRAMmemory..................................... 25 5 Conclusions 31 3 4CONTENTS Chapter 1 Introduction and objectives Since its beginning, information technology has been evolving to become in an essential field for the society of these days. Every moment, a huge amount of information is in movement, which has to be processed and stored. This could generate some problems because is possible that the right tools are not available for manage that volume, sometimes exorbitant, of data. In this last decade, the ’Big Data’ concept has been developing. It refers to the set of data o combinations of them which size, complexity and growing speed obstruct its capture, management, processing or analysis with conventional technologies and tools, such as relational databases and conventional statistics in the time that this data is useful.(5) This is one of the reasons why it is necessary to use approximate computing. With it, we can sometimes admit a certain percentage of error in data processing so its size, complexity and speed can be adjusted to our possibilities. It is our task to determinate the accuracy that we can work with. Approximate computing has been used in a variety of domains where the applications are errortolerant, such as multimedia processing, machine learning, signal processing, scientific computing, etc.(12) Figure 1.1: Approximate computing accuracy plot (4) Objectives In this Bachelor’s thesis, the objectives to complete are: •Design some models of approximate computing systems, which will be a logic multiplier and a DRAM system. •Implement the proposed solutions in UPPAAL 4.1, which is an integrated tool environment for modelling, validation and verification of real-time systems modelled as networks of timed automata(8). 5 6CHAPTER 1. INTRODUCTION AND OBJECTIVES •Check the correctness of the systems, observing if the requirements of the problems have been solved. •With several simulations of these implementations, obtain some data that I will use in my Statistics Bachelor’s thesis (6) to check if an approximate computer system can be more efficient than an accurate one, using also UPPAAL 4.1. Report Content This memory will be divided in four different parts: 1. Background: I will explain what approximate computing is, its utilities and where it is used. 2. Implementation areas and Means: Describes the models implemented and the basics about UPPAAL 4.0 and 4.1 3. Proposed solution: Shows how the implementation has been done and its characteristics. 4. Conclusions: I will give my impressions, difficulties and possible improvements of this job. Time Planning The time that I will expend into this thesis will be: •Two weeks to search for information about the background and UPPAAL. •One month to learn how to use UPPAAL 4.1, because this will be my first time using this tool. •Two months to design and implement the proposed systems. •Two weeks to look for errors in the implementation, fix them and obtain some data. With this estimation, this thesis is expected to be done in around 4 months. Chapter 2 Background: Approximate Computing Approximate computing is a research agenda that seeks to better match the accuracy in system abstractions with the needs of approximate programs (7). The main challenge in approximate computing is forging abstractions that make imprecisions controlled and predictable without sacrificing its efficiency benefits. The objective is to design hardware and software around approximation. The research in this area combines insights from hardware engineering, architecture, system design, programming languages, etc. Some of them are: •Tolerance studies: This category shows how different parts of the application have different impacts on reliability and fidelity. Certain program components, especially those involved in control flow, need to be protected from all of approximation’s effects. •Exploit resilience in architecture: Hardware techniques for approximation can lead to gains in energy, performance, manufacturing yield or verification complexity. Hardware-based approximation strategies can be categorized according to the hardware component they affect: computational units, memories or the entire system architecture. •Memory: Persistent Memories, where their storage cells can be worn out, approximate systems can reduce the number of bits they flip to lengthen the useful device lifetime. Also, memories like flash can use its probabilistic properties while hiding them from software. This memory approximation techniques typically work by exposing soft errors and other similar effects. •Relaxed fault tolerance: Some circuit design techniques can be used to reduce the cost of redundancy by providing it selectively for certain instructions in a CPU, certain blocks in DSP or components of a GPU. Other use is to select critically information to allocate software-level error detection and correction resources. •Microarchitecture: One set of techniques uses external monitoring to allow errors even in processor control logic. Other approaches compose separate processing units with different levels of reliability. •Stochastic computing: It is an alternative computational model where values are represented using probabilities. A challenge in stochastic circuits is that reading and output value requires a number of bits that is exponential in the value’s magnitude. 7 8CHAPTER 2. BACKGROUND: APPROXIMATE COMPUTING Approximate systems Most of work in approximate system architectures focuses on computation. Error tolerance in transient and persistent data is present in a broad range of application domains, from server software to mobile applications. Memories have significant costs in performance, energy, area and complexity. It is because they need to ensure perfect data integrity 100% of the time. Techniques that exploit data accuracy trade-offs are proposed to provide approximate storage and gain performance, energy and capacity: 1. Use multi-level cells in a way that enables higher density or better performance at the cost of occasional inaccurate data retrieval. 2. Use blocks with failed bits to store approximate data. To mitigate the effect of failed bits on overall value precision, the correction of higher-order bits is prioritized. Approximate storage is applied to files and databases storage as well as transient data stored in main memory. Interfaces for approximate storage: Modern non-volatile memory technologies exhibit properties that make them candidates for storing data approximately. By exploiting the synergy between these properties an application-level error tolerance, we can alleviate some of these technologies’ limitations: limited device lifetime, low density and slow writes. When an application needs strict data fidelity, it uses traditional precise storage. Then, the memory guarantees a low error rate when recovering the data. When the application can tolerate occasional errors in some data, it uses the memory’s approximate mode, in which data recovery errors may occur win non-negligible probability. In approximate storage like Phase-change RAM and other solid-state, non-volatile memories, the application must determinate which data can tolerate errors and which data needs “perfect” fidelity. Approximate Main Memory: Phase-change RAM and other fast, resistive storage technologies may be used as main memories. A wide variety of applications, from image processing to scientific computing, have large amounts of error-tolerant stack and heap data. Approximate persistent storage: In this section, file systems, database management systems (DBMSs) or flat address spaces are considered. A data centre-scale image or video search database, for example, requires vast amounts of fast persistent storage. In occasional pixel errors are acceptable, approximate storage can reduce costs by increasing the capacity and lifetime of each storage module while improving performance and energy efficiency. Hardware interface and allocation: The interface to approximate memory consists of read and write operations augmented with a precision flag. In the main-memory case, these operations are load and store instructions. In the persistent storage case, these are blockwise read and write requests. The memory interface specifies a granularity at which approximation is controlled. The compiler and allocator ensure that precise data is always stored in precise blocks. 3.2. IMPLEMENTATION MEANS 15 •Normal locations (with or without invariants). •Urgent locations: This kind of locations freeze time. It means that time is not allowed to pass. They are marked by a Uinside the circle. •Committed locations: These locations also freeze time, but also, the next transition must involve an edge from one of the committed locations. They are useful for creating atomic sequences and for encoding synchronization between more than two components. They are marked by a Cinside the circle. There is also one (and only one) initial state. It is marked by a double circle. Figure 3.3: Example of a normal, urgent and committed states 3.2.2 UPPAAL 4.1 (SMC) The modelling formalism of UPPAAL SMC is based on a stochastic interpretation and extension of the timed automata formalism used in the classical model checking version of UPPAAL.(2) For individual timed automata components, the stochastic interpretation replaces the nondeterministic choices between multiple enabled transitions by probabilistic choices. Similarly, the non-deterministic choices of time delays are defined by probability distributions, which at the component level are given either uniform distributions in cases with time-bounded delays or exponential distributions in cases of unbounded delays. Figure 3.4: Example of a stochastic timed automata (2) 16 CHAPTER 3. SELECTION OF IMPLEMENTATION AREAS AND MEANS A model in UPPAAL SMC consists of a network of interacting stochastic timed automata. It is assumed that these components are input-enabled, deterministic and non-zero. These components communicate via broadcast channels and shared variables to generate networks of stochastic timed automata. The communication is restricted to broadcast synchronizations to keep a clean semantics of only non-blocked components which are racing against each other with their corresponding local distribution. 3.2.3 Other versions UPPAAL TIGA UPPAAL TIGA is an extension of UPPAAL and it implements the first efficient on-the-fly algorithm for solving games based on timed game automata with respect to reachability and safety properties. Though timed games for long have been known to be decidable there has until now been a lack of efficient and truly on-the-fly algorithms for their analysis (10). The algorithm is a symbolic extension of the on-the-fly algorithm suggested by Liu & Smolka for linear-time model-checking of finite-state systems. Being on-the-fly, the symbolic algorithm may terminate long before having explored the entire state-space. Also, the individual steps of the algorithm are carried out efficiently by the use of so-called zones as the underlying data structure. The tool implements various optimizations of the basic symbolic algorithm, as well as methods for obtaining time-optimal winning strategies (for reachability games). UPPAAL Stratego UPPAAL Stratego is a novel tool which facilitates the generation, optimization, comparison as well as consequence and performance exploration of strategies for stochastic priced timed games in a user-friendly manner. The tool allows for efficient and flexible “strategy-space” exploration before adaptation in a final implementation by maintaining strategies as first-class objects in the model-checking query language.(1) Chapter 4 Proposed solutions 4.1 Approximate logical multiplier Two models have been created for this implementation. The first one shows a more graphical way of how these logical systems work using transitions between different states. The second one uses transitions and functions. 4.1.1 Gate Network approach With this implementation, the circuits shown in pictures 3.1a and 3.1b will be built. To do that, a model of each logic gate has been simulated. 4 random inputs will be generated randomly. Then, the outputs for the accuracy and approximate multiplier will be calculated by a series of comparisons and transitions using these gates. Finally, if these outputs are identical, the result of the approximate multiplier is correct. Otherwise, it is not. These will be checked the number of times the user wants, and, in the end, the number of successes will be count. Global variables •count (integer): Number of times that the system has calculated the outputs. •success (integer): Number of times that the outputs of the approximate multiplier are the same as the three less significant output of the accurate multiplier. •input(array of integer): Store the inputs that the system will use to calculate the outputs. •C0,C1,C2,D0,E0,E1 (integers): Auxiliary variables used in the process of the calculation of the outputs. •Out3ac,Out2ac,Out1ac,Out0ac (integers): Outputs of the accurate multiplier. •Out2ap,Out1ap,Out0ap (integers): Outputs of the approximate multiplier. •Different broadcast channels used to send and receive signals between each gate. 17 18 CHAPTER 4. PROPOSED SOLUTIONS Templates Main This template has one parameter: loops. It says the number of times that the system will calculate the possible outputs. Random inputs are selected using a normal distribution N(0,1). First, 4 different random numbers are generated using this distribution and stored in a local array of integers RandomV. These numbers have the same probability of being positive or negative: Pr(X<=0) = Pr(X>0) = 0.5. So, if the number generated is negative, the number assigned for the corresponding position of input will be 0, and if it is positive, it will be 1. This is calculated by the function setValues(). Then, a signal will be sent to another template so it can start calculating the outputs for the accuracy and approximate multiplier. Finally, when these outputs are given back, they are compared by the function check(), except the most significant bit of the accurate model because it doesn’t have any pair to compare with. If all are the same, one unit will be added to the variable success. Then, if the system has done its last iteration (seeing if count is equal to loops), it will finish. Else, the process will start again. A clock tis added to the model, so an iteration will be done depending on the delay that it shows in the first state. Figure 4.1: Main template AND This template simulate the behaviour of an AND gate. It has 5 arguments: •chanInput (broadcast channel): Channel that receives the signal so it can start working. •input1 and input2 (integers): Inputs from which the output want to be got. •output (integer): Output obtained from the transitions. •chanOutput (broadcast channel): Send the signal so another template can start working. In an AND gate, the only possibility that the output is 1 is that both inputs are also 1. So, when the signal of chanInput is received, two comparisons are established. The first one is that, if the value of the first input is 0, the output will be 0 and the signal for chanOutput will be activated. In case that it is 1, it is moved to an intermediate state where the second input intervenes. If it is also 1, then the output will be 1. Otherwise, it will be 0. Then, there is a transition to an auxiliary state aux and another one to the initial state, sending the signal chanOutput to the next template. 4.1. APPROXIMATE LOGICAL MULTIPLIER 19 Figure 4.2: AND template XOR Like the AND template, this shows how the XOR gate works. This kind of gate returns 1 if both inputs are different, and 0 if are the same. It has the same 5 arguments of the last template, but its functionality is different. Once chanInput receive the signed, the first comparison is done. if the first input is 0, we go to an intermediate state, and if is 1, we go to another intermediate state. For both states, if the second input is equal to the first one, then the output will be 0, otherwise, it will be 1. Then, a transition to an auxiliary state is done and another one to the initial state. The signal of chanOutput will be sent in this last transition. Figure 4.3: XOR template OR This template has only 4 arguments because it is only used at the end of the simulation, so it doesn’t have chanOutput. This kind of gates returns 1 if some of its inputs are 1, 0 in another case. Like the other templates, we start receiving the signal in chanInput. If the first output is 1, the value 1 is given to the output. If not, the second input is compared. If it is 1, the output will be 1, and if it is 0, the output will be 0. Then, as the other templates, a transition is done to an auxiliary state and going back to the first state. 20 CHAPTER 4. PROPOSED SOLUTIONS Figure 4.4: OR template Finally, in the system declarations section, the different gates that encompass each circuit are declared. As it has been explained before, the accurate multiplier has 6 AND and 2 XOR gates, and the approximate multiplier has 4 AND and 1 OR gates. Figure 4.5: Declarations of the accurate multiplier Figure 4.6: Declarations of the approximate multiplier 4.1.2 Truth Table approach This implementation is more focused on programming using functions, and no so much is transitions as the first implementation was. It is based in the search for the corresponding output in the truth tables (3.1 and 3.2) depending on the inputs selected. With it, you can check all 4.1. APPROXIMATE LOGICAL MULTIPLIER 21 possible values of the outputs and also analyze with which frequency the approximate multiplier fails. In total, there are 4 templates. 2 of them are used to update the values of the outputs for the accurate and approximate multipliers respectively, the third establishes the inputs in a sorted way so all the possible outputs can be seen clearly, and the fourth generate random numbers for the inputs. Global variables •update (broadcast channel): Allows the system to generate the outputs once the inputs have been established. •bits and bits aprox (boolean arrays): They have length 8 and 7 respectively. Positions 0, 1, 2 and 3 of each array represents the inputs, and positions 4, 5, 6 and 7 (This last one only for the array bits) represents the obtained outputs. •bitsCovered (Integer): Represents the number of possibilities that have been used when only the different possibilities are wanted to be seen. •equalBits (Integer): Establish if the outputs of the approximate multiplier are the same as the obtained by the accurate multiplier. •errorRate and finalErrorRate (doubles): The first one stores the error rate at every moment of the simulation, and the second one only at the end. •The truth tables of both multipliers are defined as a two-dimensional array, with dimension 2N INPUTS×(N INPUTS+N OUTPUTS), where N INPUTS and N OUTPUTS represents the number of inputs and outputs respectively. Figure 4.7: Truth table declaration of the accurate logical multiplier 22 CHAPTER 4. PROPOSED SOLUTIONS Templates Template set inputs This template has 5 parameters: a0,a1,b0,b1,integers, that represent the positions that the inputs will be stored in the array, and dly, integer, that represents the period of time used by a set of inputs and outputs. The local variables are a clock x,input, integer, used to update the inputs, and a boolean array inCoverSet used to check if the simulation should end. The functions created for this template are: •update bits(): Update the values of bits depending if the actual value of input is divisible or not by a number (1 for the less significant input, 2 for the second, 4 for the third and 8 for the most significant one). •update bits aprox(): Copy the values of the inputs of bits (First 4 registers) into bits aprox so comparisons can be done. •update input(): Call the two functions mentioned before, establish the value true to inCoverSet[input] and add 1 to input. •check(): Check if the outputs of both multipliers are the same, and set a value to equalBits depending on it. •error(): Calculates the error rate committed at a specific time of the simulation. •inCovered(): Check if all possible states have been analyzed. This is done seeing if all the registers of inCoverSet have the value true. Template set inputs random It is similar to the previous one, but with some differences, because this template is used to generate nrandom inputs. It has the same arguments of set input, but with one more: loops, integer, that specifies the number of times that inputs will be generated. As local variables, there are a clock x, an integer count that will be a counter and a boolean stop that will tell if the simulation has to finish. There are the same functions of the first template, but changing some definitions. There will be commented only the ones which are different, omitting the others: •update bits(): It generates random inputs. It uses a normal distribution to do it, as in the first implementation. 4 random numbers are generated with a distribution N(0,1), that have the same probability of being positive or negative. In case that the number is negative, the input will be 0, otherwise will be 1. •inCovered(): Check if the counter count is equal to the number of inputs that wanted to be generated, established by loops. If it is, then stop will be set with true. •update input(): Calls update bits() and update bits aprox(), increase the value of count 1 unit and calls inCovered() 4.1. APPROXIMATE LOGICAL MULTIPLIER 23 Figure 4.8: set inputs and set inputs random template Both templates have the same states and transitions, but, as it has been commented before, the functions they have are different. Template outputs acc This template has as parameters a0,a1,b1,b0, that represents the positions of the array bits where the inputs will be stored, y0,y1,y2,y3, that establish the positions of the same vector where the outputs will be, a two-dimensional boolean vector ttbl that references the truth table of the accurate multiplier, and an integer dly that set the delay between the different calculation of the outputs. As a unique local variable, there is a clock x. output acc only has one function, bin2dec(), that gets the binary values of the entries and returns a decimal number. Figure 4.9: outputs acc template Template outputs aprox This last template is similar to the last one. It has the same parameters, but in this case there is not y3, because only 3 outputs are obtained, a0,a1,b0,b1,y0,y1 now set the positions of inputs and outputs in the vector bits aprox and ttbl references the truth table of the approximate multiplier. It also has one local variable, the clock x, and the function bin2dec(). 24 CHAPTER 4. PROPOSED SOLUTIONS Figure 4.10: outputs aprox template How it works First, the simulation starts on the template set inputs or set inputs random, depending on if it is wanted to obtain all possible outputs or nrandom outputs. The initial state is get. A transition to the state apply is done. On it, the signal of the channel update is activated, which will allow the templates outputs acc and outputs aprox to do the first transition. Also, the function update inputs() is called to update the inputs. With the inputs updated, the templates outputs acc and outputs aprox will start working. In them, the outputs will be calculated, referencing the inputs to the respective truth table. Once the outputs are obtained, there will be a transition to the state wait. In that transition, the system will check if the outputs of both multipliers are the same and it will calculate the error rate in that moment of the simulation.In wait, there will be checked if all possible combinations of inputs have been obtained (in the case of set inputs) or if the number of desired outputs have been obtained (in the case of set inputs random). There are two possibilities: •If the condition is not met, there will be a transition to the initial state when the delay time has been reached. •If the condition is reached, a transition to the state done.finalErrorRate will be set with the current error rate and the simulation finish. These are some possible results obtained with this implementation: Figure 4.11: Simulation with get inputs Chapter 5 Conclusions In this thesis, I have designed and developed three approximate computing system models: Two logical multipliers using two different approaches and a Dynamic Random Access Memory (DRAM). These models have been created using UPPAAL SMC. It has been a really useful tool, that allows building the models in an intuitive way. Various versions of the models were created during the process, and some problems have also occurred. One of these problems that I had to manage with was the set of time, that made the creation of the models more difficult than I thought at the beginning.This was my first time using this program and I had a hard time getting used to it, so I took more time than expected in learning the basics and some advances methods. First I started reading the specifications of the tool and doing some easy examples. Then I created more difficult sequences till I could finally do the implementations that I have presented in this thesis. Some other implementations could be done, such as change the number of inputs of the logical multipliers or improve the functionality of the DRAM system. These tasks can be done in the future. Executing these programs, I will get some data that will be used in my Statistics Bachelor’s thesis (6) to see its behaviour and check if approximate computer systems have any advantages over the accurate ones. 31 32 CHAPTER 5. CONCLUSIONS Bibliography [1] David, A.; Gjøl, P.; Larsen, K. G.; et al.: UPPAAL STRATEGO. 2015. [Online; visited 11.02.2020]. Retrieved from: https://link.springer.com/chapter/10.1007% 2F978-3-662-46681-0_16 [2] David, A.; Larsen, K. G.; Legay, A.; et al.: UPPAAL SMC tutorial. 2015. [Online; visited 11.02.2020]. Retrieved from: https://doi.org/10.1007/s10009-014-0361-y [3] Emerging Computing Technology Laboratory at SJTU: Approximate Computing. [Online; visited 11.02.2020]. Retrieved from: http://umji.sjtu.edu.cn/~wkqian/research.html [4] Kugler, L.: Is ’good enough’ computing good enough? 2015. [Online; visited 11.02.2020]. Retrieved from: https://cacm.acm.org/magazines/2015/5/ 186012-is-good-enough-computing-good-enough/fulltext [5] PowerData: Big Data: ¿En qu´e consiste? Su importancia, desaf´ıos y gobernabilidad. [Online; visited 11.02.2020]. Retrieved from: https://www.powerdata.es/big-data [6] P´erez, S.: Statistical Model Checking in Approximate Computing Systems. 2020. [7] Sampson, A.: Hardware and Software for Approximate Computing. 2015. [Online; visited 11.02.2020]. Retrieved from: https://digital.lib.washington.edu/researchworks/bitstream/ handle/1773/33693/Sampson_washington_0250E_14938.pdf?sequence=1 [8] UPPAAL: [Online; visited 11.02.2020]. Retrieved from: www.uppaal.org [9] UPPAAL: Locations. [Online; visited 11.02.2020]. Retrieved from: http://www.it.uu.se/research/group/darts/uppaal/help.php?file= System_Descriptions/Locations.shtml [10] UPPAAL: UPPAAL TIGA. [Online; visited 11.02.2020]. Retrieved from: http://people.cs.aau.dk/~adavid/tiga/index.html [11] UPPAAL: UPPAAL 4.0: Small Tutorial. 2009. [Online; visited 11.02.2020]. Retrieved from: http://www.it.uu.se/research/group/darts/uppaal/small_ tutorial.pdf 33 34 BIBLIOGRAPHY [12] Wikipedia: Approximate computing. [Online; visited 11.02.2020]. Retrieved from: https://en.wikipedia.org/wiki/Approximate_computing [13] Wikipedia: DRAM. [Online; visited 11.02.2020]. Retrieved from: https://es.wikipedia.org/wiki/DRAM [14] Wikipedia: Dynamic Random Access Memory. [Online; visited 11.02.2020]. Retrieved from: https://en.wikipedia.org/wiki/Dynamic_random-access_memory [15] Yoon, A.: Understanding Memory. 2018. [Online; visited 11.02.2020]. Retrieved from: https://semiengineering.com/whats-really-happening-inside-memory/