feat: optim
This commit is contained in:
parent
a7d47c26f6
commit
d2953a8981
@ -330,6 +330,7 @@ find_row_mask(std::vector<set_t> &sets,
|
||||
fprintf(stderr, "thread_num: %ld\n", thread_num);
|
||||
|
||||
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,17 +338,20 @@ 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;
|
||||
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) {
|
||||
if (found.load(std::memory_order_relaxed)) { break; }
|
||||
|
Loading…
Reference in New Issue
Block a user