Stack allocation

Niels Möller nisse at lysator.liu.se
Mon Jun 9 05:33:03 UTC 2014


tg at gmplib.org (Torbjörn Granlund) writes:

> I decided to lower the TMP_SALLOC limit to a bit under 2^15 from the
> previous 2^16.

What's the a relative cost of allocation vs simple operations like
mpn_add_n? For 2^15 limit, that's 512 limbs (on 64-bit). I guess
overhead of a malloc call might be comparable to an mpn_add_n with n =
512, but it ought to be a lot faster than, e.g., an n = 256 mpn_mul_n.

Would it make sense to lower the limit further to, say, 128 limbs?

> With that change and a couple of other allocaton
> changes, GMP's now using less than 300 KiB of stack.

Nice! That seems very reasonable on current desktop and server machines,
but it might still be a bit large if people use gmp on embedded systems.

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