Speed of GMP relative to MPFR for quad precision calculations

Jerry lanceboyle at qwest.net
Fri Nov 2 22:04:47 CET 2012


On Nov 2, 2012, at 1:01 AM, Zimmermann Paul wrote:

>       Jerry,
> 
>> From: Jerry <lanceboyle at qwest.net>
>> Date: Thu, 1 Nov 2012 16:30:35 -0700
>> 
>> Hi,
>> 
>> I recently started using MPFR in an application where I am certain that quad precision would be adequate. I have been using MPFR with 30 digits precision. But I just now learned that MPFR provides _exactly_ the specified precision and that GMP uses whatever number of machine words is necessary to meet the specified precision. That makes me think that MPFR is slower than GMP floats.
>> 
>> Indeed, MPFR is running more slowly than I hoped. Would GMP's floating point facility run faster in this application (quad precision) than MPFR? I need only multiplies and adds, and conversion back to double precision at the end.
>> 
>> Thanks,
>> Jerry
> 
> maybe GMP mpf will run slightly faster, but timings should be very close, since
> both rely on GMP mpn layer. See http://www.mpfr.org/mpfr-3.1.0/timings.html
> for some timings for larger precisions.
> 
> Paul Zimmermann

Thanks, Paul. I'm not sure how those tests map to my two-core Intel on a Mac, for 30-digit precision, but it is useful to know what is possible.

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.

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.

Thanks again,
Jerry

P.S. I don't see the Ada binding listed at mpfr.org.


More information about the gmp-discuss mailing list