the LocalPolicy in Default_real_algebraic with a Local_double_sum variant, but otherwise keeps the default policies The number type Default_dsumL_real_
5.3. Exact Floating-Point Algorithms for Dag Evaluation
In this section we draw some general conclusion from the experiments of the previous section and discuss potentially better ways to employ exact floating-point algorithms based on error-free transformations in expression dag based number types. Evidently, exact floating-point algorithms based on error-free transformations allow for very fast exact evaluation of polynomial expressions. Using them to defer dag creation does however not lead to an improvement for non-degenerate data. This shows, that they are still slower than dag creation and the first stage of ex- pression evaluation with a dynamic floating-point filter. On the other hand, exact floating-point algorithms appear to be much faster than evaluation with bigfloat arithmetic, since deferring dag creation improves the overall running time in cases where bigfloat evaluation becomes necessary. An improvement is made even in the case of general expressions involving division and square roots, where only relatively small polynomial sub-expressions are evaluated exactly and an expression dag is created for the remaining expression.
This shows, that to achieve a performance improvement for both non-degenerate and degenerate data, exact floating-point algorithms should be placed between the floating-point filter stage and evaluation with bigfloat arithmetic. Such a strategy would first create the complete expression dag and evaluate it with a floating-point filter. Afterwards, exact floating-point algorithms will be used to collapse polynomial sub-expressions over the leaves of the dag to a single node. Precision driven arithmetic with bigfloat arithmetic would then be used on the remaining dag only.
For predicate calls that are decided by the floating-point filter, i.e., non-degenerate input data, such a strategy can achieve the same running time as the RealAlgebraic variant
nodaL
, which is faster thandsumL
in these cases. For all other predicate calls, the running time would be similar to the running time achieved bydsumL
, plus the additional time for dag creation and floating-point filter evaluation. This will be a bit slower thandsumL
but is still likely to be faster thannodaL
.The different running times would be achieved on a per predicate basis, while currently one can select between
nodaL
ordsumL
per data set only. Since rarely any input set forces purely non-degenerate or degenerate predicate calls only, it is likely that such a strategy would perform better or at least as good as thenodaL
anddsumL
number types in most cases.Integration into RealAlgebraic. A relatively straightforward way to integrate exact floating-point algorithms into the dag evaluation stages of the RealAlgebraic framework is, to provide an ApproximationPolicy model based on error-free transfor- mations. We now propose how to implement such a model. Based on results from the previous section we discard the option to represent a number as a plain sum of floating-point numbers but choose floating-point expansions. Thus, our model may be called
Expansion_approximation_policy
(expaA
).Since not all functionality that
expaA
must provide, can be implemented based on expansions alone, it must incorporate bigfloat arithmetic, too. A number shallbe represented either as an expansion, or as a bigfloat. Arithmetic operations on expansions shall be performed exactly, operations on bigfloat numbers approximately. Note that the ApproximationPolicy interface permits exact operations and our current
ExpressionDagPolicymodels already detects when an arithmetic operation is exact. Once a dag node becomes known exactly in that way, its children will not be accessed any more and may be pruned. When an operation may not be performed with expansions, a conversion from expansion to bigfloat representation takes place. The concrete type of bigfloat arithmetic should be of no concern to
expaA
, hence it shall take another ApproximationPolicy model as template parameter, which provides the bigfloat arithmetic.For the implementation of arithmetic operations based on expansions within
expaA
, the same questions arise as for the implementation ofLocal_double_sum
and most answers can be taken from the previous sections. For example, floating- point exceptions should be handled by checking the magnitude of input numbers and avoiding them in the first place, and a single application of Compress suffices to bring an expansion into nearly optimal form. Conversion to a bigfloat number should be done using the efficient conversion method based on Monotonize from Section 4.2. Next to arithmetic operations,
expaA
has to provide some utility functions, e.g., rounding to a floating-point number, or read and write access to the exponent of a bigfloat number. Efficient implementations of these operations for expansions still have to be devised. One option not explored forLocal_double_sum
, is allowing interspersed zeros in expansions. This would simplify arithmetic operations, but complicate sign computation. Furthermore it requires more regular application of compression to keep the number of summands small.Another option for
expaA
not explored withLocal_double_sum
is, to not limit the number of summands, as this would require dynamic memory management. The advantage would be, that only an impending floating-point exception, or a division or radical operation will force conversion to a bigfloat number. Arithmetic operations on expansions may well be faster than bigfloat arithmetic on the complete set of representable numbers. Recall that only numbers x withη ≤ lsb(x), msb(x) ≤ τ are representable as expansion, which implies that only about 2000 bits are available inthe
binary64
format. If the number of summands is not limited, the question whento apply compression takes a different form. The trigger in form of the maximum number of summands is not available in that case, but the representation as expansion should still be kept compact to keep arithmetic operations efficient.
We think that using expansions for exact evaluation of polynomial expressions in the first stage of expression dag evaluation in the described way may lead to further improvements of expression dag based number types. While many implementation parameters are already determined through our experiments with
Local_double_-
sum
, some parameters are still open and new parameters arise, so there is still room for further research and experimentation.Conclusion
In this thesis we discussed the implementation of expression dag based number types for geometric applications. We intended to improve the efficiency of such number types by means of Algorithm Engineering following the cycle of (re-)design, analysis, implementation and experimental evaluation. Our stated goal was to narrow or close the performance gap between expression dag based number types and other approaches to Exact Geometric Computation. One major tool that we considered were error-free transformations. These are small and fast algorithms based on imprecise hardware floating-point operations, which nevertheless allow for exact numerical computations.
Implementation of Expression Dag Based Number Types. In Chapter 3 we presented our new expression dag based number type RealAlgebraic. Our design allows to easily create a variety of number types, which all provide the same func- tionality, but differ in the implementation of major components for expression dag based number types. We conducted experiments to find an optimal RealAlgebraic variant and compared several RealAlgebraic variants to other number types, and to some problem specific approaches to Exact Geometric Computation.
Concerning the implementation of expression dag based number types, we ob- served that which component of an implementation accounts for most of the running time is strongly dependent on the type of geometric problem and on properties of the input data. To achieve a reasonable efficiency over a wide range of problems, each component must be implemented efficiently. The default RealAlgebraic vari-
ant
nodaL
is more efficient than other expression dag based number types, sincethere are in each case one or two components, where RealAlgebraic features a better implementation.
In comparison to problem specific approaches to Exact Geometric Computation,
RealAlgebraicperforms the better, the more involved the geometric problem at hand is. For Delaunay triangulation,
nodaL
is about a factor of six slower than Shewchuk’s adaptive predicates on thedescartes
platform, cf. Figure 3.18 and Figure 4.3, and a factor of five to ten slower than theEpick
kernel on any platform. For Cartesian segment intersection,nodaL
is within 50% of theEpeck
kernel, except for theaxisdataset where the slowdown reaches a factor of four. For arrangements of circles,
nodaL
is faster than static algebraic predicates in a few cases, and for the problemof computing the Voronoi diagram of segments, RealAlgebraic is clearly the fastest 161
approach. This is a nice improvement over results reported for other expression dag based number types reported in the literature, see again Section 1.4.
We further identified a problem in current dag evaluation strategies, that may negate the main advantage of sharing common sub-expressions. In certain cases, common sub-expression may be evaluated as often as they are referenced within the dag. We propose a new algorithm TopPrecDrivArith which does not exhibit this behavior. The implementation and practical evaluation of that algorithm remains future work.
Exact Evaluation based on Error-Free Transformations. In Chapter 4 we presented improved algorithms based on error-free transformations for computing the sign of a sum of floating-point numbers exactly and used them for the implemen- tation of geometric predicates. Many authors have suggested to implement geometric predicates based on error-free transformations and Shewchuk’s adaptive predicates are considered state of the art implementations for the 2D and 3D orientation and incircle test. But despite their advantages over traditional software number types in terms of speed, exact computations based on error-free transformations do not seem to have found widespread usage in geometric applications.
The reason may be, that so far no-one has cast these techniques into a form that is efficient, yet simple to use. A major obstacle to this are the limitations of error-free transformations. Error-free transformations allow for approximately 2000 bits of precision only, before operations inevitably underflow or overflow. An implementation therefore has to either live with these limitations, or provide a fallback strategy, e.g., in form of a more general software number type.
We have presented new algorithms that allow for switching from floating-point expansions to such a fallback strategy efficiently. It is essential that our methods work correctly when the input expansions are close to overflow or underflow, as this may trigger switching to the fallback strategy in the first place. If the evaluation of an expression using expansions fails, our new conversion methods allow to resume the evaluation with more general software arithmetic at exactly the point where it failed. This basically means that it becomes unnecessary to store the expression for later re-evaluation.
Potential applications include static algebraic predicates, which reduce the sign computation of an algebraic number with an a-priori known structure to the evalu- ation of several polynomial expressions, or more generally the implementation of number types providing exact ring operations over integers or floating-point numbers. The integration of expansions into such number types should follow the guidelines given in Section 5.3. Since exact number types are the backbone of Exact Geometric Computation, many geometric application might benefit from the potential speed improvements.
Deferring Dag Construction. In Chapter 5 we discussed options to integrate exact computations based on error-free transformations into expression dag based number types. We presented a new approach to defer dag creation, which represents
a number exactly as a sum of floating-point numbers and avoids dag creation as long as such a representation can easily be obtained. This goes beyond the abilities of previous expression dag based number types, which allow to store a single floating- point number at most. Our experiments confirm that our extended approach is more effective than previous approaches for floating-point input and allows to avoid dag creation for larger sub-expressions. Furthermore it can lead to significant performance improvements, but only if there is a certain amount of degeneracies in the input data. The experimental results suggest, that exact computation with sums of floating-point numbers and error-free transformations may be better placed at a later stage of dag evaluation. The implementation and evaluation of such a strategy remain future work.
Nevertheless, we have achieved performance improvements over the default
RealAlgebraic variant for many types of input data, which cover all types of geo- metric problems considered, while rigorously treating all limitations of error-free transformations and without sacrificing user-friendliness or limiting the scope or generality of our number-type. We achieved performance improvements even in cases where conversion to a more general software number type is always necessary due to the presence of division and square root operations. We hope that our results with
RealAlgebraicserve as an incentive to try integrating exact computations based on error-free transformations into other approaches to Exact Geometric Computation as well.
1. Andrei Alexandrescu, ModernC++design: Generic programming and design patterns applied, Addison- Wesley, 2001.
2. Gene Myron Amdahl, Validity of the single processor approach to achieving large scale computing
capabilities, Proceedings of the spring joint computer conference (AFIPS ’67, spring), ACM, 1967, pp. 483–485.
3. Mohand O. Benouamer, Philippe Jaillon, Dominique Michelucci, and Jean-Michel Moreau, A lazy
exact arithmetic, Proceedings of the 11th Symposium on Computer Arithmetic (ARITH’93), IEEE, 1993, pp. 242–249.
4. boostC++Libraries,http://www.boost.org/.
5. Hervé Brönnimann, Christoph Burnikel, and Sylvain Pion, Interval arithmetic yields efficient dynamic
filters for computational geometry, Discrete Applied Mathematics 109 (2001), no. 1–2, 25–47. 6. Hervé Brönnimann, Ioannis Z. Emiris, Victor Y. Pan, and Sylvain Pion, Computing exact geometric
predicates using modular arithmetic with single precision, Proceedings of the 13th Symposium on Computational Geometry (SoCG’97), ACM, 1997, pp. 174–182.