-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdumer.cpp
More file actions
73 lines (63 loc) · 2.6 KB
/
dumer.cpp
File metadata and controls
73 lines (63 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <vector>
#include <omp.h>
#include "instance.h"
#include "template_dumer.h"
#include "chase_manager.h"
//#include "challenges/mceliece/mce923sp.h"
//#include "challenges/mceliece/mce1473sp.h"
//#include "challenges/mceliece/mce2197sp.h"
#include "challenges/mceliece/mce3488sp.h"
#include "helper.h"
int main(int argc, char* argv[])
{
if(argc > 2){
std::cerr << "Wrong number of input parameters! Usage: ./dumer <nr_threads>. nr_threads is optional.\n";
return 1;
}
const uint32_t nr_threads = (argc == 2) ? atoi(argv[1]) : omp_get_max_threads();
const uint32_t seed0 = time(NULL);
srand(seed0);
const uint32_t seed1 = rand();
random_seed(seed1);
DecodingInstance I(h, s, n, k);
constexpr const uint32_t p = 2;
constexpr const uint32_t l = 25;
static constexpr ConfigTemplateDumer config(n, k, w, addRows, newN, p, l, true);
auto B = config.parse_weight_string(eW);
config.print();
config.print_mem_consumption();
auto chase = ChaseManager::getInstance().get_chase_sequence(config.comb_half, p);
std::vector<TemplateDumer<config>*> dumers(nr_threads);
for(size_t i = 0; i < nr_threads; i++)
dumers[i] = new TemplateDumer<config>(I, B, chase);
// some infos
std::cout << "Seed0: " << seed0 << "\n";
std::cout << "Seed1: " << seed1 << "\n";
std::cout << "Threads: " << nr_threads << "\n";
uint64_t overall_loops = 0;
auto start_real = timer_start(CLOCK_REALTIME);
auto start_CPU = timer_start(CLOCK_PROCESS_CPUTIME_ID);
#pragma omp parallel default(none) shared(dumers, overall_loops) num_threads(nr_threads)
{
auto t_id = omp_get_thread_num();
auto loops = dumers[t_id]->run();
#pragma omp atomic
overall_loops += loops;
}
auto elapsed_real_ns = timer_end(start_real, CLOCK_REALTIME, true);
auto elapsed_CPU_ns = timer_end(start_CPU, CLOCK_PROCESS_CPUTIME_ID, true);
double elapsed_real_s = double(elapsed_real_ns) / double(1e9);
double elapsed_CPU_s = double(elapsed_CPU_ns) / double(1e9);
if(I.check())
std::cout << "Found solution after " << overall_loops << " loops.\n";
else
std::cout << "Something went wrong! Solution not correct!\n";
// in a multithreaded scenario cpu time can exceed wall time (each thread/core counts individually)
std::cout << std::fixed << "Real time: " << elapsed_real_s << "s" << std::endl;
std::cout << std::fixed << "CPU time: " << elapsed_CPU_s << "s" << std::endl;
mzd_print(I.error);
for(int i = 0; i < nr_threads; i++)
delete dumers[i];
return 0;
}