reproducibility of GMP random functions vs limb size and GMP version

Paul Zimmermann Paul.Zimmermann at
Thu Sep 16 04:24:44 CEST 2010

       Hi Pedro,

> Is there such guarantee for a change in GMP version at all?
> I remember a discussion with Torbjörn (previous to May 2003), while the
> new MT generator was being prepared, where he stated precisely that such
> a guarantee didn't exist. I'm afraid I've lost these emails, though.

as far as such a change is documented in the new version, it is fine for us.
We were more concerned for a difference between the same GMP version on
different hardware, but Torbjörn's answer clarifies this.

> Since 2005, I had the intention of changing the seeding function to a
> much faster one (in the order of 100x faster), but that change would
> make the numbers obtained with a seed to be different to those obtained
> with the same seed in the current version.

do you mean gmp_randseed_ui() would be 100x faster, or say mpz_urandomb()?

> However, Torbjörn wasn't happy of that change to the seeding function,
> presumably because he preferred to keep consistency of the generated
> numbers across versions.
> I wonder, however, if it would be enough for you to have PRNG state
> export/import functions in order to overcome a potential problem of that
> nature.

I'm not sure it would help us.

One difficulty for us is to check we get similar results on different
hardware. Since we can run MPFR's "make check" on only one hardware at a time,
our current approach is to hard-code the results of the random functions
in our tests. (I wonder how GMP's "make check" does check reproducibility
among different hardware.) If the formulas used by the GMP random functions
were documented, we could write a reference implementation (possibly depending
on the GMP version).

Paul Zimmermann

More information about the gmp-devel mailing list