mpn_invert implementing ApproximateReciprocal.

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Mon Dec 14 20:40:35 CET 2009


Ciao,

>   I prefer not to commit, when I'm aware of a test failed by the new code.
>
> I think that's a very wise principle!  :-)

It depends. One of the acceptable behaviour for the "principle" above is:
"do commit before any test" :-)

>   The measured BINV_NEWTON_THRESHOLD is probably too high because of this.
>
> You're right.  Swapping the measurement order is also not right, as the
> code is written.  I don't see how to do this easily, unless we assume
> mpn_mul will never be relevant here.  I think I'll do that for now.

May I suggest an inelegant solution? Remeasure BINV_NEWTON_:

diff -r 47b27ccf9a34 tune/tuneup.c
--- a/tune/tuneup.c	Mon Dec 14 17:31:58 2009 +0100
+++ b/tune/tuneup.c	Mon Dec 14 20:34:26 2009 +0100
@@ -1071,10 +1071,12 @@
 void
 tune_binvert (void)
 {
+  const char *threshold1 = "BINV_NEWTON_THRESHOLD";
   static struct param_t  param;
   param.function = speed_mpn_binvert;

-  param.name = "BINV_NEWTON_THRESHOLD";
+  param.name = threshold1;
+  param.noprint = 1;
   param.max_size = 5000;
   one (&binv_newton_threshold, &param);

@@ -1083,10 +1085,17 @@
   param.min_size = binv_newton_threshold;
   param.max_size = 500;
   one (&binv_mulmod_bnm1_threshold, &param);
-  if (binv_mulmod_bnm1_threshold <= binv_newton_threshold)
+  if (binv_mulmod_bnm1_threshold <= binv_newton_threshold) {
     print_define_remark (param.name, 0, "always when newton");
-  else
+    param.name = threshold1;
+    param.noprint = 0;
+    param.min_size = mulmod_bnm1_threshold;
+    param.max_size = binv_newton_threshold;
+    one (&binv_newton_threshold, &param);
+  } else {
     print_define (param.name, binv_mulmod_bnm1_threshold);
+    print_define (threshold1, binv_newton_threshold);
+  }
 }

 void


-- 
http://bodrato.it/software/



More information about the gmp-devel mailing list