Re: big number arithmetic

Felix von Leitner <[email protected]> Sat, 24 Mar 2007 10:21:28 +0100
Newsgroups gmane.comp.djb.bignum.devel
Message-ID <[email protected]>
> > My hunch is that that's because gmp's schoolbook multiplication is not
> > very fast.  I haven't polished mine yet, but it's significantly faster
> > than even tomfastmath's one, which in turn beats gmp.
> Can you prove those assertions with some figures? Here are some cycles
> with gmp-4.2.1 on a Pentium M:

I don't have a Pentium M handy right now, but here are my measurements
for a 1024 bit multiplicate (1024x1024->2045 bits) on my Core 2 Duo
notebook (all 32-bit mode):

my code:	7716 cycles
gmp:		9600 cycles
tomfastmath:	9156 cycles

> Can you provide cycle numbers for tomfastmath and your code?

1024 bits == 32 words.

I called mpz_mul for gmp and fp_mul for tomfastmath.  In my code I'm
cheating a little because I directly call the 1024x1024 bit multiply
routine.  Once I finish my library, there will be added overhead to
check that there is enough space allocated.

I implemented Karatsuba, too, but that implementation is comparatively
unoptimized so it's not fair to use it for comparison.

Felix