mpn_mul is embarrassingly slow

paul zimmermann Paul.Zimmermann at inria.fr
Tue Apr 24 12:11:34 UTC 2018


       Dear Torbjörn,

> What do you think about this stopgap change?

I would entirely drop all the squaring-related stuff from mpn_mul:
the user/developer should call mpn_sqr instead (see my previous mail).

Then the code would become:

   if (BELOW_THRESHOLD (vn, MUL_TOOM22_THRESHOLD))
     {
       mpn_mul_basecase (prodp, up, un, vp, vn);
       return prodp[un + vn - 1];	/* historic */
     }

   if (un == vn)
       return mpn_mul_n (prodp, up, vp, un);

   ...

(I believe it is vn and not un that should be compared to MUL_TOOM22_THRESHOLD.)

Paul


More information about the gmp-devel mailing list