[Gmp-commit] /var/hg/gmp: Measure mpn_sbpi1_bdiv_r.

mercurial at gmplib.org mercurial at gmplib.org
Fri Jul 21 16:32:35 UTC 2017


details:   /var/hg/gmp/rev/bf9a009a2025
changeset: 17473:bf9a009a2025
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Fri Jul 21 18:32:31 2017 +0200
description:
Measure mpn_sbpi1_bdiv_r.

diffstat:

 tune/common.c |  10 ++++++++--
 tune/speed.c  |   1 +
 tune/speed.h  |  41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

diffs (96 lines):

diff -r bf11a6628feb -r bf9a009a2025 tune/common.c
--- a/tune/common.c	Thu Jul 20 03:18:51 2017 +0200
+++ b/tune/common.c	Fri Jul 21 18:32:31 2017 +0200
@@ -225,8 +225,9 @@
   fprintf (stderr, "speed_measure() could not get %d results within %.1f%%\n",
 	   e, (TOLERANCE-1.0)*100.0);
   fprintf (stderr, "    unsorted         sorted\n");
-  fprintf (stderr, "  %.12f    %.12f    is about 0.5%%\n",
-	   t_unsorted[0]*(TOLERANCE-1.0), t[0]*(TOLERANCE-1.0));
+  fprintf (stderr, "  %.12f    %.12f    is about %.1f%%\n",
+	   t_unsorted[0]*(TOLERANCE-1.0), t[0]*(TOLERANCE-1.0),
+	   100*(TOLERANCE-1.0));
   for (i = 0; i < numberof (t); i++)
     fprintf (stderr, "  %.09f       %.09f\n", t_unsorted[i], t[i]);
 
@@ -895,6 +896,11 @@
   SPEED_ROUTINE_MPN_PI1_BDIV_Q (mpn_dcpi1_bdiv_q);
 }
 double
+speed_mpn_sbpi1_bdiv_r (struct speed_params *s)
+{
+  SPEED_ROUTINE_MPN_PI1_BDIV_R (mpn_sbpi1_bdiv_r);
+}
+double
 speed_mpn_mu_bdiv_q (struct speed_params *s)
 {
   SPEED_ROUTINE_MPN_MU_BDIV_Q (mpn_mu_bdiv_q, mpn_mu_bdiv_q_itch);
diff -r bf11a6628feb -r bf9a009a2025 tune/speed.c
--- a/tune/speed.c	Thu Jul 20 03:18:51 2017 +0200
+++ b/tune/speed.c	Fri Jul 21 18:32:31 2017 +0200
@@ -382,6 +382,7 @@
   { "mpn_dcpi1_bdiv_qr",       speed_mpn_dcpi1_bdiv_qr       },
   { "mpn_sbpi1_bdiv_q",        speed_mpn_sbpi1_bdiv_q        },
   { "mpn_dcpi1_bdiv_q",        speed_mpn_dcpi1_bdiv_q        },
+  { "mpn_sbpi1_bdiv_r",        speed_mpn_sbpi1_bdiv_r        },
 
   { "mpn_broot",               speed_mpn_broot,    FLAG_R },
   { "mpn_broot_invm1",         speed_mpn_broot_invm1, FLAG_R },
diff -r bf11a6628feb -r bf9a009a2025 tune/speed.h
--- a/tune/speed.h	Thu Jul 20 03:18:51 2017 +0200
+++ b/tune/speed.h	Fri Jul 21 18:32:31 2017 +0200
@@ -299,6 +299,7 @@
 double speed_mpn_dcpi1_bdiv_qr (struct speed_params *);
 double speed_mpn_sbpi1_bdiv_q (struct speed_params *);
 double speed_mpn_dcpi1_bdiv_q (struct speed_params *);
+double speed_mpn_sbpi1_bdiv_r (struct speed_params *);
 double speed_mpn_mu_bdiv_q (struct speed_params *);
 double speed_mpn_mu_bdiv_qr (struct speed_params *);
 double speed_mpn_broot (struct speed_params *);
@@ -2033,6 +2034,46 @@
     TMP_FREE;								\
     return t;								\
   }
+#define SPEED_ROUTINE_MPN_PI1_BDIV_R(function)				\
+  {									\
+    unsigned   i;							\
+    mp_ptr     dp, tp, ap;						\
+    mp_limb_t  inv;							\
+    double     t;							\
+    TMP_DECL;								\
+									\
+    SPEED_RESTRICT_COND (s->size >= 1);					\
+									\
+    TMP_MARK;								\
+    SPEED_TMP_ALLOC_LIMBS (ap, 2*s->size, s->align_xp);			\
+    SPEED_TMP_ALLOC_LIMBS (dp, s->size, s->align_yp);			\
+    SPEED_TMP_ALLOC_LIMBS (tp, 2*s->size, s->align_wp2);		\
+									\
+    MPN_COPY (ap,         s->xp, s->size);				\
+    MPN_COPY (ap+s->size, s->xp, s->size);				\
+									\
+    /* divisor must be odd */						\
+    MPN_COPY (dp, s->yp, s->size);					\
+    dp[0] |= 1;								\
+    binvert_limb (inv, dp[0]);						\
+    inv = -inv;								\
+									\
+    speed_operand_src (s, ap, 2*s->size);				\
+    speed_operand_dst (s, tp, 2*s->size);				\
+    speed_operand_src (s, dp, s->size);					\
+    speed_cache_fill (s);						\
+									\
+    speed_starttime ();							\
+    i = s->reps;							\
+    do {								\
+      MPN_COPY (tp, ap, 2*s->size);					\
+      function (tp, 2*s->size, dp, s->size, inv);			\
+    } while (--i != 0);							\
+    t = speed_endtime ();						\
+									\
+    TMP_FREE;								\
+    return t;								\
+  }
 #define SPEED_ROUTINE_MPN_MU_BDIV_Q(function,itchfn)			\
   {									\
     unsigned   i;							\


More information about the gmp-commit mailing list