add mp_prime_is_prime to timing demo... ... it's disabled per default for now...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/demo/timing.c b/demo/timing.c
index a7edb79..819cb5f 100644
--- a/demo/timing.c
+++ b/demo/timing.c
@@ -103,6 +103,10 @@ int main(void)
uint64_t tt, gg, CLK_PER_SEC;
FILE *log, *logb, *logc, *logd;
mp_int a, b, c, d, e, f;
+#ifdef LTM_TIMING_PRIME_IS_PRIME
+ const char* name;
+ int m;
+#endif
int n, cnt, ix, old_kara_m, old_kara_s, old_toom_m, old_toom_s;
unsigned rr;
@@ -121,6 +125,40 @@ int main(void)
CLK_PER_SEC = TIMFUNC() - CLK_PER_SEC;
printf("CLK_PER_SEC == %" PRIu64 "\n", CLK_PER_SEC);
+
+#ifdef LTM_TIMING_PRIME_IS_PRIME
+ for (m = 0; m < 2; ++m) {
+ if (m == 0) {
+ name = " Arnault";
+ mp_read_radix(&a,"91xLNF3roobhzgTzoFIG6P13ZqhOVYSN60Fa7Cj2jVR1g0k89zdahO9/kAiRprpfO1VAp1aBHucLFV/qLKLFb+zonV7R2Vxp1K13ClwUXStpV0oxTNQVjwybmFb5NBEHImZ6V7P6+udRJuH8VbMEnS0H8/pSqQrg82OoQQ2fPpAk6G1hkjqoCv5s/Yr",64);
+ } else {
+ name = "2^1119 + 53";
+ mp_set(&a,1u);
+ mp_mul_2d(&a,1119,&a);
+ mp_add_d(&a,53,&a);
+ }
+ cnt = mp_prime_rabin_miller_trials(mp_count_bits(&a));
+ ix = -cnt;
+ for (; cnt >= ix; cnt += ix) {
+ rr = 0u;
+ tt = UINT64_MAX;
+ do {
+ gg = TIMFUNC();
+ DO(mp_prime_is_prime(&a, cnt, &n));
+ gg = (TIMFUNC() - gg) >> 1;
+ if (tt > gg)
+ tt = gg;
+ if ((m == 0) && (n == MP_YES)) {
+ printf("Arnault's pseudoprime is not prime but mp_prime_is_prime says it is.\n");
+ return EXIT_FAILURE;
+ }
+ } while (++rr < 100u);
+ printf("Prime-check\t%s(%2d) => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n",
+ name, cnt, CLK_PER_SEC / tt, tt);
+ }
+ }
+#endif
+
log = FOPEN("logs/add.log", "w");
for (cnt = 8; cnt <= 128; cnt += 8) {
SLEEP;