From 74469d71e6792fccdfb17f2913aaabafb7094a89 Mon Sep 17 00:00:00 2001 From: Niels M?ller Date: Wed, 4 Sep 2019 20:09:20 +0200 Subject: Speed support for mpn_hgcd2. * tune/speed.h (SPEED_ROUTINE_MPN_HGCD2): New macro. * tune/common.c (speed_mpn_hgcd2): New function. * tune/speed.c (routine): Add mpn_hgcd2. --- tune/common.c | 6 ++++++ tune/speed.c | 1 + tune/speed.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) (limited to 'tune') diff --git a/tune/common.c b/tune/common.c index 0b3f491b7..a918a67a4 100644 --- a/tune/common.c +++ b/tune/common.c @@ -1633,6 +1633,12 @@ speed_mpn_matrix22_mul (struct speed_params *s) return t; } +double +speed_mpn_hgcd2 (struct speed_params *s) +{ + SPEED_ROUTINE_MPN_HGCD2 (mpn_hgcd2); +} + double speed_mpn_hgcd (struct speed_params *s) { diff --git a/tune/speed.c b/tune/speed.c index a013a24b7..4220d6be5 100644 --- a/tune/speed.c +++ b/tune/speed.c @@ -285,6 +285,7 @@ const struct routine_t { { "mpn_matrix22_mul", speed_mpn_matrix22_mul }, + { "mpn_hgcd2", speed_mpn_hgcd2, FLAG_NODATA }, { "mpn_hgcd", speed_mpn_hgcd }, { "mpn_hgcd_lehmer", speed_mpn_hgcd_lehmer }, { "mpn_hgcd_appr", speed_mpn_hgcd_appr }, diff --git a/tune/speed.h b/tune/speed.h index 25b154203..044bc9c2b 100644 --- a/tune/speed.h +++ b/tune/speed.h @@ -214,6 +214,7 @@ double speed_mpn_div_qr_2n (struct speed_params *); double speed_mpn_div_qr_2u (struct speed_params *); double speed_mpn_fib2_ui (struct speed_params *); double speed_mpn_matrix22_mul (struct speed_params *); +double speed_mpn_hgcd2 (struct speed_params *); double speed_mpn_hgcd (struct speed_params *); double speed_mpn_hgcd_lehmer (struct speed_params *); double speed_mpn_hgcd_appr (struct speed_params *); @@ -2843,6 +2844,40 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int); }, \ function (px[j-1], py[j-1], 0)) +#define SPEED_ROUTINE_MPN_HGCD2(function) \ + { \ + unsigned i, j; \ + struct hgcd_matrix1 m = {{{0,0},{0,0}}}; \ + double t; \ + \ + speed_operand_src (s, s->xp_block, SPEED_BLOCK_SIZE); \ + speed_operand_src (s, s->yp_block, SPEED_BLOCK_SIZE); \ + speed_cache_fill (s); \ + \ + speed_starttime (); \ + i = s->reps; \ + mp_limb_t chain = 0; \ + do \ + { \ + for (j = 0; j < SPEED_BLOCK_SIZE; j+= 2) \ + { \ + /* randomized but successively dependent */ \ + function (s->xp_block[j] | GMP_NUMB_HIGHBIT, \ + s->xp_block[j+1] + chain, \ + s->yp_block[j] | GMP_NUMB_HIGHBIT, \ + s->yp_block[j+1], &m); \ + chain += m.u[0][0]; \ + } \ + } \ + while (--i != 0); \ + t = speed_endtime (); \ + \ + /* make sure the compiler won't optimize away chain */ \ + noop_1 (chain); \ + \ + s->time_divisor = SPEED_BLOCK_SIZE / 2; \ + return t; \ + } #define SPEED_ROUTINE_MPN_HGCD_CALL(func, itchfunc) \ { \ -- cgit v1.2.1