GMP 6 the incomatible GMP?

Niels Möller nisse at lysator.liu.se
Tue Jan 8 13:07:55 CET 2013


Torbjorn Granlund <tg at gmplib.org> writes:

> * There is a serial memory dependency problem, making the allocation
>   check at least one more cache latency away.  I don't think OoO
>   execution will be able to hide that, as this is used.

And that should matter for small bignums only, right, if we care about
relative overhead? Then, it's desirable to have *small* allocs directly
in the mpz_t struct.

> * There is a slight type error mixing limbs and sizes.  The ASL patch by
>   Per Olofsson will require many limbs to represent a size.

I think this can be solved in a type safe way, no matter which of
mp_limb_T and mp_size_t is the larger type. One would need to use
something more complicated than _mp_d[-1] (and this shouold be hidden in
some macro anyay), involving something like

struct mp_storage
{
  mp_size_t alloc;
  mp_limb_t limbs[1]; /* Variable size */
};

Use this when allocating, pass around pointers to the limbs member, and
to access the alloc field, do some casting and a subtraction of
offsetof(struct mp_storage, limbs).

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