summaryrefslogtreecommitdiff
path: root/tune/speed.h
diff options
context:
space:
mode:
Diffstat (limited to 'tune/speed.h')
-rw-r--r--tune/speed.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/tune/speed.h b/tune/speed.h
index 4bc73c9ac..41170e901 100644
--- a/tune/speed.h
+++ b/tune/speed.h
@@ -406,6 +406,7 @@ double speed_mpz_fib_ui (struct speed_params *);
double speed_mpz_fib2_ui (struct speed_params *);
double speed_mpz_init_clear (struct speed_params *);
double speed_mpz_init_realloc_clear (struct speed_params *);
+double speed_mpz_nextprime (struct speed_params *);
double speed_mpz_jacobi (struct speed_params *);
double speed_mpz_lucnum_ui (struct speed_params *);
double speed_mpz_lucnum2_ui (struct speed_params *);
@@ -3162,6 +3163,47 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
return t; \
}
+/* Calculate nextprime(n) for random n of s->size bits (not limbs). */
+#define SPEED_ROUTINE_MPZ_NEXTPRIME(function) \
+ { \
+ unsigned i, j; \
+ mpz_t wp, n; \
+ double t; \
+ \
+ SPEED_RESTRICT_COND (s->size >= 10); \
+ \
+ mpz_init (wp); \
+ mpz_init_set_n (n, s->xp, s->size); \
+ /* limit to s->size bits, as this function is very slow */ \
+ mpz_tdiv_r_2exp (n, n, s->size); \
+ /* set high bits so operand and result are genaral s->size bits */ \
+ mpz_setbit (n, s->size - 1); \
+ mpz_clrbit (n, s->size - 2); \
+ \
+ speed_starttime (); \
+ i = s->reps; \
+ do \
+ { \
+ /* nextprime timing is variable, so average over many calls */ \
+ j = SPEED_BLOCK_SIZE - 1; \
+ /* starts on random, after measures prime to next prime */ \
+ function (wp, n); \
+ do \
+ { \
+ function (wp, wp); \
+ } \
+ while (--j != 0); \
+ } \
+ while (--i != 0); \
+ t = speed_endtime (); \
+ \
+ mpz_clear (wp); \
+ mpz_clear (n); \
+ \
+ s->time_divisor = SPEED_BLOCK_SIZE; \
+ return t; \
+ }
+
#define SPEED_ROUTINE_MPZ_JACOBI(function) \
{ \
mpz_t a, b; \