feat: add param

This commit is contained in:
tqcq 2024-10-24 06:09:43 +00:00
parent f8c4f6ef48
commit 3f4093b913

View File

@ -266,7 +266,8 @@ find_row_mask(std::vector<set_t> &sets,
std::vector<uint64_t> fn_masks, std::vector<uint64_t> fn_masks,
mem_buff_t mem, mem_buff_t mem,
uint64_t threshold, uint64_t threshold,
uint64_t flags) uint64_t flags,
uint64_t cpu)
{ {
addr_tuple base_addr = gen_addr_tuple(get_rnd_addr(mem.buffer, mem.size, 0)); addr_tuple base_addr = gen_addr_tuple(get_rnd_addr(mem.buffer, mem.size, 0));
@ -326,12 +327,13 @@ find_row_mask(std::vector<set_t> &sets,
// } // }
std::vector<std::thread> workers; std::vector<std::thread> workers;
auto thread_num = std::thread::hardware_concurrency(); auto thread_num = cpu == 0 ? std::thread::hardware_concurrency() : cpu;
if (thread_num > 2) { thread_num -= 2; } if (thread_num > 2) { thread_num -= 2; }
uint64_t step = 0; uint64_t step = 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); }
step /= thread_num; step /= thread_num;
if (!step) { ++step; } if (!step) { ++step; }
fprintf(stderr, "thread_num: %ld", thread_num);
for (int i = 0; i < thread_num; ++i) { for (int i = 0; i < thread_num; ++i) {
workers.emplace_back([&] { workers.emplace_back([&] {
@ -450,7 +452,7 @@ rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, char *o_
fprintf(stderr, "Start Find Function\n"); fprintf(stderr, "Start Find Function\n");
fn_masks = find_functions(sets, 6, 30, flags); fn_masks = find_functions(sets, 6, 30, flags);
fprintf(stderr, "Start Find RowMask\n"); fprintf(stderr, "Start Find RowMask\n");
uint64_t row_mask = find_row_mask(sets, fn_masks, mem, threshold, flags); uint64_t row_mask = find_row_mask(sets, fn_masks, mem, threshold, flags, cpu);
free_buffer(&mem); free_buffer(&mem);
} }