[Gmp-commit] /home/hgfiles/gmp: Tune BINV_NEWTON_THRESHOLD.
mercurial at gmplib.org
mercurial at gmplib.org
Wed Dec 2 13:19:39 CET 2009
details: /home/hgfiles/gmp/rev/5f90c2d6de53
changeset: 12957:5f90c2d6de53
user: Torbjorn Granlund <tege at gmplib.org>
date: Wed Dec 02 13:19:35 2009 +0100
description:
Tune BINV_NEWTON_THRESHOLD.
diffstat:
ChangeLog | 11 +++++++++--
gmp-impl.h | 4 ++++
tune/Makefile.am | 2 +-
tune/common.c | 13 +++++++++----
tune/speed.h | 40 ++++++++++++++++++++++++++++++++++++++--
tune/tuneup.c | 16 +++++++++++++++-
6 files changed, 76 insertions(+), 10 deletions(-)
diffs (202 lines):
diff -r 4c2a39802af2 -r 5f90c2d6de53 ChangeLog
--- a/ChangeLog Wed Dec 02 02:01:15 2009 +0100
+++ b/ChangeLog Wed Dec 02 13:19:35 2009 +0100
@@ -1,10 +1,17 @@
2009-12-02 Torbjorn Granlund <tege at gmplib.org>
+ * tune/tuneup.c: Tune BINV_NEWTON_THRESHOLD.
+ (tune_binvert): New function.
+ * tune/speed.h (SPEED_ROUTINE_MPN_BINVERT): New macros.
+ * tune/common.c (speed_mpn_binvert): New function.
+ * gmp-impl.h: Provide declarations for corresponding threshold vars.
+ * tune/Makefile.am (TUNE_MPN_SRCS_BASIC): Add binvert.c.
+
* tune/tuneup.c: Tune DC_BDIV_QR_THRESHOLD and DC_BDIV_Q_THRESHOLD.
(tune_dc_bdiv): New function.
(tune_dc_div): New name for tune_dc.
- * tune/speed.h (SPEED_ROUTINE_PI1_BDIV_QR, SPEED_ROUTINE_PI1_BDIV_Q):
- New macros.
+ * tune/speed.h (SPEED_ROUTINE_MPN_PI1_BDIV_QR,
+ SPEED_ROUTINE_MPN_PI1_BDIV_Q): New macros.
* tune/common.c (speed_mpn_sbpi1_bdiv_qr, speed_mpn_dcpi1_bdiv_qr,
speed_mpn_sbpi1_bdiv_q, speed_mpn_dcpi1_bdiv_q): New functions.
* gmp-impl.h: Provide declarations for corresponding threshold vars.
diff -r 4c2a39802af2 -r 5f90c2d6de53 gmp-impl.h
--- a/gmp-impl.h Wed Dec 02 02:01:15 2009 +0100
+++ b/gmp-impl.h Wed Dec 02 13:19:35 2009 +0100
@@ -4154,6 +4154,10 @@
#define DC_BDIV_QR_THRESHOLD dc_bdiv_qr_threshold
extern mp_size_t dc_bdiv_qr_threshold;
+#undef BINV_NEWTON_THRESHOLD
+#define BINV_NEWTON_THRESHOLD binv_newton_threshold
+extern mp_size_t binv_newton_threshold;
+
#undef REDC_1_TO_REDC_2_THRESHOLD
#define REDC_1_TO_REDC_2_THRESHOLD redc_1_to_redc_2_threshold
extern mp_size_t redc_1_to_redc_2_threshold;
diff -r 4c2a39802af2 -r 5f90c2d6de53 tune/Makefile.am
--- a/tune/Makefile.am Wed Dec 02 02:01:15 2009 +0100
+++ b/tune/Makefile.am Wed Dec 02 13:19:35 2009 +0100
@@ -123,7 +123,7 @@
TUNE_MPN_SRCS = $(TUNE_MPN_SRCS_BASIC) divrem_1.c mod_1.c
TUNE_MPN_SRCS_BASIC = dcpi1_div_qr.c dcpi1_bdiv_qr.c dcpi1_bdiv_q.c \
- divrem_2.c gcd.c gcdext.c get_str.c \
+ binvert.c divrem_2.c gcd.c gcdext.c get_str.c \
set_str.c matrix22_mul.c hgcd.c mul_n.c sqr_n.c \
mullow_n.c mul_fft.c mul.c tdiv_qr.c mulmod_bnm1.c \
toom22_mul.c toom2_sqr.c toom33_mul.c toom3_sqr.c toom44_mul.c toom4_sqr.c
diff -r 4c2a39802af2 -r 5f90c2d6de53 tune/common.c
--- a/tune/common.c Wed Dec 02 02:01:15 2009 +0100
+++ b/tune/common.c Wed Dec 02 13:19:35 2009 +0100
@@ -740,22 +740,27 @@
double
speed_mpn_sbpi1_bdiv_qr (struct speed_params *s)
{
- SPEED_ROUTINE_PI1_BDIV_QR (mpn_sbpi1_bdiv_qr);
+ SPEED_ROUTINE_MPN_PI1_BDIV_QR (mpn_sbpi1_bdiv_qr);
}
double
speed_mpn_dcpi1_bdiv_qr (struct speed_params *s)
{
- SPEED_ROUTINE_PI1_BDIV_QR (mpn_dcpi1_bdiv_qr);
+ SPEED_ROUTINE_MPN_PI1_BDIV_QR (mpn_dcpi1_bdiv_qr);
}
double
speed_mpn_sbpi1_bdiv_q (struct speed_params *s)
{
- SPEED_ROUTINE_PI1_BDIV_Q (mpn_sbpi1_bdiv_q);
+ SPEED_ROUTINE_MPN_PI1_BDIV_Q (mpn_sbpi1_bdiv_q);
}
double
speed_mpn_dcpi1_bdiv_q (struct speed_params *s)
{
- SPEED_ROUTINE_PI1_BDIV_Q (mpn_dcpi1_bdiv_q);
+ SPEED_ROUTINE_MPN_PI1_BDIV_Q (mpn_dcpi1_bdiv_q);
+}
+double
+speed_mpn_binvert (struct speed_params *s)
+{
+ SPEED_ROUTINE_MPN_BINVERT (mpn_binvert, mpn_binvert_itch);
}
double
diff -r 4c2a39802af2 -r 5f90c2d6de53 tune/speed.h
--- a/tune/speed.h Wed Dec 02 02:01:15 2009 +0100
+++ b/tune/speed.h Wed Dec 02 13:19:35 2009 +0100
@@ -239,6 +239,7 @@
double speed_mpn_dcpi1_bdiv_qr __GMP_PROTO ((struct speed_params *s));
double speed_mpn_sbpi1_bdiv_q __GMP_PROTO ((struct speed_params *s));
double speed_mpn_dcpi1_bdiv_q __GMP_PROTO ((struct speed_params *s));
+double speed_mpn_binvert __GMP_PROTO ((struct speed_params *s));
double speed_mpn_redc_1 __GMP_PROTO ((struct speed_params *s));
double speed_mpn_redc_2 __GMP_PROTO ((struct speed_params *s));
double speed_mpn_redc_n __GMP_PROTO ((struct speed_params *s));
@@ -1302,7 +1303,7 @@
return speed_endtime (); \
}
-#define SPEED_ROUTINE_PI1_BDIV_QR(function) \
+#define SPEED_ROUTINE_MPN_PI1_BDIV_QR(function) \
{ \
unsigned i; \
mp_ptr dp, tp, ap, qp; \
@@ -1343,7 +1344,7 @@
TMP_FREE; \
return t; \
}
-#define SPEED_ROUTINE_PI1_BDIV_Q(function) \
+#define SPEED_ROUTINE_MPN_PI1_BDIV_Q(function) \
{ \
unsigned i; \
mp_ptr dp, tp, qp; \
@@ -1381,6 +1382,41 @@
return t; \
}
+#define SPEED_ROUTINE_MPN_BINVERT(function,itchfn) \
+ { \
+ long i; \
+ mp_ptr up, tp, ip; \
+ double t; \
+ TMP_DECL; \
+ \
+ SPEED_RESTRICT_COND (s->size >= 1); \
+ \
+ TMP_MARK; \
+ SPEED_TMP_ALLOC_LIMBS (ip, s->size, s->align_xp); \
+ SPEED_TMP_ALLOC_LIMBS (up, s->size, s->align_yp); \
+ SPEED_TMP_ALLOC_LIMBS (tp, itchfn (s->size), s->align_wp); \
+ \
+ MPN_COPY (up, s->xp, s->size); \
+ \
+ /* normalize the data */ \
+ up[0] |= 1; \
+ \
+ speed_operand_src (s, up, s->size); \
+ speed_operand_dst (s, tp, s->size); \
+ speed_operand_dst (s, ip, s->size); \
+ speed_cache_fill (s); \
+ \
+ speed_starttime (); \
+ i = s->reps; \
+ do \
+ function (ip, up, s->size, tp); \
+ while (--i != 0); \
+ t = speed_endtime (); \
+ \
+ TMP_FREE; \
+ return t; \
+ }
+
#define SPEED_ROUTINE_REDC_1(function) \
{ \
unsigned i; \
diff -r 4c2a39802af2 -r 5f90c2d6de53 tune/tuneup.c
--- a/tune/tuneup.c Wed Dec 02 02:01:15 2009 +0100
+++ b/tune/tuneup.c Wed Dec 02 13:19:35 2009 +0100
@@ -167,6 +167,7 @@
mp_size_t dc_div_qr_threshold = MP_SIZE_T_MAX;
mp_size_t dc_bdiv_q_threshold = MP_SIZE_T_MAX;
mp_size_t dc_bdiv_qr_threshold = MP_SIZE_T_MAX;
+mp_size_t binv_newton_threshold = MP_SIZE_T_MAX;
mp_size_t redc_1_to_redc_2_threshold = MP_SIZE_T_MAX;
mp_size_t redc_1_to_redc_n_threshold = MP_SIZE_T_MAX;
mp_size_t redc_2_to_redc_n_threshold = MP_SIZE_T_MAX;
@@ -1018,7 +1019,7 @@
param.name = "DC_BDIV_QR_THRESHOLD";
param.function = speed_mpn_sbpi1_bdiv_qr;
param.function2 = speed_mpn_dcpi1_bdiv_qr;
- param.min_size = 2;
+ param.min_size = 4;
one (&dc_bdiv_qr_threshold, ¶m);
}
{
@@ -1032,6 +1033,18 @@
}
void
+tune_binvert (void)
+{
+ {
+ static struct param_t param;
+ param.name = "BINV_NEWTON_THRESHOLD";
+ param.function = speed_mpn_binvert;
+ param.step_factor = 0.02;
+ one (&binv_newton_threshold, ¶m);
+ }
+}
+
+void
tune_redc (void)
{
#if WANT_REDC_2
@@ -1884,6 +1897,7 @@
tune_dc_div ();
tune_dc_bdiv ();
+ tune_binvert ();
tune_redc ();
printf("\n");
More information about the gmp-commit
mailing list