Improving the numerical accuracy of programs by automatic transformation

  • Nasrine DamoucheEmail author
  • Matthieu Martel
  • Alexandre Chapoutot
FMICS 2015/2016


The dangers of programs performing floating-point computations are well known. This is due to the sensitivity of the results to the way formulæ are written. These last years, several techniques have been proposed concerning the transformation of arithmetic expressions in order to improve their numerical accuracy and, in this article, we go one step further by automatically transforming larger pieces of code containing assignments and control structures. We define a set of transformation rules allowing the generation, under certain conditions and in polynomial time, of larger expressions by performing limited formal computations, possibly among several iterations of a loop. These larger expressions are better suited to improve, by reparsing, the numerical accuracy of the program results. We use abstract interpretation-based static analysis techniques to over-approximate the round-off errors in programs and during the transformation of expressions. A tool has been implemented and experimental results are presented concerning classical numerical algorithms and algorithms for embedded systems.


Program transformation Floating-point numbers Static analysis IEEE754 standard Numerical accuracy 


  1. 1.
    Almagor, L., Cooper, K.D., Grosul, A., Harvey, T.J., Reeves, S.W., Subramanian, D., Torczon, L., Waterman, T.: Finding effective compilation sequences. In: Whalley D.B., Cytron, R. (eds.) ACM SIGPLAN/SIGBED Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES’04), pp. 231–239. ACM (2004)Google Scholar
  2. 2.
    ANSI/IEEE. IEEE Standard for Binary Floating-point Arithmetic, std 754-2008 edition (2008)Google Scholar
  3. 3.
    Appel, A.-W.: Modern compiler implementation in ML. Cambridge University Press, Cambridge (1998)zbMATHGoogle Scholar
  4. 4.
    Barr, E.T., Vo, T., Le, V., Su, Z.: Automatic detection of floating-point exceptions. In: Giacobazzi, R., Cousot, R. (eds.) ACM SIGPLAN-SIGACT POPL’13, pp. 549–560, ACM (2013)Google Scholar
  5. 5.
    Benz, F., Hildebrandt, A., Hack, S.: A dynamic program analysis to find floating-point accuracy problems. In: Vitek, J., Lin, H., Tip, F. (eds.) ACM SIGPLAN PLDI’12, pp. 453–462. ACM (2012)Google Scholar
  6. 6.
    Bertrane, J., Cousot, P., Cousot, R., Feret, J., Mauborgne, L., Miné, A., Rival, X.: Static analysis by abstract interpretation of embedded critical software. ACM SIGSOFT Softw. Eng. Notes 36(1), 1–8 (2011)CrossRefGoogle Scholar
  7. 7.
    Cooper, K.D., Subramanian, D., Torczon, L.: Adaptive optimizing compilers for the 21st century. J. Supercomput. 23(1), 7–22 (2002)CrossRefzbMATHGoogle Scholar
  8. 8.
    Cousot, P., Cousot, R.: Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: Graham, R.M., Harrison, M.A., Sethi, R. (eds.) POPL’77, pp. 238–252 ACM (1977)Google Scholar
  9. 9.
    Cousot, P., Cousot, R.: Systematic design of program transformation frameworks by abstract interpretation. In: Launchbury, J., Mitchell, J.C. (eds.) POPL’02, pp. 178–190. ACM (2002)Google Scholar
  10. 10.
    Cytron, R., Gershbein, R.: Efficient accomodation of may-alias information in SSA form. In PLDI’93, pp. 36–45, ACM (1993)Google Scholar
  11. 11.
    Damouche, N., Martel, M., Chapoutot, A.: Impact of accuracy optimization on the convergence of numerical iterative methods. In: Falaschi, M. (ed.) LOPSTR 2015, volume 9527 of Lecture Notes in Computer Science, pp. 143–160. Springer (2015)Google Scholar
  12. 12.
    Damouche, N., Martel, M., Chapoutot, A.: Intra-procedural optimization of the numerical accuracy of programs. In M. Núñez and M. Güdemann, editors, FMICS’15, volume 9128 of Lecture Notes in Computer Science, pp. 31–46 Springer (2015)Google Scholar
  13. 13.
    Damouche, N., Martel, M., Chapoutot, A.: Optimizing the accuracy of a rocket trajectory simulation by program transformation. In: CF’15, pp. 40:1–40:2. ACM (2015)Google Scholar
  14. 14.
    Damouche, N., Martel, M., Chapoutot, A.: Transformation of a PID controller for numerical accuracy. Electr. Notes Theor. Comput. Sci. 317, 47–54 (2015)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Darulova, E., Kuncak, V.: Sound compilation of reals. In: Jagannathan, S., Sewell, P. (eds.) POPL’14, pp. 235–248. ACM (2014)Google Scholar
  16. 16.
    Delmas, D., Goubault, E., Putot, S., Souyris, J., Tekkal, K.  Védrine, F.: Towards an industrial use of FLUCTUAT on safety-critical avionics software. In: FMICS’09, pp. 53–69 (2009)Google Scholar
  17. 17.
    Feron, E.: From control systems to control software, ieee control systems magazine. IEEE 30, 50–71 (2010)MathSciNetGoogle Scholar
  18. 18.
    Goubault E.: Static analysis by abstract interpretation of numerical programs and systems, and FLUCTUAT. In: Logozzo, F., Fähndrich, M. (eds.) SAS’13, volume 7935 of Lecture Notes in Computer Science, pp. 1–3. Springer (2013)Google Scholar
  19. 19.
    Goubault E., Putot S.: Static analysis of finite precision computations. In: Jhala, R., Schmidt, D.A. (eds.) VMCAI’11, volume 6538 of Lecture Notes in Computer Science, pp. 232–247. Springer (2011)Google Scholar
  20. 20.
    Feret, J.: Static analysis of digital filters. In: Schmidt, D.A. (ed.) Programming Languages and Systems, 13th European Symposium on Programming, ESOP 2004, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS, volume 2986 of Lecture Notes in Computer Science, pp. 33–48. Springer (2004)Google Scholar
  21. 21.
    Gao, X., Bayliss, S., G. A. Constantinides. SOAP: structural optimization of arithmetic expressions for high-level synthesis. In: FPT’13, pp. 112–119. IEEE (2013)Google Scholar
  22. 22.
    Hankin, E.: Lambda Calculi A guide for computer scientists. Clarendon Press, Oxford (1994)zbMATHGoogle Scholar
  23. 23.
    Huet, G., Kahn, G., Paulin-Mohring, Ch.: The \(\sf Coq\) ProofAssistant—A tutorial-Version 8.0, (2004)Google Scholar
  24. 24.
    Ioualalen, A., Martel, M.: A new abstract domain for the representation of mathematically equivalent expressions. In: SAS’12, volume 7460 of LNCS, pp. 75–93. Springer (2012)Google Scholar
  25. 25.
    Jones, N.D.: An introduction to partial evaluation. ACM Comput. Surv. 28(3), 480–503 (1996)CrossRefGoogle Scholar
  26. 26.
    Kendall, A.: An introduction to numerical analysis. Wiley, Hoboken (1989)zbMATHGoogle Scholar
  27. 27.
    Knoop, J., R”uthing, O., Steffen, B.: Optimal code motion: Theory and practice. ACM Transactions on Programming Languages and Syst. 16(4):1117–1155 (1994)Google Scholar
  28. 28.
    Langlois, P., Martel, M., Thévenoux, L.: Accuracy versus time: a case study with summation algorithms. In: Maza, M.M., Roch, J.-L. (eds) 4th International Workshop on Parallel Symbolic Computation, PASCO, pp. 121–130. ACM (2010)Google Scholar
  29. 29.
    Lerner, S., Grove, D., Chambers, C.: Composing dataflow analyses and transformations. In: Launchbury, J., Mitchell, J.C. (eds) 29th SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 270–282. ACM (2002)Google Scholar
  30. 30.
    Martel, M.: Semantics of roundoff error propagation in finite precision calculations. High. Order Symb. Comput. 19(1), 7–30 (2006)CrossRefzbMATHGoogle Scholar
  31. 31.
    Martel, M.: Accurate evaluation of arithmetic expressions (invited talk). Electr. Notes Theor. Comput. Sci. 287, 3–16 (2012)CrossRefzbMATHGoogle Scholar
  32. 32.
    Miné, A.: Relational abstract domains for the detection of floating-point run-time errors. In D. A. Schmidt, editor, Programming Languages and Systems, 13th European Symposium on Programming, ESOP 2004, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2004, Proceedings, volume 2986 of Lecture Notes in Computer Science, p. 3–17. Springer (2004)Google Scholar
  33. 33.
    Monniaux, D.: The pitfalls of verifying floating-point computations. ACM Trans. Program. Lang. Syst. 30(3) 2008Google Scholar
  34. 34.
    Muller, J.-M., Brisebarre, N., de Dinechin, F., Jeannerod, C.-P., Lefèvre, V., Melquiond, G., Revol, N., Stehlé, D., Torres, S.: Handbook of floating-point arithmetic. B. Boston (2010)Google Scholar
  35. 35.
    Wilcox, J. R., Panchekha, P., Sanchez-Stern, A., Tatlock, Z.: Automatically improving accuracy for floating point expressions. In: Grove, D., Blackburn, S. (eds.) ACM SIGPLAN PLDI’2015, pp. 1–11. ACM (2015)Google Scholar
  36. 36.
    Solovyev, A., Jacobsen, C., Rakamaric, Z., Gopalakrishnan, G.: Rigorous estimation of floating-point round-off errors with symbolic taylor expansions. In FM’15, volume 9109 of LNCS, pp. 532–550. Springer (2015)Google Scholar
  37. 37.
    Steffen, B., Knoop, J., Rüthing, O.: The value flow graph: a program representation for optimal program transformations. In: Jones, N.D. (ed.) ESOP’90, 3rd European Symposium on Programming, volume 432 of Lecture Notes in Computer Science, pp. 389–405. Springer (1990)Google Scholar
  38. 38.
    Tate, R., Stepp, M., Tatlock, Z., Lerner, S.: Equality saturation: a new approach to optimization. In Z. Shao and B. C. Pierce, editors, ACM SIGPLAN-SIGACT POPL’09, pages 264–276. ACM, (2009)Google Scholar
  39. 39.
    Tate, R., Stepp, M., Tatlock, Z., Lerner, S.: Equality saturation: a new approach to optimization. Logical Methods in Computer Science 7(1) (2011)Google Scholar
  40. 40.
    Whitfield, D., Lou Soffa, M.: An approach for exploring code-improving transformations. ACM Trans. Program. Lang. Syst. 19(6), 1053–1084 (1997)CrossRefGoogle Scholar
  41. 41.
    Winskel, G.: The formal semantics of programming languages - an introduction. Foundation of computing series. MIT Press, Cambridge (1993)zbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2016

Authors and Affiliations

  • Nasrine Damouche
    • 1
    Email author
  • Matthieu Martel
    • 1
  • Alexandre Chapoutot
    • 2
  1. 1.LAMPS LaboratoryUniversity of Perpignan Via DomitiaPerpignanFrance
  2. 2.U2IS, ENSTA ParisTech, Université Paris-SaclayPalaiseau cedexFrance

Personalised recommendations