This commit is contained in:
tqcq 2024-10-24 05:15:37 +00:00
parent 9a0c0f77da
commit 47bf8cc0d9

View File

@ -330,20 +330,26 @@ find_row_mask(std::vector<set_t> &sets,
if (thread_num > 2) { thread_num -= 2; } if (thread_num > 2) { thread_num -= 2; }
for (int i = 0; i < thread_num; ++i) { for (int i = 0; i < thread_num; ++i) {
workers.emplace_back([&] { workers.emplace_back([&] {
std::vector<uint64_t> masks;
while (!found) { while (!found) {
uint64_t cur_mask = last_mask;
{ {
masks.clear();
std::lock_guard<std::mutex> _(lock); std::lock_guard<std::mutex> _(lock);
cur_mask = row_mask; for (int i = 0; i < 10000 && row_mask < last_mask; ++i) {
if (row_mask >= last_mask) { break; } masks.push_back(row_mask);
row_mask = next_bit_permutation(row_mask); 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 (row_mask >= last_mask) { break; }
} }
for (const auto &cur_mask : masks) {
if (resolve(cur_mask, found)) { if (resolve(cur_mask, found)) {
std::lock_guard<std::mutex> _(lock); std::lock_guard<std::mutex> _(lock);
if (!found.exchange(true)) { row_mask = cur_mask; } if (!found.exchange(true)) {
row_mask = cur_mask;
break;
}
}
} }
} }
}); });