Re: Stack allocation

2014-06-09 Thread Torbjörn Granlund
ni...@lysator.liu.se (Niels Möller) writes: t...@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

Re: Stack allocation

2014-06-09 Thread Niels Möller
suite). I see. 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. Perhaps alloca is not useful there? What stack usage do you get if you disable use of stack allocation? Regards, /Niels

Re: Stack allocation

2014-06-09 Thread Torbjörn Granlund
ni...@lysator.liu.se (Niels Möller) writes: What stack usage do you get if you disable use of stack allocation? A good question. My measurements are blunt, using 'ulimit -s'. I don't know how to measure it accurately without instrumenting the code. I assume that GMP will use around 1 KiB

Re: Stack allocation

2014-06-08 Thread Torbjörn Granlund
I made the automated GMP nightbuilds use at most 512 KiB. Now I realise that the testsuite needs might both overestimate and underestimate the actual requirements. The overestimate will come from tests/mpn where we call functions outside their normal operand size envelope. Underestimation might

Re: Stack allocation

2014-06-08 Thread Torbjörn Granlund
I decided to lower the TMP_SALLOC limit to a bit under 2^15 from the previous 2^16. With that change and a couple of other allocaton changes, GMP's now using less than 300 KiB of stack. The nightly builds attempt to enforce this limit. Torbjörn Please encrypt, key id 0xC8601622

Stack allocation

2014-06-06 Thread Torbjörn Granlund
This started as a thread in gmp-discuss about crashes due to stack overflow. I modified the TMP_SALLOC macro in gmp-impl.h to print its allocation argument. I did this as I suspected that we sometimes invoke the SALLOC form inappropriately for huge allocation. Below is a sample output. We

Re: Stack allocation

2014-06-06 Thread Torbjörn Granlund
t...@gmplib.org (Torbjörn Granlund) writes: I modified the TMP_SALLOC macro in gmp-impl.h to print its allocation argument. I did this as I suspected that we sometimes invoke the SALLOC form inappropriately for huge allocation. After adding printing of __FILE__ and __LINE__ to the