[MPFR] multiplications vs. subtractions: which one is faster?
patrick.pelissier at gmail.com
Sun Jul 15 09:57:32 CEST 2007
Here are some benchmarks of MPFR 2.2.1 on Pentium M with prec=3000
mpfr_sub: 553 / 607.50 / 818
mpfr_mul: 26572 / 26906.87 / 27175
mpfr_add: 551 / 594.00 / 799
Subtraction version: 6400*607=3,884,800 ticks
Multiplication version: 138*594+138*26906 = 3,795,000 ticks
Taking into account the cache and the branch prediction, I think both
versions are equal.
If you reduce the precision, the multiplication version should be
faster, whereas the subtraction version should be faster if you
On 7/15/07, Michael <comtech.usa at gmail.com> wrote:
> Hi all,
> In my project I am seeking ultimate speed. In one small part of my
> program using GMP/MPFR, I am facing the following two design choices:
> The operands/variables are of 1000 digits precision in MPFR mpfr_t
> format(floating point numbers).
> 1. Using two for loops with around 80*80=6400 substractions;
> 2. Using one for loop 7+15+21+32+63=138 additions and 138 multiplications,
> Which approach will be faster? Please shed some lights on me from your
> Since the change in design is complicated (the MPFR programming is
> much like arranging registers in assembly language programming), I
> want to first do some thought experimenting and comparison.
> Moreover, I would appreciate any further
> suggestions/advice/comments/tips on how to improve speed using MPFR
> Thanks a lot!
More information about the gmp-discuss