fix: update row_mask

This commit is contained in:
tqcq 2024-10-26 13:35:37 +00:00
parent e74f5e6103
commit aae19ee316

View File

@ -341,6 +341,7 @@ find_row_mask(std::vector<set_t> &sets,
// if (!step) { ++step; }
fprintf(stderr, "worker_step: %ld\n", outer_step);
auto try_update_row_mask = [&](uint64_t cur_pos, uint64_t cur_mask) {
if (found) { return; }
if (cur_pos > g_base_pos.load(std::memory_order_relaxed)) {
std::lock_guard<std::mutex> _(lock);
if (cur_pos > g_base_pos.load()) {
@ -350,13 +351,14 @@ find_row_mask(std::vector<set_t> &sets,
}
};
auto try_get_row_mask = [&](uint64_t end_pos, uint64_t &diff, uint64_t &cur_mask) {
uint64_t v = g_base_pos.load(std::memory_order_relaxed);
auto try_get_latest_row_mask = [&](uint64_t end_pos, uint64_t &diff, uint64_t &cur_mask) {
uint64_t gpos = g_base_pos.load(std::memory_order_relaxed);
uint64_t cur_pos = end_pos - diff;
if (cur_pos < v && end_pos >= v) {
if (end_pos >= gpos && gpos > cur_pos) {
std::lock_guard<std::mutex> _(lock);
if (cur_pos < v && end_pos >= v) {
diff = end_pos - g_base_pos.load();
uint64_t cur_pos = g_base_pos.load();
if (end_pos >= gpos && gpos > cur_pos) {
diff = end_pos - gpos;
cur_mask = row_mask;
}
}
@ -392,13 +394,13 @@ find_row_mask(std::vector<set_t> &sets,
}
diff -= std::min(inner_step, diff);
try_update_row_mask(end_pos - diff, cur_mask);
try_get_row_mask(end_pos, diff, cur_mask);
try_get_latest_row_mask(end_pos, diff, cur_mask);
}
for (int i = outer_step; i > 0 && cur_mask < last_mask; --i) {
if (i % inner_step == 0) { try_update_row_mask(end_pos - i, cur_mask); }
if (resolve(cur_mask)) { set_found(cur_mask); }
cur_mask = next_bit_permutation(cur_mask);
if (i % inner_step == 0) { try_update_row_mask(end_pos - i - 1, cur_mask); }
}
}
});