• Aucun résultat trouvé

Code Synthesis to Optimize Accuracy and Execution Time of Floating-Point Programs

N/A
N/A
Protected

Academic year: 2021

Partager "Code Synthesis to Optimize Accuracy and Execution Time of Floating-Point Programs"

Copied!
3
0
0

Texte intégral

(1)

HAL Id: hal-01157509

https://hal.archives-ouvertes.fr/hal-01157509

Preprint submitted on 1 Jun 2015

HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Code Synthesis to Optimize Accuracy and Execution Time of Floating-Point Programs

Laurent Thévenoux, Matthieu Martel, Philippe Langlois

To cite this version:

Laurent Thévenoux, Matthieu Martel, Philippe Langlois. Code Synthesis to Optimize Accuracy and

Execution Time of Floating-Point Programs. 2015. �hal-01157509�

(2)

Code Synthesis to Optimize Accuracy and Execution Time of Floating-Point Programs

Laurent Thévenoux 1 , Matthieu Martel 2 , and Philippe Langlois 2

1 Inria – Laboratoire LIP, (CNRS, ENS de Lyon, Inria, UCBL), Univ. de Lyon, France

2

UPVD – Équipe DALI, (CNRS, LIRMM, UPVD, UM2), Univ. de Perpignan, France laurent.thevenoux@ens-lyon.fr, {matthieu.martel, langlois}@univ-perp.fr

Keywords: code synthesis, compensation, execution-time performance, floating-point arithmetic, multi-criteria optimization, numerical accuracy.

Since the precision of standard floating-point arithmetic [6] is finite, numerical pro- grams based on it can suffer from rounding errors. To avoid such accuracy losses, code writers must be careful by using floating-point numbers. Unfortunately, they can not take care of every accuracy issues, even if they are floating-point experts. Neverthe- less, several methods have been proposed to help developers to improve the accuracy of their floating-point programs [2, 3, 5].

As the numerical accuracy, execution time is a critical matter for programs, espe- cially in embedded systems where less execution time means less energy consumption or better reactivity. Taking into account both accuracy and execution time simultane- ously is a difficult problem because these two criteria do not cohabit well: improving accuracy may be costly (execution-time improvement can impact accuracy as well).

Our proposed solution is to allow tradeoffs between accuracy and time [4].

We present the SyHD software developed to perform source-to-source transforma- tion improving accuracy without impacting execution time too much. SyHD synthe- sizes C source code for both accuracy and execution-time criteria. It uses compensation for improving accuracy and transformation strategies for reducing the impact of this improvement on execution time. The automatic compensation is provided by another software, CoHD [8]. Compensated algorithms are efficient but difficult to implement, so we automate this process with CoHD to benefit from a good execution time com- pared to other methods. Experimental results show that our automatically transformed programs have roughly the same accuracy and execution time than the existing com- pensated ones when the latter exist. To improve execution time, we have implemented several strategies of partial compensation. SyHD synthesizes a new program by auto- matically analyzing a set of transformed programs implementing these strategies for a given environment (defined by a target, some data, as well as some accuracy and

Abstract of a manuscript in preparation.

1

(3)

execution-time constraints). Two kinds of transformation strategies are proposed: the ones which compensate the floating-point computations that generate the largest errors, and the ones which do loop transformations, such as loop fission [1].

We apply this approach to a significant set of examples, ranging from recursive summation, to polynomial evaluations, to iterative refinement for linear system solving.

We successfully generate programs with accuracy and execution-time tradeoffs in a reasonable amount of time [7].

25 30 35 40 45 50 55

0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 original transformed

25 30 35 40 45 50 55

0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 original transformed

The following example illustrates the potential of our approach (results are auto- matically obtained by CoHD and SyHD). The figure above presents the number of significant bits when evaluating the polynomial p(x) = (x − 0.75)

5

(x − 1)

11

with the Horner’s scheme, where x ∈ [0.35, 0.45]. The leftmost part shows the result of the original and transformed programs when no tradeoff is allowed. We recover the full accuracy (53 bits for double precision) for approximately 300 cycles (more than 3 times better than an algorithm using double-double expansions). The rightmost part shows same results when tradeoff between accuracy and execution time is required. By sacrificing accuracy we can save here 50 more cycles for this polynomial evaluation.

References

[1] A. W. Appel. Modern Compiler Implementation: In ML. Cambridge University Press, New York, NY, USA, 1998.

[2] T. J. Dekker. A floating-point technique for extending the available precision. Numer. Math., 18:224–

242, 1971.

[3] S. Graillat, P. Langlois, and N. Louvet. Algorithms for accurate, validated and fast polynomial evalua- tion. Japan Journal of Industrial and Applied Mathematics, 26(2-3):191–214, 2009.

[4] P. Langlois, M. Martel, and L. Thévenoux. Automatic code transformation to optimize accuracy and speed in floating-point arithmetic. In SCAN 2012 – 15th GAMM-IMACS International Symposium on Scientific Computing, Computer Arithmetic and Validated Numerics, 2012.

[5] J. R. Shewchuk. Adaptive precision floating-point arithmetic and fast robust geometric predicates.

Springer Disc. & Comp. Geometry, 18(3):305–363, 1997.

[6] IEEE Computer Society. IEEE 754 Standard for Floating-Point Arithmetic. The Institute of Electrical and Electronics Engineers, Inc., 2008.

[7] L. Thévenoux. Synthèse de code avec compromis entre performance et précision en arithmétique flot- tante IEEE 754. PhD thesis, Université de Perpignan Via Domitia, Perpignan, France, July 2014. URL:

https://tel.archives-ouvertes.fr/tel-01143824 .

[8] L. Thévenoux, P. Langlois, and M. Martel. Automatic source-to-source error compensation of floating- point programs. Submitted to the 18th IEEE International Conference on Computational Science and En- gineering (CSE 2015), Porto, Portugal., May 2015. URL: https://hal.archives-ouvertes.

fr/hal-01158399.

2

Références

Documents relatifs

The table shows results from a standard execution in IEEE-754 single precision (float) with rounding to nearest, as well as results obtained with the same program (i.e. the exact

Table 5 compares the exact value of d , its numerical evaluation by using IEEE-754 double precision with the rounding mode to the nearest and the numerical verification done both

amplicon for QPCR subsequently revealed differences in HF183 marker abundance among sites that were corre- lated with land use (Fig. 1a–c) and pointed to on-site treatment plants

Section 4 describes how we generate exhaustively the summation algorithms of interest and Section 5 intro- duces further examples involving larger sums, accuracy ver- sus

SyHD explores a set of transformed programs generated with CoHD following several transformation strategies and finds the program with the best accuracy and execution time

La prescription des médicaments anti-infectieux chez la femme enceinte doit respecter la double règle qui veut que, d’une part,l’on privilégie la prise en charge de

In this paper, we identified several issues, i.e., an instrumentation time overhead, a discrepancy of the measured number of instructions, a calibration method that ignores some