forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (44 loc) · 1.55 KB
/
Copy pathmain.cpp
File metadata and controls
58 lines (44 loc) · 1.55 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
#include "levelgraph.hpp"
#include <CLI11.hpp>
int main(int argc, char* argv[]) {
CLI::App app{"Graph Traversal"};
unsigned num_threads {1};
app.add_option("-t,--num_threads", num_threads, "number of threads (default=1)");
unsigned num_rounds {1};
app.add_option("-r,--num_rounds", num_rounds, "number of rounds (default=1)");
std::string model = "tf";
app.add_option("-m,--model", model, "model name tbb|omp|tf (default=tf)")
->check([] (const std::string& m) {
if(m != "tbb" && m != "omp" && m != "tf") {
return "model name should be \"tbb\", \"omp\", or \"tf\"";
}
return "";
});
CLI11_PARSE(app, argc, argv);
std::cout << "model=" << model << ' '
<< "num_threads=" << num_threads << ' '
<< "num_rounds=" << num_rounds << ' '
<< std::endl;
std::cout << std::setw(12) << "|V|+|E|"
<< std::setw(12) << "Runtime"
<< '\n';
for(int i=1; i<=451; i += 15) {
double runtime {0.0};
LevelGraph graph(i, i);
for(unsigned j=0; j<num_rounds; ++j) {
if(model == "tf") {
runtime += measure_time_taskflow(graph, num_threads).count();
}
else if(model == "tbb") {
runtime += measure_time_tbb(graph, num_threads).count();
}
else if(model == "omp") {
runtime += measure_time_omp(graph, num_threads).count();
}
graph.clear_graph();
}
std::cout << std::setw(12) << graph.graph_size()
<< std::setw(12) << runtime / num_rounds / 1e3
<< std::endl;
}
}