diff options
| author | J08nY | 2018-02-03 21:58:03 +0100 |
|---|---|---|
| committer | J08nY | 2018-02-03 21:58:03 +0100 |
| commit | dedb8c3f127a3198c45dd29221f524d1227c207a (patch) | |
| tree | 1178c0aa560960ee8ed6b7b2931288f24c775624 | |
| parent | ed7e99ebc7c50523e5a2c6f21c8f89028348da71 (diff) | |
| download | ecgen-dedb8c3f127a3198c45dd29221f524d1227c207a.tar.gz ecgen-dedb8c3f127a3198c45dd29221f524d1227c207a.tar.zst ecgen-dedb8c3f127a3198c45dd29221f524d1227c207a.zip | |
| -rw-r--r-- | src/exhaustive/exhaustive.c | 1 | ||||
| -rw-r--r-- | src/invalid/invalid_thread.c | 15 | ||||
| -rw-r--r-- | src/io/output.h | 30 | ||||
| -rw-r--r-- | src/misc/types.c | 3 | ||||
| -rw-r--r-- | src/misc/types.h | 2 |
5 files changed, 37 insertions, 14 deletions
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index c0cb08a..e7d6350 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -309,6 +309,7 @@ int exhaustive_gen_retry(curve_t *curve, const exhaustive_t *setup, timeout = true; } else { + debug_log_state(state, ""); diff = setup->generators[state](curve, gen_arg, (offset_e)state); } timeout_stop(); diff --git a/src/invalid/invalid_thread.c b/src/invalid/invalid_thread.c index c9e8108..cf0f67c 100644 --- a/src/invalid/invalid_thread.c +++ b/src/invalid/invalid_thread.c @@ -5,6 +5,8 @@ #include "invalid_thread.h" #include "gen/curve.h" +#include "gen/gens.h" +#include "gen/point.h" #include "util/random.h" #include "util/timeout.h" @@ -27,6 +29,7 @@ void *invalid_thread(void *arg) { pari_sp btop = avma; exhaustive_gen(invalid, thread->setup, OFFSET_B, OFFSET_GENERATORS); size_t ndivides = 0; + size_t nfree = 0; for (size_t i = thread->nprimes; i-- > 0;) { if (dvdis(invalid->order, thread->primes[i])) { // whoo we have a new invalid curve @@ -38,8 +41,6 @@ void *invalid_thread(void *arg) { exhaustive_gen_retry(invalid, &invalid_setup, OFFSET_GENERATORS, OFFSET_POINTS, 1)) { pthread_mutex_lock(thread->mutex_state); - size_t nfree = 0; - // can be up to ndivides, but also lower... pari_ulong primes[ndivides]; size_t nprimes = 0; for (size_t i = thread->nprimes; i-- > 0;) { @@ -70,17 +71,13 @@ void *invalid_thread(void *arg) { *(thread->generated) += count; pthread_cond_signal(thread->cond_generated); pthread_mutex_unlock(thread->mutex_state); - - invalid = curve_new(); - invalid->field = gcopy(thread->original_curve->field); - invalid->a = gcopy(thread->original_curve->a); - continue; } } - // We were unsuccessful for some reason, unroll + points_unroll(invalid, avma, btop); + gens_unroll(invalid, avma, btop); curve_unroll(invalid, avma, btop); - avma = btop; + if (nfree == 0) avma = btop; } curve_free(&invalid); diff --git a/src/io/output.h b/src/io/output.h index 6381812..1037c00 100644 --- a/src/io/output.h +++ b/src/io/output.h @@ -15,34 +15,53 @@ #ifdef DEBUG #include <inttypes.h> +#include <sys/syscall.h> +#include <sys/types.h> #include <time.h> -#define _debug_print(prefix) \ - fprintf(verbose, prefix); \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - fprintf(verbose, "%" PRIdMAX ".%.9ld ", ts.tv_sec, ts.tv_nsec); +#define _debug_print(prefix) \ + fprintf(verbose, prefix); \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + fprintf(verbose, "%d %" PRIdMAX ".%.9ld - ", (int)syscall(SYS_gettid), \ + ts.tv_sec, ts.tv_nsec); #define debug(...) pari_fprintf(verbose, __VA_ARGS__) #define debug_log(...) \ do { \ + flockfile(verbose); \ _debug_print(" - "); \ debug(__VA_ARGS__); \ fprintf(verbose, "\n"); \ + funlockfile(verbose); \ } while (0) #define debug_log_start(...) \ do { \ + flockfile(verbose); \ _debug_print("[ ] "); \ debug(__VA_ARGS__); \ fprintf(verbose, "\n"); \ + funlockfile(verbose); \ } while (0) #define debug_log_end(...) \ do { \ + flockfile(verbose); \ _debug_print("[*] "); \ debug(__VA_ARGS__); \ fprintf(verbose, "\n"); \ + funlockfile(verbose); \ + } while (0) + +#define debug_log_state(state, ...) \ + do { \ + flockfile(verbose); \ + _debug_print(" - "); \ + fprintf(verbose, "%s - ", offset_s[(state)]); \ + debug(__VA_ARGS__); \ + fprintf(verbose, "\n"); \ + funlockfile(verbose); \ } while (0) #else @@ -50,6 +69,7 @@ #define debug_log(...) #define debug_log_start(...) #define debug_log_end(...) +#define debug_log_state(...) #endif // DEBUG #define verbose_log(...) \ diff --git a/src/misc/types.c b/src/misc/types.c index a9d53e6..1554684 100644 --- a/src/misc/types.c +++ b/src/misc/types.c @@ -4,6 +4,9 @@ */ #include "types.h" +const char* offset_s[OFFSET_END] = {"SEED", "FIELD", "A", "B", + "CURVE", "ORDER", "GENERATORS", "POINTS"}; + GENERATOR(gen_skip) { return 1; } CHECK(check_skip) { return 1; } diff --git a/src/misc/types.h b/src/misc/types.h index 7f2d4a8..1e74e04 100644 --- a/src/misc/types.h +++ b/src/misc/types.h @@ -107,6 +107,8 @@ typedef enum { OFFSET_END } offset_e; +extern const char *offset_s[OFFSET_END]; + /** * @brief */ |
