-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.cc
executable file
·186 lines (159 loc) · 4.23 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/***********************************************************/
/* configuration parse */
/***********************************************************/
#include "configuration.h"
#include <vector>
#include "SRGen.h"
#include <string>
#include "SString.h"
#include <ctime>
#include <unistd.h>
#include <iostream>
#include <strstream>
//define the static member
configuration * configuration::ap_ = 0;
configuration::configuration(int argc, char * const argv []):
//throw(init_error &):
ary_number_(16),
cube_number_(2),
virtual_channel_number_(2),
buffer_size_(4),
outbuffer_size_(4),
channel_width_(8),
phit_size_(8),
flit_size_(32),
packet_size_(128),
ran_seed_(1),
sim_length_(1000),
trace_fname_(),
his_win_size_(10000),
his_win_counter_(3),
routing_alg_(0),
vc_share_(MONO_)
{
ap_ = this;
const char * opt_str = "h:?:A:c:V:B:C:p:F:P:L:I:O:H:S:R:f:";
string usage = string("usage: ") + argv[0] + " [" +
opt_str + "] \n";
if(argc <= 1) {
// Vassos: comment the following line out, compilation error, replace with next two lines
// throw init_error(help_);
cout<<help_;
exit;
}
while (1) {
long ch = getopt(argc, argv, opt_str);
if(ch == -1) {
break;
}
vector<string> vec;
switch (ch) {
case 'h':
// Vassos: comment the following line out, compilation error, replace with next two lines
// throw init_error(help_);
cout<<help_;
abort();
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 'C':
channel_width_ = Conv(optarg);
break;
case 'p':
phit_size_ = Conv(optarg);
break;
case 'F':
flit_size_ = Conv(optarg);
break;
case 'P':
packet_size_ = Conv(optarg);
break;
case 'L':
sim_length_ = Conv(optarg);
break;
case 'I':
trace_fname_ = optarg;
break;
case 'O':
outbuffer_size_ = Conv(optarg);
break;
case 'H':
his_win_size_ = Conv(optarg);
break;
case 'S':
ran_seed_ = Conv(optarg);
break;
case 'R':
routing_alg_ = Conv(optarg);
break;
case 'f':
his_win_counter_ = Conv(optarg);
break;
case '?':
// Vassos: comment the following line out, compilation error, replace with next two lines
// throw init_error(help_);
cout<<help_;
abort();
break;
default :
// Vassos: comment the following line out, compilation error, replace with next two lines
// throw init_error(usage);
cout<<usage;
abort();
cout<<"here"<<endl;
break;
}
}
SRGen::wrg().set_seed(ran_seed_);
if(routing_alg_ == OPTY_ ) {
vc_share_ = MONO_;
}else {
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" +
"C: channel width\n" +
"p: phit size\n" +
"F: flit size\n" +
"P: packet size\n" +
"L: simulation length\n" +
"S: random seed\n" +
"I: trace file\n" +
"R: routing algorithm: 0-dimension 1-opty\n" +
"H: history window size\n" +
"f: history windows counter\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"<<
"channel width:"<<cf.channel_width_<<"\n"<<
"phit size:"<<cf.phit_size_<<"\n"<<
"flit size:"<<cf.flit_size_<<"\n"<<
"packet size:"<<cf.packet_size_<<"\n"<<
"simulation length:" <<cf.sim_length_<<"\n"<<
"trace file:"<<cf.trace_fname_.c_str()<<"\n"<<
"Routing algorithm:"<<cf.routing_alg_<<"\n"<<
"History window size:"<<cf.his_win_size_<<"\n"<<
"history windows counter:"<<cf.his_win_counter_<<"\n";
return os;
}