feat update
This commit is contained in:
parent
1845acf65f
commit
7262c59d5a
@ -329,12 +329,12 @@ find_row_mask(std::vector<set_t> &sets,
|
|||||||
|
|
||||||
std::vector<std::thread> workers;
|
std::vector<std::thread> workers;
|
||||||
int thread_num = cpu == 0 ? std::thread::hardware_concurrency() : cpu;
|
int thread_num = cpu == 0 ? std::thread::hardware_concurrency() : cpu;
|
||||||
if (thread_num > 4) { thread_num -= 4; }
|
if (thread_num > 4) { thread_num = 4; }
|
||||||
fprintf(stderr, "thread_num: %d\n", thread_num);
|
fprintf(stderr, "thread_num: %d\n", thread_num);
|
||||||
|
|
||||||
uint64_t step = 1000;
|
uint64_t step = 1000;
|
||||||
std::atomic<uint64_t> cur_pos{0};
|
std::atomic<uint64_t> g_cur_pos{0};
|
||||||
std::atomic<uint64_t> base_pos{0};
|
std::atomic<uint64_t> g_base_pos{0};
|
||||||
// for (uint64_t i = row_mask; i < last_mask; ++step) { i = next_bit_permutation(i); }
|
// for (uint64_t i = row_mask; i < last_mask; ++step) { i = next_bit_permutation(i); }
|
||||||
// fprintf(stderr, "total_step: %ld\n", step);
|
// fprintf(stderr, "total_step: %ld\n", step);
|
||||||
// step /= thread_num;
|
// step /= thread_num;
|
||||||
@ -351,21 +351,22 @@ find_row_mask(std::vector<set_t> &sets,
|
|||||||
std::lock_guard<std::mutex> _(lock);
|
std::lock_guard<std::mutex> _(lock);
|
||||||
if (row_mask >= last_mask || found) { break; }
|
if (row_mask >= last_mask || found) { break; }
|
||||||
cur_mask = row_mask;
|
cur_mask = row_mask;
|
||||||
step_count = cur_pos - base_pos;
|
step_count = g_cur_pos - g_base_pos;
|
||||||
my_pos = cur_pos.fetch_add(1);
|
my_pos = g_cur_pos.fetch_add(step * 10);
|
||||||
}
|
}
|
||||||
while (cur_mask < last_mask && step_count > 0 && !found.load(std::memory_order_relaxed)) {
|
while (cur_mask < last_mask && step_count > 0 && !found.load(std::memory_order_relaxed)) {
|
||||||
--step_count;
|
for (int i = std::min(step_count, step); i > 0 && cur_mask < last_mask; --i) {
|
||||||
for (int i = 0; i < step && cur_mask < last_mask; ++i) {
|
|
||||||
cur_mask = next_bit_permutation(cur_mask);
|
cur_mask = next_bit_permutation(cur_mask);
|
||||||
}
|
}
|
||||||
}
|
step_count -= std::min(step_count, step);
|
||||||
// update pos
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> _(lock);
|
std::lock_guard<std::mutex> _(lock);
|
||||||
if (my_pos > base_pos) {
|
if (my_pos > g_base_pos) {
|
||||||
base_pos = my_pos;
|
g_base_pos = my_pos;
|
||||||
row_mask = cur_mask;
|
row_mask = cur_mask;
|
||||||
|
} else if (g_base_pos <= g_cur_pos) {
|
||||||
|
cur_mask = row_mask;
|
||||||
|
my_pos = g_base_pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user