[Gmp-commit] /home/hgfiles/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Wed Dec 9 22:57:08 CET 2009


details:   /home/hgfiles/gmp/rev/2a3cc993fecc
changeset: 13018:2a3cc993fecc
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Dec 09 22:38:24 2009 +0100
description:
(tune_mulmod_bnm1): Rewrite.

details:   /home/hgfiles/gmp/rev/5f5db65dc8ea
changeset: 13019:5f5db65dc8ea
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Dec 09 22:40:28 2009 +0100
description:
(mpn_mulmod_bnm1_next_size): Rewrite.

details:   /home/hgfiles/gmp/rev/6dafd7951ee5
changeset: 13020:6dafd7951ee5
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Dec 09 22:57:02 2009 +0100
description:
Allow direct measuring of mpn_bc_mulmod_bnm1.

diffstat:

 ChangeLog                 |  12 ++++++++++++
 gmp-impl.h                |   2 ++
 mpn/generic/mulmod_bnm1.c |  23 ++++++++++-------------
 tune/common.c             |   8 +++++++-
 tune/speed.c              |   5 +++--
 tune/speed.h              |  12 ++++++++----
 tune/tuneup.c             |   8 ++------
 7 files changed, 44 insertions(+), 26 deletions(-)

diffs (179 lines):

diff -r 09a9c6db7ac3 -r 6dafd7951ee5 ChangeLog
--- a/ChangeLog	Wed Dec 09 08:04:28 2009 +0100
+++ b/ChangeLog	Wed Dec 09 22:57:02 2009 +0100
@@ -1,3 +1,15 @@
+2009-12-09  Torbjorn Granlund  <tege at gmplib.org>
+
+	* tune/speed.h (SPEED_ROUTINE_MPN_MULMOD_BNM1_CALL): New macro, made
+	from now deleted SPEED_ROUTINE_MPN_MULMOD_BNM1.
+	* tune/common.c (speed_mpn_bc_mulmod_bnm1): New function.
+	(speed_mpn_mulmod_bnm1): Use SPEED_ROUTINE_MPN_MULMOD_BNM1_CALL.
+	* tune/speed.c (routine): Add mpn_bc_mulmod_bnm1.
+
+	* mpn/generic/mulmod_bnm1.c (mpn_mulmod_bnm1_next_size): Rewrite.
+
+	* tune/tuneup.c (tune_mulmod_bnm1): Rewrite.
+
 2009-12-08  Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mpn/generic/mulmod_bnm1.c (mpn_bc_mulmod_bnm1,
diff -r 09a9c6db7ac3 -r 6dafd7951ee5 gmp-impl.h
--- a/gmp-impl.h	Wed Dec 09 08:04:28 2009 +0100
+++ b/gmp-impl.h	Wed Dec 09 22:57:02 2009 +0100
@@ -947,6 +947,8 @@
 #define mpn_mod_1s_4p __MPN(mod_1s_4p)
 __GMP_DECLSPEC mp_limb_t mpn_mod_1s_4p __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t [7])) __GMP_ATTRIBUTE_PURE;
 
+#define mpn_bc_mulmod_bnm1 __MPN(bc_mulmod_bnm1)
+__GMP_DECLSPEC void mpn_bc_mulmod_bnm1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr));
 #define mpn_mulmod_bnm1 __MPN(mulmod_bnm1)
 __GMP_DECLSPEC void mpn_mulmod_bnm1 __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr));
 #define mpn_mulmod_bnm1_next_size __MPN(mulmod_bnm1_next_size)
diff -r 09a9c6db7ac3 -r 6dafd7951ee5 mpn/generic/mulmod_bnm1.c
--- a/mpn/generic/mulmod_bnm1.c	Wed Dec 09 08:04:28 2009 +0100
+++ b/mpn/generic/mulmod_bnm1.c	Wed Dec 09 22:57:02 2009 +0100
@@ -28,15 +28,11 @@
 #include "gmp.h"
 #include "gmp-impl.h"
 
-#ifndef MULMOD_BNM1_THRESHOLD
-#define MULMOD_BNM1_THRESHOLD 16
-#endif
-
 /* Inputs are {ap,rn} and {bp,rn}; output is {rp,rn}, computation is
    mod B^rn - 1, and values are semi-normalised; zero is represented
    as either 0 or B^n - 1.  Needs a scratch of 2rn limbs at tp.
    tp==rp is allowed. */
