[Ecls-list] computing results into preallocated bignums

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Wed Sep 9 12:25:32 UTC 2009


On Wed, Sep 9, 2009 at 1:27 AM, Nils Bruin<nbruin at cecm.sfu.ca> wrote:
> ------------------------------------------------------------------------------
>                case t_bignum:
>                         i = x->big.big_size;
>                         if (i < 0) i = -i;
>                         j = y->big.big_size;
>                         if (j < 0) j = -j;
>                         if (i > j ) dim = (i+1); else dim = (j+1);
>                         z = ecl_alloc_compact_object(t_bignum, (cl_index) (dim*sizeof(mp_limb_t)));
>                         z->big.big_limbs = ECL_COMPACT_OBJECT_EXTRA(z);
>                         z->big.big_size = 0;
>                         z->big.big_dim = dim;
>                         _ecl_big_add(z, x, y);
> -------------------------------------------------------------

The only perhaps "corner" case in which this may lead to worse
performance is when the result is not a bignum, but an integer that
fits into a computer word. In that case "z" has to be converted to
that, and the bignum should be discarded. Currently this leads to _no_
additional memory being "consed" or allocated precisely because of
using preallocated registers.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list