[Gmp-commit] /var/hg/gmp: (relspeed_div_1_vs_mul_1): Prefer mpn_pi1_bdiv_q_1.

mercurial at gmplib.org mercurial at gmplib.org
Tue Feb 7 19:48:20 UTC 2017


details:   /var/hg/gmp/rev/95d022abf322
changeset: 17231:95d022abf322
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Tue Feb 07 20:48:14 2017 +0100
description:
(relspeed_div_1_vs_mul_1): Prefer mpn_pi1_bdiv_q_1.

diffstat:

 tune/tuneup.c |  29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diffs (63 lines):

diff -r 69c512606e05 -r 95d022abf322 tune/tuneup.c
--- a/tune/tuneup.c	Tue Feb 07 16:50:14 2017 +0100
+++ b/tune/tuneup.c	Tue Feb 07 20:48:14 2017 +0100
@@ -1,6 +1,6 @@
 /* Create tuned thresholds for various algorithms.
 
-Copyright 1999-2003, 2005, 2006, 2008-2016 Free Software Foundation, Inc.
+Copyright 1999-2003, 2005, 2006, 2008-2017 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -1201,7 +1201,6 @@
 relspeed_div_1_vs_mul_1 (void)
 {
   const size_t max_opsize = 100;
-  const mp_limb_t fake_big_base = (~CNST_LIMB(0)) / 3;
   mp_size_t n;
   long j;
   mp_limb_t rp[max_opsize];
@@ -1213,10 +1212,10 @@
   multime = 0;
   for (n = max_opsize; n > 1; n--)
     {
-      mpn_mul_1 (rp, ap, n, fake_big_base);
+      mpn_mul_1 (rp, ap, n, MP_BASES_BIG_BASE_10);
       speed_starttime ();
       for (j = speed_precision; j != 0 ; j--)
-	mpn_mul_1 (rp, ap, n, fake_big_base);
+	mpn_mul_1 (rp, ap, n, MP_BASES_BIG_BASE_10);
       multime += speed_endtime () / n;
     }
 
@@ -1224,12 +1223,26 @@
   for (n = max_opsize; n > 1; n--)
     {
       /* Make input divisible for good measure.  */
-      ap[n - 1] = mpn_mul_1 (ap, ap, n - 1, fake_big_base);
-
-      mpn_divexact_1 (rp, ap, n, fake_big_base);
+      ap[n - 1] = mpn_mul_1 (ap, ap, n - 1, MP_BASES_BIG_BASE_10);
+
+#if HAVE_NATIVE_mpn_pi1_bdiv_q_1
+	  mpn_pi1_bdiv_q_1 (rp, ap, n, MP_BASES_BIG_BASE_10,
+			    MP_BASES_BIG_BASE_BINVERTED_10,
+			    MP_BASES_BIG_BASE_CTZ_10);
+#else
+	  mpn_divexact_1 (rp, ap, n, MP_BASES_BIG_BASE_10);
+#endif
       speed_starttime ();
       for (j = speed_precision; j != 0 ; j--)
-	mpn_divexact_1 (rp, ap, n, fake_big_base);
+	{
+#if HAVE_NATIVE_mpn_pi1_bdiv_q_1
+	  mpn_pi1_bdiv_q_1 (rp, ap, n, MP_BASES_BIG_BASE_10,
+			    MP_BASES_BIG_BASE_BINVERTED_10,
+			    MP_BASES_BIG_BASE_CTZ_10);
+#else
+	  mpn_divexact_1 (rp, ap, n, MP_BASES_BIG_BASE_10);
+#endif
+	}
       divtime += speed_endtime () / n;
     }
 


More information about the gmp-commit mailing list