-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (66 loc) · 2.23 KB
/
main.cpp
File metadata and controls
77 lines (66 loc) · 2.23 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
74
75
76
77
#include "sim.h"
#include "router.h"
#include "queue.h"
int main(int argc, char **argv) {
int debug = 0;
bool verbose = false;
double mean_interval = 0.0;
long total_cycles = 10000;
// Default is 4-ary 2-torus.
int k = 4, r = 2;
int terminal_count;
int router_count;
int radix;
int vc_count = -1;
for (int i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-d")) {
debug = 1;
} else if (!strcmp(argv[i], "-v")) {
verbose = true;
} else if (!strcmp(argv[i], "-k")) {
i++;
k = std::stoi(std::string(argv[i]));
} else if (!strcmp(argv[i], "-r")) {
i++;
r = std::stoi(std::string(argv[i]));
} else if (!strcmp(argv[i], "-vc")) {
// VC can be overrided
i++;
vc_count = std::stoi(std::string(argv[i]));
} else if (!strcmp(argv[i], "-cycle")) {
i++;
total_cycles = std::stoi(std::string(argv[i]));
} else if (!strcmp(argv[i], "-interval")) {
i++;
mean_interval = std::stod(std::string(argv[i]));
}
}
router_count = 1;
for (int i = 0; i < r; i++) {
router_count *= k;
}
terminal_count = router_count;
// 1: terminal node, 2: bidirectional in each ring
radix = 1 + 2 * r;
if (vc_count == -1) {
// 2 VCs in each dimension
vc_count = 2 * r;
} // else, overrided
Topology top = topology_torus(k, r);
Sim sim{verbose, debug, top, terminal_count, router_count, radix, vc_count, mean_interval, 10};
// schedule(&sim.eventq, 0, tick_event_from_id(src_id(0)));
// schedule(&sim.eventq, 0, tick_event_from_id(src_id(1)));
// schedule(&sim.eventq, 0, tick_event_from_id(src_id(2)));
// schedule(&sim.eventq, 0, tick_event_from_id(src_id(3)));
// VC vs. Wormhole (6-ary 2-torus)
// schedule(&sim.eventq, 0, tick_event_from_id(src_id(19)));
// schedule(&sim.eventq, 0, tick_event_from_id(src_id(20)));
for (int i = 0; i < terminal_count; i++) {
schedule(&sim.eventq, 0, tick_event_from_id(src_id(i)));
}
sim_run(&sim, total_cycles);
sim_report(&sim);
sim_destroy(&sim);
topology_destroy(&top);
return 0;
}