feat: optim
This commit is contained in:
parent
a7d47c26f6
commit
d2953a8981
@ -329,7 +329,8 @@ find_row_mask(std::vector<set_t> &sets,
|
||||
if (thread_num > 2) { thread_num -= 2; }
|
||||
fprintf(stderr, "thread_num: %ld\n", thread_num);
|
||||
|
||||
uint64_t step = 1 << 20;
|
||||
uint64_t step = 1 << 20;
|
||||
bool lazy_advance_step = false;
|
||||
// for (uint64_t i = row_mask; i < last_mask; ++step) { i = next_bit_permutation(i); }
|
||||
// fprintf(stderr, "total_step: %ld\n", step);
|
||||
// step /= thread_num;
|
||||
@ -337,16 +338,19 @@ find_row_mask(std::vector<set_t> &sets,
|
||||
fprintf(stderr, "worker_step: %ld\n", step);
|
||||
|
||||
for (int i = 0; i < thread_num; ++i) {
|
||||
workers.emplace_back([=, &row_mask, &found, &lock] {
|
||||
workers.emplace_back([=, &row_mask, &found, &lock, &lazy_advance_step] {
|
||||
while (!found) {
|
||||
uint64_t cur_mask = last_mask;
|
||||
{
|
||||
std::lock_guard<std::mutex> _(lock);
|
||||
if (row_mask >= last_mask) { break; }
|
||||
cur_mask = row_mask;
|
||||
for (int i = 0; i < step && row_mask < last_mask; ++i) {
|
||||
row_mask = next_bit_permutation(row_mask);
|
||||
if (lazy_advance_step) {
|
||||
for (int i = 0; i < step && row_mask < last_mask; ++i) {
|
||||
row_mask = next_bit_permutation(row_mask);
|
||||
}
|
||||
}
|
||||
cur_mask = row_mask;
|
||||
lazy_advance_step = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < step && cur_mask < last_mask; ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user