An Evaluation of POP Performance for Tuning Numerical Programs in Floating-Point Arithmetic

An Evaluation of POP Performance for Tuning Numerical Programs in Floating-Point Arithmetic

An Evaluation of POP Performance for Tuning Numerical Programs in Floating-Point Arithmetic Dorra Ben Khalifa1 Matthieu Martel1;2 1 LAMPS - University of Perpignan Via Domitia 2 Numalis 52 Av. P. Alduy, 66100, Perpignan, France Cap Omega, Rond-point B. Franklin, Montpellier, France [email protected] [email protected] Abstract—Most of today’s numerical computations are per- accuracy while maintaining a precision constraint. In this formed using floating-point data operations for representing article, we present an evaluation of the performance of our real numbers. The precision of the related data types should be static analysis based tool named POP (short for ”Precision adapted in order to guarantee a desired overall rounding error and to strengthen the performance of programs. This adaptation OPtimizer”) that, by minimizing the over-estimated precision lies to the precision tuning technique, which consists of finding of the inputs and intermediary results, guarantees a desired the least floating-point formats enabling a program to compute precision on the outputs of floating-point programs. Our tool some results with an accuracy requirement. Precision tuning takes as input a program annotated with the accuracy required is important for several applications from a wide variety of by the user and it implements a forward and backward static domains including embedded systems, Internet of Things (IoT), etc. In this work, we evaluate the performance of POP, our program analysis as a set of constraints. The analysis is static analysis tool, in several manners. First, we compare two expressed as a set of propositional formulae on constraints ways of optimizing programs in POP throughout the definition between integer variables only (checked by Z3) [13]. The of different cost functions given to the solver. Second, we constraints are made of inequalities between linear arithmetic measure the runtime errors between the exact results given expressions possibly containing min and max operators. In by an execution in multiple precision and the results of tuned programs by POP and show that the measured error is always practice, these constraints are easy to handle for Z3. As a less than the accuracy requirements given by the user for several result, the transformed program is guaranteed to use variables examples. Third, we provide a detailed comparison of POP of lower precision with a minimal number of bits than the versus the prior state-of-the-art tool, Precimonious. original program. The contributions introduced in this article are: Index Terms—Floating-point arithmetic, precision tuning, static program analysis, numerical accuracy. 1) We improve the efficiency of POP by experimenting with several cost functions to our global system of I. INTRODUCTION constraints in order to optimize the solutions returned Nowadays, with the wide availability of processors with by the Z3 solver. We compare the performance of our hardware floating-point units, e.g. for smartphones or other tool for each of these functions on different programs IoT devices, many applications rely on floating-point com- coming from scientific computing, signal processing or putations. In practice, these applications such as the crit- the IoT domain. ical control-command systems for aeronautic, automotive, 2) For each tuned program, we measure the error between etc., have stringent correctness requirements and limita- the exact results given by an execution in multiple pre- tions related to accuracy issues including extreme sensitivity cision (using MPFR [14]) and the results of optimized to rounding errors and poorly handled numerical excep- programs by POP. This error is compared to the user tions [1]. This has led to several bugs and catastrophic conse- required accuracy. quences [2]. Without any extensive background in numerical 3) We provide a detailed comparison of POP against the accuracy and computer arithmetic and to strengthen the prior state-of-the-art tool Precimonious [8] in terms of accuracy of floating-point programs, developers tend to use analysis time, speed and the quality of the solution. the highest precision available in hardware (usually double Even though both tools use different techniques, we precision). While more robust, this can degrade program have adjusted the comparison criteria in order to make a performance significantly: the application runtime, bandwidth closer comparison of the real behavior of these tools (see capacity and the memory and energy consumption of the Section IV-B3). A detailed explanation of POP is given system. in Section II while the comparison versus Precimonious Besides, reducing the floating-point precision of certain is presented in Section IV-B3. variables, also called Precision Tuning, is a possible so- lution to speedup the execution or to save resources such The rest of this article is organized as follows. We present as memory and energy. Precision tuning has resulted in some preliminary definitions and an overview of our tool the development of several tools based on static [3]–[7] or POP in Section II. Section III deals with the related work dynamic methods [8]–[12] to help programmers explore the of the existing tools. Section IV is devoted to the analysis trade-off between floating-point precision and performance. of the experimental results. Limitations and future work are Their main objective is to improve performance by reducing discussed in Section V. Finally, Section VI concludes. II. OVERVIEW OF POP TOOL variable x only 20 correct digits at its control point (we This section starts with a brief background on the IEEE754 consider that a result has n correct digits or significants if Standard for floating-point arithmetic and the definitions of the relative error between the exact and approximated results −n the ufp and ulp functions. In addition, an overview of our is less than 2 ). As a consequence, the minimal precision tool POP is presented. needed for the inputs and intermediary results satisfying the user assertion is observed on the bottom center side of A. Preliminary Definitions Figure 1. Since, in our example, 20 bits only are required The IEEE754 Standard [15] formalizes a binary floating- for x, the result of the addition x + a also needs 20 accurate point number x = s.m.βe−p+1, generally in base β = 2, as bits only. By combining this information with the result of a triplet made of a sign s, a mantissa m and an exponent e. the forward analysis, it is then possible to lower the number The sign is s 2 {−1; 1g, the mantissa is m = d0:d1:::dp−1, of bits needed for one of the operands. The fundamental with the digits 0 ≤ di < β, 0 ≤ i ≤ p − 1, and p is the point of our technique is to generate simple constraints made precision (length of the mantissa). Finally, the exponent is e of propositional logic formulae and of affine expressions 2 [emin; emax]. among integers, even if the floating-point computations in The IEEE754 Standard specifies some particular values for the source code are non-linear [18]. Therefore, we assign ` p, emin and emax [16] and defines binary formats. Hence, to each control point two types of integer parameters: the IEEE754 standard distinguishes between normalized and the ufp of the values (see Equation (1)) and three integer denormalized numbers. The normalization of a floating-point variables corresponding to the forward, the backward and acc (`) acc (`) acc(`) number ensuring d0 6= 0 guarantees the uniqueness of its the final accuracies, denoted F , B and representation. The IEEE754 standard defines also some respectively, so that the inequality in Equation (3) is always special numbers (see [7] for details). Moreover, the IEEE754 verified. Hence, we notice that in the forward mode, the Standard defines four rounding modes for elementary oper- accuracy decreases contrarily to the backward mode when ations over floating-point numbers which are: towards +1, we strengthen the post-conditions (accuracy increases). towards −∞, towards zero and to the nearest denoted by 0 ≤ accB(`) ≤ acc(`) ≤ accF (`) (3) "+1, "−∞, "0 and "∼, respectively. Henceforth, we present the ufp (unit in the first place) and The constraint system in this example, with control points `0 ulp (unit in the last place) functions which express the weight to `28, is made of constraints for the whole program including of the most significant bit and the weight of the last significant the while loop, assignments, additions and the counter. These bit, respectively. In practice, our approach which describes numbers of variables and constraints are linear in the size of the error propagation across the computations is based on the program. Although the number of constraints generated these functions as already detailed in [7]. The definitions of is linear, it is too large to be written by hand yet in the same these functions are given at equations (1) and (2) defined time it is easy to be checked by an SMT solver. In the sequel, in [17] . we show at Equation (4) some constraints without taking into account the while loop and by taking into consideration the ufp(x) = minfi 2 : 2i+1 > xg = blog (x)c Z 2 (1) operations of assignments a := 1:0 , i = 1:0 and x = 0:0 Let p be the size of the significand, the ulp of a floating-point and only one elementary operation a := a+1:0 (see [17] for number can be expressed as shown: more details for the constraint generation of while loops and other commands.) The way to generate systematically these ulp(x) = ufp(x) − p + 1 : (2) constraints from the source code of the program is explained B. POP Technical Approach in [17]. To better explain the forward and backward static analysis 8 acc (` ) = 53; acc (` ) = 53; acc (` ) = 53; 9 > F 0 F 2 F 4 > by constraint generation performed by POP, a straightforward > accF (`12) = 53; > > > > acc (a`1 ) = acc (` ); acc (a`1 ) = acc (` ); > C program used as motivating example is given in Figure 1.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us