diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-04-22 12:23:10 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-04-22 12:23:10 +0200 |
commit | 71b05bcce68b4c38ce0dae04a026c54b2fa6064d (patch) | |
tree | 4a6f37765765c950547684148d3c08b48bae8e81 /tune/common.c | |
parent | bbd1f5f7aee9035eb3eb98967096d5b14a5f9055 (diff) | |
download | gmp-71b05bcce68b4c38ce0dae04a026c54b2fa6064d.tar.gz |
tune: Support mpz_bin_ui.
Diffstat (limited to 'tune/common.c')
-rw-r--r-- | tune/common.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tune/common.c b/tune/common.c index 8cf0ab952..9cc3f2d1f 100644 --- a/tune/common.c +++ b/tune/common.c @@ -1954,6 +1954,40 @@ speed_mpz_bin_uiui (struct speed_params *s) return t; } +/* If r==0, calculate binomial(2^size,size), + otherwise calculate binomial(2^size,r). */ + +double +speed_mpz_bin_ui (struct speed_params *s) +{ + mpz_t w, x; + unsigned long k; + unsigned i; + double t; + + mpz_init (w); + mpz_init_set_ui (x, 0); + + mpz_setbit (x, s->size); + + if (s->r != 0) + k = s->r; + else + k = s->size; + + speed_starttime (); + i = s->reps; + do + { + mpz_bin_ui (w, x, k); + } + while (--i != 0); + t = speed_endtime (); + + mpz_clear (w); + mpz_clear (x); + 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 |