gmpxx and allocation

Richard B. Kreckel kreckel at ginac.de
Tue Mar 6 09:47:03 CET 2012


Hi!

On 03/06/2012 01:07 AM, Marc Glisse wrote:
> * For the small object optimization, I used flint's fmpz_t. It computes
> with integers as long as numbers fit in a pointer minus a few bits and
> only uses gmp when they don't (and in that case uses a pool approach).
> Note that this is a classical technique (some standard libraries use it
> for std::string, integers in guile (scheme) are implemented that way),
> flint was just the first one I found for this test. If done properly,
> one can get a speed within a small factor of builtin operations as long
> as the numbers fit (although it is hard to convince the compiler to
> generate optimal code without writing the whole function in asm).

Can you, please, check the assembler code? Are there still calls to 
operator+, operator-, and operator*, or are these being inlined somehow? 
(I suppose the calls are there: CLN also does the fixnum/bignum thing 
and the speedup is about the same with the optimzation coming from 
avoiding allocation, deallocation, and assignment and the speed being 
limited by the three arithmetic operator calls.)

Bye!
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the gmp-discuss mailing list