From 47bf8cc0d983cab06e594eb3cf2be6d5cd8fe077 Mon Sep 17 00:00:00 2001 From: tqcq Date: Thu, 24 Oct 2024 05:15:37 +0000 Subject: [PATCH] fast --- drama/src/rev-mc.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index d0d71cf..70e1ac6 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -330,20 +330,26 @@ find_row_mask(std::vector &sets, if (thread_num > 2) { thread_num -= 2; } for (int i = 0; i < thread_num; ++i) { workers.emplace_back([&] { + std::vector masks; while (!found) { - uint64_t cur_mask = last_mask; { + masks.clear(); std::lock_guard _(lock); - cur_mask = row_mask; + for (int i = 0; i < 10000 && row_mask < last_mask; ++i) { + masks.push_back(row_mask); + row_mask = next_bit_permutation(row_mask); + } if (row_mask >= last_mask) { break; } - - row_mask = next_bit_permutation(row_mask); - // verbose_printerr("[LOG] - Cur Row mask: 0x%0lx \t\t bits: %s\n", cur_mask, bit_string(cur_mask)); } - if (resolve(cur_mask, found)) { - std::lock_guard _(lock); - if (!found.exchange(true)) { row_mask = cur_mask; } + for (const auto &cur_mask : masks) { + if (resolve(cur_mask, found)) { + std::lock_guard _(lock); + if (!found.exchange(true)) { + row_mask = cur_mask; + break; + } + } } } });