-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfiguration.cc
138 lines (115 loc) · 2.81 KB
/
configuration.cc
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***********************************************************/
/* configuration parse */
/***********************************************************/
#include "configuration.h"
#include <vector>
#include "SRGen.h"
#include <string>
#include "SString.h"
#include <ctime>
#include <unistd.h>
#include <iostream>
#include <strstream>
configuration * configuration::ap_ = 0;
configuration::configuration(int argc, char * const argv []):
ary_number_(8),
cube_number_(2),
virtual_channel_number_(2),
buffer_size_(64),
outbuffer_size_(4),
ran_seed_(1),
sim_length_(1000000000),
trace_fname_(),
routing_alg_(0),
vc_share_(MONO_)
{
ap_ = this;
const char * opt_str = "h:?:A:c:V:B:F:T:r:I:O:R:L:";
string usage = string("usage: ") + argv[0] + " [" +
opt_str + "] \n";
if(argc <= 1) {
throw init_error(help_);
}
while (1) {
long ch = getopt(argc, argv, opt_str);
if(ch == -1) {
break;
}
vector<string> vec;
switch (ch) {
case 'h':
throw init_error(help_);
break;
case 'A':
ary_number_ = Conv(optarg);
break;
case 'c':
cube_number_ = Conv(optarg);
break;
case 'V':
virtual_channel_number_ = Conv(optarg);
break;
case 'B':
buffer_size_ = Conv(optarg);
break;
case 'F':
flit_size_ = Conv(optarg);
break;
case 'L':
link_length_ = Conv(optarg);
break;
case 'T':
sim_length_ = Conv(optarg);
break;
case 'I':
trace_fname_ = optarg;
break;
case 'O':
outbuffer_size_ = Conv(optarg);
break;
case 'r':
ran_seed_ = Conv(optarg);
break;
case 'R':
routing_alg_ = Conv(optarg);
break;
case '?':
throw init_error(help_);
break;
default :
throw init_error(usage);
break;
}
}
SRGen::wrg().set_seed(ran_seed_);
vc_share_ = SHARE_;
}
string configuration:: help_ =
string("h: help\n") +
"?: help\n" +
"A: array size\n" +
"c: cube dimension\n" +
"V: virtual channel number\n" +
"B: buffer size\n" +
"O: outbuffer size\n" +
"F: flit size\n" +
"L: link legnth\n" +
"T: simulation length\n" +
"r: random seed\n" +
"I: trace file\n" +
"R: routing algorithm: 0-dimension 1-opty\n";
ostream & operator<<(ostream & os, const configuration & cf) {
os <<"****************configuration********************\n"<<
"ary size:"<<cf.ary_number_<<"\n"<<
"cube dimension:"<<cf.cube_number_<<"\n"<<
"virtual channel number:"<<cf.virtual_channel_number_<<"\n"<<
"buffer size:"<<cf.buffer_size_<<"\n"<<
"outbuffer size:"<<cf.outbuffer_size_<<"\n"<<
"flit size:"<<cf.flit_size_<<"\n"<<
"link length:"<<cf.link_length_<<"\n"<<
"simulation length:" <<cf.sim_length_<<"\n"<<
"trace file:"<<cf.trace_fname_.c_str()<<"\n"<<
"Routing algorithm:"<<cf.routing_alg_<<"\n"<<
"****************configuration********************\n";
return os;
}