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; + } + } } } });