Boost logo

Boost :

Subject: [boost] [multiprecision] Some rvalue reference experiments (performance inhancements #1)
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-06-30 13:04:52


I've started to work through some of the points that came up in the
multiprecision review, starting with further rvalue reference support.

The idea (due to Marc Glisse) was to add operator overloads that look
something like:

Number&& operator+(Number&&a, const Number& b)
   return static_cast<Number&&>(a += b);

Using my Polynomial Horner evaluation scheme as an example the number of
temporaries dropped as follows:

Type #
No expression templates, no rvalue refs 24
No expression templates, rvalue refs 1
Expression template 0

Which is pretty impressive, but not necessarily typical usage, so by way of
"real world" tests, I compared the times taken to evaluate Boost.Math's
Bessel function test cases to 50 decimal places:

Library Time/s
# Allocations

MPFR/mpreal (no ET's or rvalue refs) 9.4 13226029
MPFR/mpfr_class (ET's) 6.3 3948316
MPFR/mp_number(ET's) 6.0 2683646
GMP/mp_number(no ET's) 5.2 4186977
GMP/mp_number(ET's) 5.0 2594441

As you can see the number of allocations required when using mp_number with
ET's turned off is almost double that without, I guess this is because many
statements are similar to:

a = b op c;

Where a temporary is still required when relying on rvalue refs, but not for
expression templates.

Having said that the times are getting much closer now....


Boost list run by bdawes at, gregod at, cpdaniel at, john at