memory problem with GMP 5
Paul Zimmermann
Paul.Zimmermann at loria.fr
Fri Jan 15 14:04:16 CET 2010
Hi,
I'm not sure this is a bug, but at least it is annoying and I thought I should
report it.
I've noticed that GMP 5 uses much more internal memory for big multiplications
than previous versions. For example with the following program on a 64-bit
Core 2, top gives a maximal "RES" memory of 1.6g for GMP 4.3.2, and 2.4g for
GMP 5, i.e., 50% more!
Note that the inputs a and b use about 0.5g, as does the result a*b. Thus
GMP 4.3.2 uses extra memory of 0.6g to perform the product, whereas GMP 5
uses 1.4g.
With a given memory limit, this means that GMP 4.3.2 is able to perform larger
computations than GMP 5.
Paul
#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"
int
main()
{
mp_ptr a, b, c;
mp_size_t sa = 25465231, sb = 36985114;
a = malloc (sa * sizeof (mp_limb_t));
b = malloc (sb * sizeof (mp_limb_t));
c = malloc ((sa + sb) * sizeof (mp_limb_t));
mpn_random (a, sa);
mpn_random(b, sb);
printf ("start product\n");
fflush (stdout);
mpn_mul (c, a, sa, b, sb);
printf ("end product\n");
fflush (stdout);
return 0;
}
More information about the gmp-bugs
mailing list