Rethinking GMP's configure

Niels Möller nisse at lysator.liu.se
Tue Dec 6 09:38:07 CET 2011


Torbjorn Granlund <tg at gmplib.org> writes:

> I'd like to move away from a specifically configured lib to a
> default-is-fat model.

Makes sense to me. Either --with-cpu=ALL or --with-cpu=HOST would be a
sensible default.

> Note that I am not suggesting any change to ABI selection.  I think we
> should still go for the fastest ABI by default.

I disagree, but that's a minor thing in this context.

> First, let's admit there will be some overhead.  At some level, there
> will be a need to jump through a table, initiated for the run-time CPU.
> This indirection costs a few cycles each time.  But note that in a
> shared library, we typically access data through a GOT (global offset
> table) and call functions indirectly through a PLT (procedure linkage
> table).  I think we could stay within the overhead of shared library
> calls, if we do things right.  (For ELF, that is, where we can control
> such things.)

I think I suggested, some time ago, that one could overwrite the table
entries in the PLT, with no *additional* indirections. But that may not
work. If I understand things correctly, there's no *the* PLT, there's a
PLT in each loadable object (executable or shared library file). And
then I have already forgotten how that is supposed to work with function
pointers.

But for gmp-internal calls, we can jump through the table in the same
way for both static and dynamic linking; the PLT need not be involved.

And the overhead should be omitted completely when building for a
single cpu type.

> To decrease overhead, perhaps mainly in the static library, code
> selection can be made not at the calls to the most primitive functions,
> but a bit "higher"; we need to compile such functions several times with
> fixed primitive functions (i.e., with calls to these going directly, not
> through a jump table).

Which functions are candidates for this treatment?

> 2. When using an optional assembly primitive, use a run-time test if the
>    optional primitive is provided by *any* but not all configured CPUs,
>    exclude it if it is never available, and include it without a
>    run-time test if it is always available.

Sounds like the most invasive part of this change.

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