diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2016-12-28 18:20:00 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2016-12-28 18:20:00 +0100 |
commit | 597e975c08e77466196cce4db5f683a5f04dc9d6 (patch) | |
tree | 48e10e26065a99141e051b9ed23e8bb33a29da22 /tune | |
parent | 294d8b6ab779b599c414cd38d5099d33ae40c8b1 (diff) | |
download | gmp-597e975c08e77466196cce4db5f683a5f04dc9d6.tar.gz |
tune/speed: support mpz_mfac_uiui
Diffstat (limited to 'tune')
-rw-r--r-- | tune/common.c | 36 | ||||
-rw-r--r-- | tune/speed.c | 3 | ||||
-rw-r--r-- | tune/speed.h | 3 |
3 files changed, 37 insertions, 5 deletions
diff --git a/tune/common.c b/tune/common.c index f350171b6..a794aafe6 100644 --- a/tune/common.c +++ b/tune/common.c @@ -1,6 +1,6 @@ /* Shared speed subroutines. -Copyright 1999-2006, 2008-2015 Free Software Foundation, Inc. +Copyright 1999-2006, 2008-2016 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -2039,8 +2039,8 @@ speed_mpz_add (struct speed_params *s) } -/* If r==0, calculate (size,size/2), - otherwise calculate (size,r). */ +/* If r==0, calculate binomial(size,size/2), + otherwise calculate binomial(size,r). */ double speed_mpz_bin_uiui (struct speed_params *s) @@ -2104,6 +2104,36 @@ speed_mpz_bin_ui (struct speed_params *s) return t; } +/* If r==0, calculate mfac(size,log(size)), + otherwise calculate mfac(size,r). */ + +double +speed_mpz_mfac_uiui (struct speed_params *s) +{ + mpz_t w; + unsigned long k; + unsigned i; + double t; + + mpz_init (w); + if (s->r != 0) + k = s->r; + else + for (k = 1; s->size >> k; ++k); + + speed_starttime (); + i = s->reps; + do + { + mpz_mfac_uiui (w, s->size, k); + } + while (--i != 0); + t = speed_endtime (); + + mpz_clear (w); + return t; +} + /* The multiplies are successively dependent so the latency is measured, not the issue rate. There's only 10 per loop so the code doesn't get too big since umul_ppmm is several instructions on some cpus. diff --git a/tune/speed.c b/tune/speed.c index e33775b3b..b49d5abf6 100644 --- a/tune/speed.c +++ b/tune/speed.c @@ -1,6 +1,6 @@ /* Speed measuring program. -Copyright 1999-2003, 2005, 2006, 2008-2015 Free Software Foundation, Inc. +Copyright 1999-2003, 2005, 2006, 2008-2016 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -407,6 +407,7 @@ const struct routine_t { { "mpz_bin_ui", speed_mpz_bin_ui, FLAG_NODATA | FLAG_R_OPTIONAL }, { "mpz_fac_ui", speed_mpz_fac_ui, FLAG_NODATA }, { "mpz_2fac_ui", speed_mpz_2fac_ui, FLAG_NODATA }, + { "mpz_mfac_uiui", speed_mpz_mfac_uiui, FLAG_NODATA | FLAG_R_OPTIONAL }, { "mpz_primorial_ui", speed_mpz_primorial_ui, FLAG_NODATA }, { "mpz_powm", speed_mpz_powm }, { "mpz_powm_mod", speed_mpz_powm_mod }, diff --git a/tune/speed.h b/tune/speed.h index be1966368..dd95372c9 100644 --- a/tune/speed.h +++ b/tune/speed.h @@ -1,6 +1,6 @@ /* Header for speed and threshold things. -Copyright 1999-2003, 2005, 2006, 2008-2015 Free Software Foundation, Inc. +Copyright 1999-2003, 2005, 2006, 2008-2016 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -388,6 +388,7 @@ double speed_mpz_bin_uiui (struct speed_params *); double speed_mpz_bin_ui (struct speed_params *); double speed_mpz_fac_ui (struct speed_params *); double speed_mpz_2fac_ui (struct speed_params *); +double speed_mpz_mfac_uiui (struct speed_params *); double speed_mpz_primorial_ui (struct speed_params *); double speed_mpz_fib_ui (struct speed_params *); double speed_mpz_fib2_ui (struct speed_params *); |