This commit is contained in:
tqcq 2024-10-24 05:15:37 +00:00
parent 2a8d045463
commit 9a0c0f77da
3 changed files with 11 additions and 5 deletions

View File

@ -9,4 +9,5 @@ typedef struct {
//---------------------------------------------------------- //----------------------------------------------------------
// Functions // Functions
void rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, char *o_file, uint64_t flags); void
rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, char *o_file, uint64_t flags, uint64_t cpu);

View File

@ -57,6 +57,7 @@ main(int argc, char **argv)
size_t rounds = ROUNDS_std; size_t rounds = ROUNDS_std;
size_t m_size = MEM_SIZE_std; size_t m_size = MEM_SIZE_std;
size_t threshold = THRESHOLD_std; size_t threshold = THRESHOLD_std;
size_t cpu = 1;
char *o_file = (char *) O_FILE_std; char *o_file = (char *) O_FILE_std;
flags |= F_POPULATE; flags |= F_POPULATE;
@ -74,7 +75,7 @@ main(int argc, char **argv)
{"mem", required_argument, 0, 0}, {"mem", required_argument, 0, 0},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
int arg = getopt_long(argc, argv, "o:s:r:t:hv", long_options, &option_index); int arg = getopt_long(argc, argv, "o:s:r:t:n:hv", long_options, &option_index);
if (arg == -1) break; if (arg == -1) break;
@ -99,6 +100,8 @@ main(int argc, char **argv)
case 'r': case 'r':
rounds = atoi(optarg); rounds = atoi(optarg);
break; break;
case 'n':
cpu = atoi(optarg);
case 't': case 't':
threshold = atoi(optarg); threshold = atoi(optarg);
break; break;
@ -112,7 +115,7 @@ main(int argc, char **argv)
} }
} }
rev_mc(sets_cnt, threshold, rounds, m_size, o_file, flags); rev_mc(sets_cnt, threshold, rounds, m_size, o_file, flags, cpu);
return 0; return 0;
} }

View File

@ -326,7 +326,9 @@ find_row_mask(std::vector<set_t> &sets,
// } // }
std::vector<std::thread> workers; std::vector<std::thread> workers;
for (int i = 0; i < 8; ++i) { auto thread_num = std::thread::hardware_concurrency();
if (thread_num > 2) { thread_num -= 2; }
for (int i = 0; i < thread_num; ++i) {
workers.emplace_back([&] { workers.emplace_back([&] {
while (!found) { while (!found) {
uint64_t cur_mask = last_mask; uint64_t cur_mask = last_mask;
@ -361,7 +363,7 @@ find_row_mask(std::vector<set_t> &sets,
//---------------------------------------------------------- //----------------------------------------------------------
void void
rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, char *o_file, uint64_t flags) rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, char *o_file, uint64_t flags, uint64_t cpu)
{ {
time_t t; time_t t;