mpz_t caching

Niels Möller nisse at lysator.liu.se
Mon Sep 7 10:36:51 UTC 2015


Vincent Lefevre <vincent at vinc17.net> writes:

> I suspect that the cause
> of the difference is that with mpz_t caching, the mpz_t's are
> preallocated with a size that is large enough to avoid internal
> reallocations in GMP (thus memory copies), but in such a case, the
> right solution would be to use mpz_init2.

The lazy initialization discussed a few days ago might also help a bit,
then limb storage isn't allocated until the first assignment to the
variable, and then reallocations should be less likely.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list