Benchmarking GMP gives poor results for small numbers

Karl Hasselström kha at treskal.com
Wed Mar 9 11:10:01 CET 2005


On 2005-03-09 04:47:52 -0500, Richard Cavell wrote:

> So I don't want to knock GMP code so much as I want to tell people
> that for numbers less than about 1024 bits, I strongly recommend
> using your own code for performance.

If you find the overhead for mpz to be too great, try GMP's mpn
functions. They have a lot less overhead, but are more work to use
because you get to do all the bookkeping yourself. It'll be a lot less
work than actually coding your own bignum functions, though.

For small enough numbers, even mpn will lose to your homegrown bignums
because they can't be inlined or specialized for specific sizes etc.,
but I suspect that the breakeven point will be less than 1024 bits.

-- 
Karl Hasselström, kha at treskal.com
      www.treskal.com/kalle


More information about the gmp-discuss mailing list