-
Notifications
You must be signed in to change notification settings - Fork 0
/
NoximGlobalStats.cpp
271 lines (213 loc) · 6.79 KB
/
NoximGlobalStats.cpp
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
* Noxim - the NoC Simulator
*
* (C) 2005-2010 by the University of Catania
* For the complete list of authors refer to file ../doc/AUTHORS.txt
* For the license applied to these sources refer to file ../doc/LICENSE.txt
*
* This file contains the implementaton of the global statistics
*/
#include "NoximGlobalStats.h"
using namespace std;
NoximGlobalStats::NoximGlobalStats(const NoximNoC * _noc)
{
noc = _noc;
#ifdef TESTING
drained_total = 0;
#endif
}
double NoximGlobalStats::getAverageDelay()
{
unsigned int total_packets = 0;
double avg_delay = 0.0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++) {
unsigned int received_packets =
noc->t[x][y]->r->stats.getReceivedPackets();
if (received_packets) {
avg_delay +=
received_packets *
noc->t[x][y]->r->stats.getAverageDelay();
total_packets += received_packets;
}
}
avg_delay /= (double) total_packets;
return avg_delay;
}
double NoximGlobalStats::getAverageDelay(const int src_id,
const int dst_id)
{
NoximTile *tile = noc->searchNode(dst_id);
assert(tile != NULL);
return tile->r->stats.getAverageDelay(src_id);
}
double NoximGlobalStats::getMaxDelay()
{
double maxd = -1.0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++) {
NoximCoord coord;
coord.x = x;
coord.y = y;
int node_id = coord2Id(coord);
double d = getMaxDelay(node_id);
if (d > maxd)
maxd = d;
}
return maxd;
}
double NoximGlobalStats::getMaxDelay(const int node_id)
{
NoximCoord coord = id2Coord(node_id);
unsigned int received_packets =
noc->t[coord.x][coord.y]->r->stats.getReceivedPackets();
if (received_packets)
return noc->t[coord.x][coord.y]->r->stats.getMaxDelay();
else
return -1.0;
}
double NoximGlobalStats::getMaxDelay(const int src_id, const int dst_id)
{
NoximTile *tile = noc->searchNode(dst_id);
assert(tile != NULL);
return tile->r->stats.getMaxDelay(src_id);
}
vector < vector < double > > NoximGlobalStats::getMaxDelayMtx()
{
vector < vector < double > > mtx;
mtx.resize(NoximGlobalParams::mesh_dim_y);
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
mtx[y].resize(NoximGlobalParams::mesh_dim_x);
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++) {
NoximCoord coord;
coord.x = x;
coord.y = y;
int id = coord2Id(coord);
mtx[y][x] = getMaxDelay(id);
}
return mtx;
}
double NoximGlobalStats::getAverageThroughput(const int src_id,
const int dst_id)
{
NoximTile *tile = noc->searchNode(dst_id);
assert(tile != NULL);
return tile->r->stats.getAverageThroughput(src_id);
}
double NoximGlobalStats::getAverageThroughput()
{
unsigned int total_comms = 0;
double avg_throughput = 0.0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++) {
unsigned int ncomms =
noc->t[x][y]->r->stats.getTotalCommunications();
if (ncomms) {
avg_throughput +=
ncomms * noc->t[x][y]->r->stats.getAverageThroughput();
total_comms += ncomms;
}
}
avg_throughput /= (double) total_comms;
return avg_throughput;
}
unsigned int NoximGlobalStats::getReceivedPackets()
{
unsigned int n = 0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++)
n += noc->t[x][y]->r->stats.getReceivedPackets();
return n;
}
unsigned int NoximGlobalStats::getReceivedFlits()
{
unsigned int n = 0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++) {
n += noc->t[x][y]->r->stats.getReceivedFlits();
#ifdef TESTING
drained_total += noc->t[x][y]->r->local_drained;
#endif
}
return n;
}
double NoximGlobalStats::getThroughput()
{
int total_cycles =
NoximGlobalParams::simulation_time -
NoximGlobalParams::stats_warm_up_time;
// int number_of_ip = NoximGlobalParams::mesh_dim_x * NoximGlobalParams::mesh_dim_y;
// return (double)getReceivedFlits()/(double)(total_cycles * number_of_ip);
unsigned int n = 0;
unsigned int trf = 0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++) {
unsigned int rf = noc->t[x][y]->r->stats.getReceivedFlits();
if (rf != 0)
n++;
trf += rf;
}
return (double) trf / (double) (total_cycles * n);
}
vector < vector < unsigned long > > NoximGlobalStats::getRoutedFlitsMtx()
{
vector < vector < unsigned long > > mtx;
mtx.resize(NoximGlobalParams::mesh_dim_y);
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
mtx[y].resize(NoximGlobalParams::mesh_dim_x);
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++)
mtx[y][x] = noc->t[x][y]->r->getRoutedFlits();
return mtx;
}
double NoximGlobalStats::getPower()
{
double power = 0.0;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++)
power += noc->t[x][y]->r->getPower();
return power;
}
void NoximGlobalStats::showStats(std::ostream & out, bool detailed)
{
out << "% Total received packets: " << getReceivedPackets() << endl;
out << "% Total received flits: " << getReceivedFlits() << endl;
out << "% Global average delay (cycles): " << getAverageDelay() <<
endl;
out << "% Global average throughput (flits/cycle): " <<
getAverageThroughput() << endl;
out << "% Throughput (flits/cycle/IP): " << getThroughput() << endl;
out << "% Max delay (cycles): " << getMaxDelay() << endl;
out << "% Total energy (J): " << getPower() << endl;
if (detailed) {
out << endl << "detailed = [" << endl;
for (int y = 0; y < NoximGlobalParams::mesh_dim_y; y++)
for (int x = 0; x < NoximGlobalParams::mesh_dim_x; x++)
noc->t[x][y]->r->stats.showStats(y *
NoximGlobalParams::
mesh_dim_x + x, out,
true);
out << "];" << endl;
// show MaxDelay matrix
vector < vector < double > > md_mtx = getMaxDelayMtx();
out << endl << "max_delay = [" << endl;
for (unsigned int y = 0; y < md_mtx.size(); y++) {
out << " ";
for (unsigned int x = 0; x < md_mtx[y].size(); x++)
out << setw(6) << md_mtx[y][x];
out << endl;
}
out << "];" << endl;
// show RoutedFlits matrix
vector < vector < unsigned long > > rf_mtx = getRoutedFlitsMtx();
out << endl << "routed_flits = [" << endl;
for (unsigned int y = 0; y < rf_mtx.size(); y++) {
out << " ";
for (unsigned int x = 0; x < rf_mtx[y].size(); x++)
out << setw(10) << rf_mtx[y][x];
out << endl;
}
out << "];" << endl;
}
}