[Ecls-list] computing results into preallocated bignums

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Wed Sep 9 07:30:10 UTC 2009

On Wed, Sep 9, 2009 at 1:27 AM, Nils Bruin<nbruin at cecm.sfu.ca> wrote:
> If we could preallocate limb space for bignums in such a way that GMP
> doesn't need to resize it, one could avoid the use of registers
> altogether. Jason Moxham responded to the suggestion by making available
> macros that would guarantee space needs (it's pretty clear how much space
> an answer is going to need, but MPIR development wants to reserve the
> right to use a little more, should that ever be beneficial for speed)

Indeed bignum operations and special function arithmetics is something
yet to be optimized in ECL. Your suggestion is interesting and, if
used, it should be somehow encapsulated, but it may be worth. I am
only worried about one thing: the code would bind ECL to MPIR's macros
and not all platforms use MPIR -- some still use GMP --. In other
words, would the code still be backwards compatible?

> I tried out the following program: [...]
> OLD: 9182, 9189, 9181 [but also some much lower values at the start]
> NEW: 8156, 8144, 8144

Could you redo the timings using Common Lisp's TIME macro, like in

(TIME (test ... ))

This would be more stable because TIME takes care of performing
garbage collection _outside_ the addition loop. It would also return
numbers about consed memory, which we could compare.


Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)

More information about the ecl-devel mailing list