-static void
+void
 mpn_bc_mulmod_bnm1 (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t rn,
 		    mp_ptr tp)
 {
@@ -260,18 +256,19 @@
 mp_size_t
 mpn_mulmod_bnm1_next_size (mp_size_t n)
 {
+  mp_size_t nh;
+
   if (BELOW_THRESHOLD (n,     MULMOD_BNM1_THRESHOLD))
     return n;
-  if (BELOW_THRESHOLD (n, 2 * MULMOD_BNM1_THRESHOLD))
+  if (BELOW_THRESHOLD (n, 4 * (MULMOD_BNM1_THRESHOLD - 1) + 1))
     return (n + (2-1)) & (-2);
-  if (BELOW_THRESHOLD (n, 4 * MULMOD_BNM1_THRESHOLD))
+  if (BELOW_THRESHOLD (n, 8 * (MULMOD_BNM1_THRESHOLD - 1) + 1))
     return (n + (4-1)) & (-4);
-  if (BELOW_THRESHOLD (n, 8 * MULMOD_BNM1_THRESHOLD))
+
+  nh = (n + 1) >> 1;
+
+  if (BELOW_THRESHOLD (nh, MUL_FFT_MODF_THRESHOLD))
     return (n + (8-1)) & (-8);
 
-  if (BELOW_THRESHOLD (n, MUL_FFT_MODF_THRESHOLD))
-    return (n + (16-1)) & (-16);
-
-  n = (n + 1) >> 1;
-  return 2 * mpn_fft_next_size (n, mpn_fft_best_k (n, 0));
+  return 2 * mpn_fft_next_size (nh, mpn_fft_best_k (nh, 0));
 }
diff -r 09a9c6db7ac3 -r 6dafd7951ee5 tune/common.c
--- a/tune/common.c	Wed Dec 09 08:04:28 2009 +0100
+++ b/tune/common.c	Wed Dec 09 22:57:02 2009 +0100
@@ -1106,7 +1106,13 @@
 double
 speed_mpn_mulmod_bnm1 (struct speed_params *s)
 {
-  SPEED_ROUTINE_MPN_MULMOD_BNM1 (mpn_mulmod_bnm1);
+  SPEED_ROUTINE_MPN_MULMOD_BNM1_CALL (mpn_mulmod_bnm1 (wp, s->size, s->xp, s->size, s->yp, s->size, tp));
+}
+
+double
+speed_mpn_bc_mulmod_bnm1 (struct speed_params *s)
+{
+  SPEED_ROUTINE_MPN_MULMOD_BNM1_CALL (mpn_bc_mulmod_bnm1 (wp, s->xp, s->yp, s->size, tp));
 }
 
 double
diff -r 09a9c6db7ac3 -r 6dafd7951ee5 tune/speed.c
--- a/tune/speed.c	Wed Dec 09 08:04:28 2009 +0100
+++ b/tune/speed.c	Wed Dec 09 22:57:02 2009 +0100
@@ -308,8 +308,9 @@
   { "mpn_mullo_n",        speed_mpn_mullo_n         },
   { "mpn_mullo_basecase", speed_mpn_mullo_basecase  },
 
-  { "mpn_mulmod_bnm1",   speed_mpn_mulmod_bnm1      },
-  { "mpn_mulmod_bnm1_rounded", speed_mpn_mulmod_bnm1_rounded      },
+  { "mpn_bc_mulmod_bnm1",      speed_mpn_bc_mulmod_bnm1      },
+  { "mpn_mulmod_bnm1",         speed_mpn_mulmod_bnm1         },
+  { "mpn_mulmod_bnm1_rounded", speed_mpn_mulmod_bnm1_rounded },
 
   { "mpn_invert",        speed_mpn_invert           },
   { "mpn_binvert",       speed_mpn_binvert          },
diff -r 09a9c6db7ac3 -r 6dafd7951ee5 tune/speed.h
--- a/tune/speed.h	Wed Dec 09 08:04:28 2009 +0100
+++ b/tune/speed.h	Wed Dec 09 22:57:02 2009 +0100
@@ -276,6 +276,7 @@
 double speed_mpn_toom32_mul __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_toom42_mul __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_mulmod_bnm1 __GMP_PROTO ((struct speed_params *s));
+double speed_mpn_bc_mulmod_bnm1 __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_mulmod_bnm1_rounded __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_udiv_qrnnd __GMP_PROTO ((struct speed_params *s));
 double speed_mpn_udiv_qrnnd_r __GMP_PROTO ((struct speed_params *s));
@@ -994,29 +995,32 @@
     return t;								\
   }
 
-#define SPEED_ROUTINE_MPN_MULMOD_BNM1(function)				\
+#define SPEED_ROUTINE_MPN_MULMOD_BNM1_CALL(call)			\
   {									\
     mp_ptr    wp, tp;							\
     unsigned  i;							\
     double    t;							\
+    mp_size_t itch;							\
     TMP_DECL;								\
 									\
     SPEED_RESTRICT_COND (s->size >= 1);					\
 									\
+    itch = mpn_mulmod_bnm1_itch (s->size);				\
+									\
     TMP_MARK;								\
     SPEED_TMP_ALLOC_LIMBS (wp, 2 * s->size, s->align_wp);		\
-    SPEED_TMP_ALLOC_LIMBS (tp, 3 * s->size + 100, s->align_wp2);	\
+    SPEED_TMP_ALLOC_LIMBS (tp, itch, s->align_wp2);			\
 									\
     speed_operand_src (s, s->xp, s->size);				\
     speed_operand_src (s, s->yp, s->size);				\
     speed_operand_dst (s, wp, 2 * s->size);				\
-    speed_operand_dst (s, tp, 3 * s->size + 100); /* FIXME: Use itch function */ \
+    speed_operand_dst (s, tp, itch);					\
     speed_cache_fill (s);						\
 									\
     speed_starttime ();							\
     i = s->reps;							\
     do									\
-      function (wp, s->size, s->xp, s->size, s->yp, s->size, tp);	\
+      call;								\
     while (--i != 0);							\
     t = speed_endtime ();						\
 									\
diff -r 09a9c6db7ac3 -r 6dafd7951ee5 tune/tuneup.c
--- a/tune/tuneup.c	Wed Dec 09 08:04:28 2009 +0100
+++ b/tune/tuneup.c	Wed Dec 09 22:57:02 2009 +0100
@@ -904,13 +904,9 @@
 {
   static struct param_t  param;
 
+  param.name = "MULMOD_BNM1_THRESHOLD";
   param.function = speed_mpn_mulmod_bnm1;
-
-  param.name = "MULMOD_BNM1_THRESHOLD";
-  param.min_size = 12;
-  param.step_factor = 0.0;
-  param.step = 4;
-  param.min_is_always = 1;
+  param.min_size = 4;
   param.max_size = 100;
   one (&mulmod_bnm1_threshold, &param);
 }


More information about the gmp-commit mailing list