From c7246f974073869dde6b5f260eac2200c04f875e Mon Sep 17 00:00:00 2001 From: tqcq Date: Sat, 26 Oct 2024 13:15:55 +0000 Subject: [PATCH] fix :error --- drama/src/rev-mc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index 9ac0afa..843ee9d 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -340,22 +340,23 @@ find_row_mask(std::vector &sets, // step /= thread_num; // if (!step) { ++step; } fprintf(stderr, "worker_step: %ld\n", outer_step); - auto try_update_row_mask = [&](uint64_t pos, uint64_t mask) { - if (pos > g_base_pos.load(std::memory_order_relaxed)) { + auto try_update_row_mask = [&](uint64_t cur_pos, uint64_t cur_mask) { + if (cur_pos > g_base_pos.load(std::memory_order_relaxed)) { std::lock_guard _(lock); - if (pos > g_base_pos.load()) { - g_base_pos = row_mask; - row_mask = mask; + if (cur_pos > g_base_pos.load()) { + g_base_pos = cur_pos; + row_mask = cur_mask; } } }; + 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); - if (end_pos - diff < v && end_pos >= v) { + uint64_t v = g_base_pos.load(std::memory_order_relaxed); + uint64_t cur_pos = end_pos - diff; + if (cur_pos < v && end_pos >= v) { std::lock_guard _(lock); - v = g_base_pos.load(); - if (end_pos - diff < v && end_pos >= v) { - diff = end_pos - v; + if (cur_pos < v && end_pos >= v) { + diff = end_pos - g_base_pos.load(); cur_mask = row_mask; } }