feat: update
This commit is contained in:
parent
d2953a8981
commit
0a21209790
@ -304,8 +304,9 @@ find_row_mask(std::vector<set_t> &sets,
|
|||||||
uint64_t row_mask = LS_BITMASK(16);// use 16 bits for the row
|
uint64_t row_mask = LS_BITMASK(16);// use 16 bits for the row
|
||||||
const uint64_t last_mask = (row_mask << (40 - 16));
|
const uint64_t last_mask = (row_mask << (40 - 16));
|
||||||
row_mask <<= CL_SHIFT;// skip the lowest 6 bits since they're used for CL addressing
|
row_mask <<= CL_SHIFT;// skip the lowest 6 bits since they're used for CL addressing
|
||||||
|
bool need_update_row_mask = false;
|
||||||
|
|
||||||
auto resolve = [=](uint64_t row_mask) -> bool {
|
auto resolve = [=](uint64_t row_mask) -> bool {
|
||||||
if (row_mask & LS_BITMASK(CL_SHIFT)) { return false; }
|
if (row_mask & LS_BITMASK(CL_SHIFT)) { return false; }
|
||||||
for (auto addr_pool : same_row_sets) {
|
for (auto addr_pool : same_row_sets) {
|
||||||
addr_tuple base_addr = addr_pool[0];
|
addr_tuple base_addr = addr_pool[0];
|
||||||
@ -329,8 +330,7 @@ find_row_mask(std::vector<set_t> &sets,
|
|||||||
if (thread_num > 2) { thread_num -= 2; }
|
if (thread_num > 2) { thread_num -= 2; }
|
||||||
fprintf(stderr, "thread_num: %ld\n", thread_num);
|
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); }
|
// 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;
|
||||||
@ -338,49 +338,28 @@ find_row_mask(std::vector<set_t> &sets,
|
|||||||
fprintf(stderr, "worker_step: %ld\n", step);
|
fprintf(stderr, "worker_step: %ld\n", step);
|
||||||
|
|
||||||
for (int i = 0; i < thread_num; ++i) {
|
for (int i = 0; i < thread_num; ++i) {
|
||||||
workers.emplace_back([=, &row_mask, &found, &lock, &lazy_advance_step] {
|
workers.emplace_back([&] {
|
||||||
while (!found) {
|
while (!found) {
|
||||||
uint64_t cur_mask = last_mask;
|
uint64_t cur_mask = last_mask;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _(lock);
|
std::lock_guard<std::mutex> _(lock);
|
||||||
if (row_mask >= last_mask) { break; }
|
if (row_mask >= last_mask || found) { break; }
|
||||||
if (lazy_advance_step) {
|
if (need_update_row_mask) {
|
||||||
for (int i = 0; i < step && row_mask < last_mask; ++i) {
|
for (int i = 0; i < step && row_mask < last_mask; ++i) {
|
||||||
row_mask = next_bit_permutation(row_mask);
|
row_mask = next_bit_permutation(row_mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_mask = row_mask;
|
cur_mask = row_mask;
|
||||||
lazy_advance_step = true;
|
need_update_row_mask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < step && cur_mask < last_mask; ++i) {
|
for (int i = 0; i < step && cur_mask < last_mask; ++i) {
|
||||||
if (found.load(std::memory_order_relaxed)) { break; }
|
if (!found.load(std::memory_order_relaxed) && resolve(cur_mask)) {
|
||||||
|
std::lock_guard<std::mutex> _(lock);
|
||||||
if (cur_mask & LS_BITMASK(CL_SHIFT)) {
|
if (!found.exchange(true)) {
|
||||||
cur_mask = next_bit_permutation(row_mask);
|
row_mask = cur_mask;
|
||||||
continue;
|
break;
|
||||||
}
|
|
||||||
bool mismatch = false;
|
|
||||||
for (auto addr_pool : same_row_sets) {
|
|
||||||
addr_tuple base_addr = addr_pool[0];
|
|
||||||
for (int i = 1; i < addr_pool.size(); i++) {
|
|
||||||
addr_tuple tmp = addr_pool[i];
|
|
||||||
if ((tmp.p_addr & row_mask) != (base_addr.p_addr & cur_mask)) {
|
|
||||||
mismatch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mismatch) { break; }
|
|
||||||
}
|
|
||||||
if (mismatch) {
|
|
||||||
cur_mask = next_bit_permutation(row_mask);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> _(lock);
|
|
||||||
if (!found.exchange(true)) {
|
|
||||||
row_mask = cur_mask;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user