Browse Source

configure with testing options

Michele Orrù 6 years ago
parent
commit
096889e505
4 changed files with 36 additions and 27 deletions
  1. 18 4
      configure.ac
  2. 2 2
      src/ddlog.c
  3. 2 2
      src/ddlog.h
  4. 14 19
      src/ddlog_bench.c

+ 18 - 4
configure.ac

@@ -44,7 +44,7 @@ AM_INIT_AUTOMAKE
 CFLAGS+=" -pedantic -Wall "
 
 # Shut up automake
-#AM_SILENT_RULES([yes])
+AM_SILENT_RULES([yes])
 AC_SUBST([AM_MAKEFLAGS], [--no-print-directory])
 
 # Adding package options
@@ -54,9 +54,23 @@ AC_ARG_ENABLE(debug,
    CFLAGS+=" -UNDEBUG -O0 -ggdb -fbounds-check -D_FORTIFY_SOURCE=1",
    CFLAGS+=" -DNDEBUG -O3 -march=native")
 
-AC_DEFINE([FAILURE],  [17], [log inverse of the failure probability, default: 17.])
-AC_DEFINE([FB_BASE], [10], [log of precomputed base for group operation, default: 8.])
-AC_DEFINE([SS_BASE], [1], [log of secret shares representation, default: 1.])
+
+AC_ARG_VAR([failure], [failure prob.])
+AS_IF([test "x$failure" = x], [failure="17"])
+
+
+AC_ARG_VAR([failure], [failure prob.])
+AS_IF([test "x$failure" = x], [failure="17"])
+AC_DEFINE_UNQUOTED([FAILURE], [$failure], [log inverse of the failure probability, default: 17.])
+
+AC_ARG_VAR([fb_base], [fixed base])
+AS_IF([test "x$fb_base" = x], [fb_base="8"])
+AC_DEFINE_UNQUOTED([FB_BASE], [$fb_base], [log of precomputed base for group operation, default: 8.])
+
+
+AC_ARG_VAR([ss_base], [ss base])
+AS_IF([test "x$ss_base" = x], [ss_base="1"])
+AC_DEFINE_UNQUOTED([SS_BASE], [$ss_base], [log of secret shares representation, default: 1.])
 
 
 AC_OUTPUT([Makefile

+ 2 - 2
src/ddlog.c

@@ -9,8 +9,8 @@
 #include "group.h"
 #include "hss.h"
 
-uint32_t lookup[256];
-uint32_t offset[256];
+uint64_t lookup[0x01 << strip_size];
+uint64_t offset[0x01 << strip_size];
 
 static const uint64_t topmask = ~(ULLONG_MAX >> halfstrip_size);
 //static const uint64_t topbigmask = ~(ULLONG_MAX >> strip_size);

+ 2 - 2
src/ddlog.h

@@ -9,8 +9,8 @@
 #define strip_size (FAILURE - 1)
 #define halfstrip_size ((strip_size)/2)
 
-extern uint32_t lookup[256];
-extern uint32_t offset[256];
+extern uint64_t lookup[0x01 << strip_size];
+extern uint64_t offset[0x01 << strip_size];
 
 
 uint32_t convert(uint64_t *nn);

+ 14 - 19
src/ddlog_bench.c

@@ -8,35 +8,30 @@
 #include "group.h"
 #include "timeit.h"
 
+#define SEP "\t"
+
 int main()
 {
   group_init();
   dlog_precompute();
   mpz_entropy_init();
 
-  INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
-  for (int i=0; i < (int) (1e9 / (0x01 << strip_size) * 3.5); i++) {
-    mpz_t n, n0;
-    mpz_inits(n, n0, NULL);
+  for (int i=0; i < (int) (0x01 << 16); i++) {
+    mpz_t n;
+    mpz_init(n);
+
+    mpz_urandomm(n, _rstate, p);
+    INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
 
-    mpz_urandomm(n0, _rstate, p);
-    mpz_set(n, n0);
     START_TIMEIT();
-#ifndef NDEBUG
-    uint32_t converted =
-#endif
-    convert(n->_mp_d);
+    uint32_t steps = convert(n->_mp_d);
     END_TIMEIT();
-    mpz_set(n, n0);
-#ifndef NDEBUG
-    uint32_t expected = naif_convert(n);
-    printf("%d %d\n", converted, expected);
-    assert(converted == expected);
-#endif
-    mpz_clears(n, n0, NULL);
-  }
 
-  printf(TIMEIT_FORMAT "\n", GET_TIMEIT());
+    printf("%d" SEP "%u" SEP TIMEIT_FORMAT "\n",
+           FAILURE, steps, GET_TIMEIT());
+
+    mpz_clear(n);
+  }
 
   group_clear();
   return 0;