diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-01-29 00:25:27 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-01-29 00:25:27 +0100 |
commit | 4df351b89e27ca05168648dc60da61c41a6e69cc (patch) | |
tree | 44143a53f7b84a5ffd0a1455902d1dee1588bc20 /tune/common.c | |
parent | 9be801c0d1d7c0daa067fdaeb0521b029e8d8f7e (diff) | |
download | gmp-4df351b89e27ca05168648dc60da61c41a6e69cc.tar.gz |
* tune/speed.c, tune/speed.h, tune/common.c, tune/Makefile.am: Measure
operator_div, operator_mod, mpn_divrem_2_div, mpn_divrem_2_inv,
mpn_sb_divrem_m3, mpn_sb_divrem_m3_div, mpn_sb_divrem_m3_inv,
mpn_dc_divrem_sb_div, mpn_dc_divrem_sb_inv.
* tune/tuneup.c, gmp-impl.h, tune/speed.h, tune/common.c,
tune/Makefile.am: Tune SB_PREINV_THRESHOLD and DIVREM_2_THRESHOLD.
Diffstat (limited to 'tune/common.c')
-rw-r--r-- | tune/common.c | 126 |
1 files changed, 124 insertions, 2 deletions
diff --git a/tune/common.c b/tune/common.c index a6da5d7d6..4505ceb0b 100644 --- a/tune/common.c +++ b/tune/common.c @@ -532,6 +532,16 @@ speed_mpn_divrem_2 (struct speed_params *s) { SPEED_ROUTINE_MPN_DIVREM_2 (mpn_divrem_2); } +double +speed_mpn_divrem_2_div (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_DIVREM_2 (mpn_divrem_2_div); +} +double +speed_mpn_divrem_2_inv (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_DIVREM_2 (mpn_divrem_2_inv); +} double speed_mpn_mod_1 (struct speed_params *s) @@ -574,6 +584,11 @@ speed_mpn_modexact_1c_odd (struct speed_params *s) double +speed_mpn_dc_tdiv_qr (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_DC_TDIV_QR (mpn_tdiv_qr); +} +double speed_mpn_dc_divrem_n (struct speed_params *s) { SPEED_ROUTINE_MPN_DC_DIVREM_N (mpn_dc_divrem_n); @@ -584,10 +599,32 @@ speed_mpn_dc_divrem_sb (struct speed_params *s) SPEED_ROUTINE_MPN_DC_DIVREM_SB (mpn_sb_divrem_mn); } double -speed_mpn_dc_tdiv_qr (struct speed_params *s) +speed_mpn_dc_divrem_sb_div (struct speed_params *s) { - SPEED_ROUTINE_MPN_DC_TDIV_QR (mpn_tdiv_qr); + SPEED_ROUTINE_MPN_DC_DIVREM_SB (mpn_sb_divrem_mn_div); +} +double +speed_mpn_dc_divrem_sb_inv (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_DC_DIVREM_SB (mpn_sb_divrem_mn_inv); } + +double +speed_mpn_sb_divrem_m3 (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_SB_DIVREM_M3 (mpn_sb_divrem_mn); +} +double +speed_mpn_sb_divrem_m3_div (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_SB_DIVREM_M3 (mpn_sb_divrem_mn_div); +} +double +speed_mpn_sb_divrem_m3_inv (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_SB_DIVREM_M3 (mpn_sb_divrem_mn_inv); +} + double speed_mpz_mod (struct speed_params *s) { @@ -1471,6 +1508,91 @@ speed_invert_limb (struct speed_params *s) } +/* xp[0] might not be particularly random, but should give an indication how + "/" runs. Same for speed_operator_mod below. */ +double +speed_operator_div (struct speed_params *s) +{ + double t; + unsigned i; + mp_limb_t x, q, d; + + s->time_divisor = 10; + + /* divisor from "r" parameter, or a default */ + d = s->r; + if (d == 0) + d = __mp_bases[10].big_base; + + x = s->xp[0]; + q = 0; + + speed_starttime (); + i = s->reps; + do + { + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + q ^= x; q /= d; + } + while (--i != 0); + t = speed_endtime (); + + /* stop the compiler optimizing away the whole calculation! */ + noop_1 (q); + + return t; +} + +double +speed_operator_mod (struct speed_params *s) +{ + double t; + unsigned i; + mp_limb_t x, r, d; + + s->time_divisor = 10; + + /* divisor from "r" parameter, or a default */ + d = s->r; + if (d == 0) + d = __mp_bases[10].big_base; + + x = s->xp[0]; + r = 0; + + speed_starttime (); + i = s->reps; + do + { + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + r ^= x; r %= d; + } + while (--i != 0); + t = speed_endtime (); + + /* stop the compiler optimizing away the whole calculation! */ + noop_1 (r); + + return t; +} + + /* r==0 measures on data with the values uniformly distributed. This will be typical for count_trailing_zeros in a GCD etc. |