diff options
-rw-r--r-- | src/div.c | 4 | ||||
-rw-r--r-- | src/generic/mparam.h | 4 | ||||
-rw-r--r-- | tune/tuneup.c | 19 |
3 files changed, 22 insertions, 5 deletions
@@ -281,10 +281,6 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode) * * **************************************************************************/ -#ifndef MPFR_DIV_THRESHOLD -#define MPFR_DIV_THRESHOLD 23 /* near to optimal on a Core 2 Duo U9600 */ -#endif - if (MPFR_UNLIKELY(q0size >= MPFR_DIV_THRESHOLD && vsize >= MPFR_DIV_THRESHOLD)) { diff --git a/src/generic/mparam.h b/src/generic/mparam.h index 17f4cac81..42df7c7d4 100644 --- a/src/generic/mparam.h +++ b/src/generic/mparam.h @@ -18,6 +18,10 @@ # define MPFR_SQR_THRESHOLD 20 /* limbs */ #endif +#ifndef MPFR_DIV_THRESHOLD +# define MPFR_DIV_THRESHOLD 25 /* limbs */ +#endif + #ifndef MPFR_EXP_2_THRESHOLD # define MPFR_EXP_2_THRESHOLD 100 /* bits */ #endif diff --git a/tune/tuneup.c b/tune/tuneup.c index d99cdeddf..66bb52a81 100644 --- a/tune/tuneup.c +++ b/tune/tuneup.c @@ -273,14 +273,18 @@ speed_mpfr_sincos (struct speed_params *s) SPEED_MPFR_FUNC2 (mpfr_sin_cos); } -/* Setup mpfr_mul and mpfr_sqr */ +/* Setup mpfr_mul, mpfr_sqr and mpfr_div */ mpfr_prec_t mpfr_mul_threshold; mpfr_prec_t mpfr_sqr_threshold; +mpfr_prec_t mpfr_div_threshold; #undef MPFR_MUL_THRESHOLD #define MPFR_MUL_THRESHOLD mpfr_mul_threshold #undef MPFR_SQR_THRESHOLD #define MPFR_SQR_THRESHOLD mpfr_sqr_threshold +#undef MPFR_DIV_THRESHOLD +#define MPFR_DIV_THRESHOLD mpfr_div_threshold #include "mul.c" +#include "div.c" static double speed_mpfr_mul (struct speed_params *s) { @@ -291,6 +295,11 @@ speed_mpfr_sqr (struct speed_params *s) { SPEED_MPFR_SQR (mpfr_mul); } +static double +speed_mpfr_div (struct speed_params *s) +{ + SPEED_MPFR_OP (mpfr_div); +} /************************************************ * Common functions (inspired by GMP function) * @@ -1056,6 +1065,14 @@ all (const char *filename) fprintf (f, "#define MPFR_SQR_THRESHOLD %lu /* limbs */\n", (unsigned long) (mpfr_sqr_threshold - 1) / GMP_NUMB_BITS + 1); + /* Tune mpfr_div (threshold is in limbs, but it doesn't matter too much) */ + if (verbose) + printf ("Tuning mpfr_div...\n"); + tune_simple_func (&mpfr_div_threshold, speed_mpfr_div, + 2*GMP_NUMB_BITS+1); + fprintf (f, "#define MPFR_DIV_THRESHOLD %lu /* limbs */\n", + (unsigned long) (mpfr_div_threshold - 1) / GMP_NUMB_BITS + 1); + /* Tune mpfr_exp_2 */ if (verbose) printf ("Tuning mpfr_exp_2...\n"); |