From 6cbbb133c179915d0d7f8941128aa87d875568a8 Mon Sep 17 00:00:00 2001 From: tqcq Date: Sat, 26 Oct 2024 10:25:50 +0000 Subject: [PATCH] feat: show progress --- drama/src/rev-mc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index dd462de..b8c795c 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -342,6 +342,7 @@ find_row_mask(std::vector &sets, fprintf(stderr, "worker_step: %ld\n", step); std::atomic cnt{0}; + std::atomic progress{0}; for (int i = 0; i < thread_num; ++i) { workers.emplace_back([&] { while (!found) { @@ -359,8 +360,8 @@ find_row_mask(std::vector &sets, for (int i = std::min(step_count, step); i > 0 && cur_mask < last_mask; --i) { cur_mask = next_bit_permutation(cur_mask); if (cnt.fetch_add(1) % 10000000 == 0) { - fprintf(stderr, "cnt : %ld, step_count: %5ld, cur_pos: %5ld\n", - cnt.load(std::memory_order_relaxed), step_count, g_cur_pos.load()); + fprintf(stderr, "cnt : %ld, step_count: %5ld, cur_pos: %5ld progress: %ld\n", + cnt.load(std::memory_order_relaxed), step_count, g_cur_pos.load(), progress.load()); } } @@ -383,7 +384,7 @@ find_row_mask(std::vector &sets, } } - for (int i = 0; i < step && cur_mask < last_mask && !found.load(std::memory_order_relaxed); ++i) { + for (int i = step * 10; i > 0 && cur_mask < last_mask && !found.load(std::memory_order_relaxed); --i) { if (resolve(cur_mask)) { bool expected = false; if (found.compare_exchange_strong(expected, true)) { @@ -393,6 +394,7 @@ find_row_mask(std::vector &sets, } } } + progress.fetch_add(step * 10); } }); }