[Gmp-commit] /var/hg/gmp: speed support for mpn_div_qr_2.

mercurial at gmplib.org mercurial at gmplib.org
Sun Mar 20 20:23:36 CET 2011


details:   /var/hg/gmp/rev/73696857a067
changeset: 14073:73696857a067
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Sun Mar 20 20:23:07 2011 +0100
description:
speed support for mpn_div_qr_2.

diffstat:

 ChangeLog     |   6 ++++++
 tune/common.c |  11 +++++++++++
 tune/speed.c  |   3 +++
 tune/speed.h  |  44 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+), 0 deletions(-)

diffs (110 lines):

diff -r ca5189aa27ce -r 73696857a067 ChangeLog
--- a/ChangeLog	Sun Mar 20 18:51:36 2011 +0100
+++ b/ChangeLog	Sun Mar 20 20:23:07 2011 +0100
@@ -1,5 +1,11 @@
 2011-03-20  Niels Möller  <nisse at lysator.liu.se>
 
+	* tune/common.c (speed_mpn_div_qr_2_norm): New function.
+	(speed_mpn_div_qr_2_unnorm): New function.
+	* tune/speed.c (routine): Recognize above functions.
+	* tune/speed.h: Declarations for above functions.
+	(SPEED_ROUTINE_MPN_DIV_QR_2): New macro.
+
 	* tests/mpn/t-div.c (main): Added tests for mpn_divrem_2 and
 	mpn_div_qr_2.
 
diff -r ca5189aa27ce -r 73696857a067 tune/common.c
--- a/tune/common.c	Sun Mar 20 18:51:36 2011 +0100
+++ b/tune/common.c	Sun Mar 20 20:23:07 2011 +0100
@@ -682,6 +682,17 @@
 }
 
 double
+speed_mpn_div_qr_2_norm (struct speed_params *s)
+{
+  SPEED_ROUTINE_MPN_DIV_QR_2 (mpn_div_qr_2, 1);
+}
+double
+speed_mpn_div_qr_2_unnorm (struct speed_params *s)
+{
+  SPEED_ROUTINE_MPN_DIV_QR_2 (mpn_div_qr_2, 0);
+}
+
+double
 speed_mpn_mod_1 (struct speed_params *s)
 {
   SPEED_ROUTINE_MPN_MOD_1 (mpn_mod_1);
diff -r ca5189aa27ce -r 73696857a067 tune/speed.c
--- a/tune/speed.c	Sun Mar 20 18:51:36 2011 +0100
+++ b/tune/speed.c	Sun Mar 20 20:23:07 2011 +0100
@@ -230,6 +230,9 @@
   { "mpn_divrem_2_div",  speed_mpn_divrem_2_div,    },
   { "mpn_divrem_2_inv",  speed_mpn_divrem_2_inv,    },
 
+  { "mpn_div_qr_2_norm", speed_mpn_div_qr_2_norm,   },
+  { "mpn_div_qr_2_unnorm", speed_mpn_div_qr_2_unnorm, },
+
   { "mpn_divexact_1",    speed_mpn_divexact_1,    FLAG_R },
   { "mpn_divexact_by3",  speed_mpn_divexact_by3          },
 
diff -r ca5189aa27ce -r 73696857a067 tune/speed.h
--- a/tune/speed.h	Sun Mar 20 18:51:36 2011 +0100
+++ b/tune/speed.h	Sun Mar 20 20:23:07 2011 +0100
@@ -187,6 +187,8 @@
 double speed_mpn_divrem_2 __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_divrem_2_div __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_divrem_2_inv __GMP_PROTO ((struct speed_params *s));
+double speed_mpn_div_qr_2_norm __GMP_PROTO ((struct speed_params *s));
+double speed_mpn_div_qr_2_unnorm __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_fib2_ui __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_matrix22_mul __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_hgcd __GMP_PROTO ((struct speed_params *s));
@@ -2764,6 +2766,48 @@
     return t;								\
   }
 
+#define SPEED_ROUTINE_MPN_DIV_QR_2(function, norm)			\
+  {									\
+    mp_ptr    wp, xp;							\
+    mp_limb_t yp[2];							\
+    unsigned  i;							\
+    double    t;							\
+    TMP_DECL;								\
+									\
+    SPEED_RESTRICT_COND (s->size >= 2);					\
+									\
+    TMP_MARK;								\
+    SPEED_TMP_ALLOC_LIMBS (xp, s->size, s->align_xp);			\
+    SPEED_TMP_ALLOC_LIMBS (wp, s->size, s->align_wp);			\
+									\
+    /* source is destroyed */						\
+    MPN_COPY (xp, s->xp, s->size);					\
+									\
+    /* divisor must be normalized */					\
+    MPN_COPY (yp, s->yp_block, 2);					\
+    if (norm)								\
+      yp[1] |= GMP_NUMB_HIGHBIT;					\
+    else								\
+      {									\
+	yp[1] &= ~GMP_NUMB_HIGHBIT;					\
+	if (yp[1] == 0)							\
+	  yp[1] = 1;							\
+      }									\
+    speed_operand_src (s, xp, s->size);					\
+    speed_operand_src (s, yp, 2);					\
+    speed_operand_dst (s, wp, s->size);					\
+    speed_cache_fill (s);						\
+									\
+    speed_starttime ();							\
+    i = s->reps;							\
+    do									\
+      function (wp, xp, s->size, yp);					\
+    while (--i != 0);							\
+    t = speed_endtime ();						\
+									\
+    TMP_FREE;								\
+    return t;								\
+  }
 
 #define SPEED_ROUTINE_MODLIMB_INVERT(function)				\
   {									\


More information about the gmp-commit mailing list