Speed of GMP relative to MPFR for quad precision calculations

Jerry lanceboyle at qwest.net
Sun Nov 18 01:01:25 CET 2012

On Nov 2, 2012, at 2:42 PM, Zimmermann Paul wrote:

>       Jerry,
>> BTW, I _am_ correct in thinking that setting the precision to 30 digits is roughly quad precision, right? I'm still studying the docs and so far have found only references to setting precision by bits, not digits. I believe I got the "digits" idea from an example.
> quad precision (as defined by IEEE 754) is a 128-bit format, with 113-bit
> significand. Thus to compare with MPFR you should use mpfr_init2 (x, 113).
>> I am seeing a piece of code that takes about two minutes to execute in double precision taking about two _hours_ in 30-digit precision. Does that sound about right? FWIW, I am using MPFR through the Ada binding.
> as already said by Torbjörn, it might be the Ada binding contributes to the
> overhead, but if you are doing 100% arithmetic, a factor of up to 50 between
> MPFR and hardware is possible for double precision.
> Paul Zimmermann
> PS: maybe this becomes off-topic for the gmp-discuss list...

Hell again,

I just want to finalize this discussion with what I learned about the Ada bindings.

The thin binding runs at essentially the same speed as C in a few examples that I tried.

The thick binding, which is what I was using at the time of my original post, runs much slower and does a _lot_ more computation. I have switched to the thin binding and now believe that I am getting expected speeds.

FWIW, this is an excerpt from the comments in one of the thick binding files:

"This packages uses a new approach to dynamically adjust the precision of a
MPFR_Float, everytime a value is computed (and not, as mpfr does, at the
initialization of the mpfr_t variable). The goal is to try to have a precision
that is of the same order of magnitude as the accuracy."

I don't recall seeing a link to the Ada bindings on the MPFR web site. If would you like to do so, the project is here:


Thanks again for making these numerical packages--it has helped me immensely in my work.


More information about the gmp-discuss mailing list