mpn_invert implementing ApproximateReciprocal.

Paul Zimmermann Paul.Zimmermann at loria.fr
Fri Dec 11 18:04:29 CET 2009


> The size where the code starts winning is very nice!  But I expected a
> bigger effect of bnm1.  It is possible to make mpn_invert and mpn_binvert
> run at about the same speed for large sizes.  But this is not currently
> the case:
> 
> 10        0.000000615  #0.000000163
> 20        0.000001819  #0.000000586
> 40        0.000005808  #0.000002005
> 80        0.000018237  #0.000007122
> 160       0.000056544  #0.000026310
> 320       0.000168331  #0.000078748
> 640       0.000492760  #0.000240207
> 1280      0.001181596  #0.000658926
> 2560      0.002886252  #0.001624284
> 5120      0.006674533  #0.003929748
> 10240     0.015298000  #0.009517735
> 20480     0.034995000  #0.021580000
> 40960     0.078814000  #0.051110000
> 81920     0.171726000  #0.115397000

it would be good to understand where this discrepancy between mpn_invert and
mpn_binvert comes from. Marco, I suggest you disable the while-correction-loop
in mpn_invert to see the difference (if any) it makes with speed (of course
the result will no longer be correct, but this is just to get an idea of the
slowdown due to the corrections).

Another idea would be to use short products for A X_h and T_m X_h, but then
one would have to redesign the algorithm and thus the proof.

Paul


More information about the gmp-devel mailing list