diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index 70e1ac6..c5bba1f 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -320,6 +320,7 @@ find_row_mask(std::vector &sets, std::atomic_bool found{false}; std::mutex lock; + const uint64_t step = 10000; // while (row_mask < last_mask) { // row_mask = next_bit_permutation(row_mask); @@ -330,19 +331,18 @@ 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); - for (int i = 0; i < 10000 && row_mask < last_mask; ++i) { - masks.push_back(row_mask); + if (row_mask >= last_mask) { break; } + cur_mask = row_mask; + for (int i = 0; i < step && row_mask < last_mask; ++i) { row_mask = next_bit_permutation(row_mask); } - if (row_mask >= last_mask) { break; } } - for (const auto &cur_mask : masks) { + for (int i = 0; i < step && cur_mask < last_mask; ++i) { if (resolve(cur_mask, found)) { std::lock_guard _(lock); if (!found.exchange(true)) {