-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathglobal.cc
More file actions
executable file
·461 lines (442 loc) · 19.8 KB
/
Copy pathglobal.cc
File metadata and controls
executable file
·461 lines (442 loc) · 19.8 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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
/*
FOGSim, simulator for interconnection networks.
http://fuentesp.github.io/fogsim/
Copyright (C) 2017 University of Cantabria
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "global.h"
class generatorModule;
class switchModule;
using namespace std;
/* General parameters */
long long g_max_cycles = 10000; /* Maximum number of simulated cycles */
long long g_warmup_cycles = g_max_cycles; /* Number of warm-up cycles; in those,
* no general statistics are collected
* (but some specific ones are) */
int g_print_cycles = 100; /* Number of cycles between printing
* temporary stats to the stdout. */
long long g_injection_queue_length = 999999; /* Injection queue size in phits */
long long g_local_queue_length = 10; /* Local link queue size in phits */
long long g_global_queue_length = 100; /* Global link queue size in phits */
long long g_out_queue_length = 10; /* Output queue size in phits (only used
* under InputOutputQueued switch). */
int g_ring_injection_bubble = 1; /* Deadlock-avoidance bubble to respect when
* injecting packets to ring (preserves
* packet advance through ring) */
int g_p_computing_nodes_per_router = 4; /* Number of computing nodes ('p') per router */
int g_a_routers_per_group = 4; /* Number of routers ('a') per group */
int g_h_global_ports_per_router = 1; /* Number of global ports ('h') per router;
* total number of groups will be a*h+1 */
long long g_xbar_delay = 1; /* Delay when forwarding flit from input to
* output buffers (only with InputOutputQueueing) */
long long g_injection_delay = 1; /* Delay at injection queues */
long long g_local_link_transmission_delay = 1; /* Flit delay end-to-end of a local link */
long long g_global_link_transmission_delay = 1; /* Flit delay end-to-end of a global link */
int g_injection_channels = 1; /* Number of VCs in injection queues; refers
* amount of generators per computing node */
int g_local_link_channels = 1; /* Number of VCs in local links */
int g_global_link_channels = 1; /* Number of VCs in global links */
int g_local_res_channels = 0; /* Number of VCs in local links reserved for responses
* (exclusive for reactive traffic patterns)*/
int g_global_res_channels = 0; /* Number of VCs in global links reserved for responses
* (exclusive for reactive traffic patterns)*/
int g_segregated_flows = 1; /* Number of segregated traffic flows at output
* ports; currently only used to segregate petitions
* from responses at the consumption nodes. */
int g_flit_size = 1; /* Flit size in phits */
int g_packet_size = 1; /* Packet size in phits */
float g_injection_probability = 1; /* Packet injection probability at a generator.
* It ranges between 0 and 100 (it is expressed
* as a percentage). When multiplied by packet
* size and number of generators, gives total
* injection rate within the network */
char *g_output_file_name; /* Results filename */
long long g_seed = 1; /* Employed seed (to randomize simulations) */
int g_allocator_iterations = 3; /* Number of (local/global) arbiter iterations
* within an allocation cycle */
int g_local_arbiter_speedup = 1; /* SpeedUp within local arbiter: number of ports to
* crossbar for every input port. */
bool g_issue_parallel_reqs = true; /* Used in conjunction with local_arbiter_speedup,
* if set allows to make as many requests as speedup
* in a single allocation iteration */
float g_internal_speedup = 1.0; /* SpeedUp in router frequency: router allocation
* cycles are conducted faster and more frequently
* than simulation cycles (only with InputOutputQueueing) */
bool g_palm_tree_configuration = 0;
bool g_transient_stats = false; /* Determines if temporal statistics over simulation
* time are tracked or not. Mainly related to transient
* and trace traffic. */
unsigned short g_cos_levels = 1; /* Number of Class of Service levels - Ethernet 802.1q */
bool g_print_hists = false; /* Chooses whether to print latency and injection
* histograms or not. */
/* General variables */
long long g_cycle = 0; /* Current cycle, tracks amount of simulated cycles */
long double g_internal_cycle = 0.0; /* Current internal cycle, determines when switch simulation
* is conducted (only profited in InputOutputQueued switch
* with internal speedUp) */
int g_iteration = 0; /* Global variable to exchange current iteration value
* between allocation operation and petition attendance */
int g_local_router_links_offset = 0; /* Local links offset among router ports; followed
* port convention is:
* computing nodes < local links < global links,
* where local links connect a router with the rest
* of routers within the same group, and global
* links connect the router with other groups */
int g_global_router_links_offset = 0; /* Global links offset among router ports */
int g_global_links_per_group = g_a_routers_per_group * g_h_global_ports_per_router; /* Convenience variable,
* tracks amount of global
* links per group (this is,
* number of groups
* in the network -1) */
int g_number_switches = (g_a_routers_per_group * g_h_global_ports_per_router + 1) * g_a_routers_per_group; /* Total number of switches in the network */
int g_number_generators = g_number_switches * g_p_computing_nodes_per_router; /* Total number of computing
* nodes in the network */
int g_channels = 1; /* Number of VCs in the network, as a max of local,
* global and injections VCs PLUS those in the escape
* subnetwork, when the latter is embedded */
int g_flits_per_packet = 0; /* Packet size in flits */
ofstream g_output_file; /* Results file */
generatorModule **g_generators_list; /* List of generator modules */
switchModule **g_switches_list; /* List of router modules */
int g_ports = g_p_computing_nodes_per_router + g_a_routers_per_group - 1 + g_h_global_ports_per_router; /* Number of ports per router */
default_random_engine g_reng;
/* Switch type */
SwitchType g_switch_type = BASE_SW;
/* Buffer type */
BufferType g_buffer_type = SEPARATED;
int g_local_queue_reserved = 1;
int g_global_queue_reserved = 1;
/* Arbiter type */
ArbiterType g_input_arbiter_type = LRS;
ArbiterType g_output_arbiter_type = PrioLRS;
/* Traffic type */
TrafficType g_traffic = UN; /* Traffic pattern */
bool g_reactive_traffic = false; /* Reactive traffic */
/* Adversarial traffic parameters */
int g_adv_traffic_distance = 1; /* Distance to the adverse traffic destination group/router (depending on pattern) */
/* Auxiliary parameters (employed in many traffic types) */
vector<TrafficType> g_phase_traffic_type;
vector<int> g_phase_traffic_adv_dist;
float g_phase_traffic_probability[2];
vector<int> g_phase_traffic_percent;
bool g_cluster_random = false;
int *g_cluster_random_distribution;
bool g_cluster_interleaved = false;
int **g_cluster_start_end_node;
bool g_cluster_destinations = false;
long double *g_cluster_flit_latency;
long double *g_cluster_warmup_flit_latency;
long long *g_cluster_rx_flit_counter;
long long *g_cluster_warmup_rx_flit_counter;
/* Transient traffic parameters */
int g_transient_traffic_cycle = 0;
/* All To All traffic parameters */
int g_phases = -1;
AllToAllType g_all2all_type = LINEAR_SHIFT_DESTINATIONS;
int *g_all2all_random_placement;
bool g_random_AllToAll = 0;
int *g_all2all_completition_time_by_node;
/* Burst traffic parameters */
int g_single_burst_length = 100; /* Burst length in flits */
/* Bursty UN traffic parameters */
int g_bursty_avg_length = 1; /* Average burst size in packets */
/* Reactive traffic parameters */
int g_max_petitions_on_flight = -1;
/* Graph 500 traffic parameters */
int g_graph_coalescing_size = 256;
vector<int> g_graph_nodes_cap_mod;
int g_graph_cap_mod_factor = 100;
vector<int> g_graph_root_node;
vector<int> g_graph_root_degree;
float g_graph_query_time;
int g_graph_scale;
int g_graph_edgefactor;
vector<int> g_graph_tree_level;
vector<long long> g_graph_queries_remain;
vector<long long> g_graph_queries_rem_minus_means;
long long ***g_graph_p2pmess_node2node;
int g_graph_max_levels = 9;
long long g_graph_p2pmess = 0;
/* End-point congestion traffic parameters */
int g_percent_traffic_to_congest = 25;
/* Hot-region traffic parameters */
float g_percent_nodes_into_region = 12.5;
/* Hot-spot traffic parameters */
int g_hotspot_node = 0;
/* Random permutation auxiliar variable */
vector<int> g_available_generators;
/* Stencil traffic parameters */
StencilSendOrder g_stencil_send_order = ASC;
string g_stencil_matrix_file;
unsigned int g_stencil_iterations = 1;
unsigned int g_stencil_compute_delay = 1;
vector<vector<tuple<unsigned int, unsigned int>>> *g_stencil_exchangeSendMessages;
/* Routing */
RoutingType g_routing = MIN;
VcUsageType g_vc_usage = BASE;
VcAllocationMechanism g_vc_alloc = LOWEST_OCCUPANCY;
VcInjectionPolicy g_vc_injection = DEST;
int g_ugal_local_threshold = 0;
int g_ugal_global_threshold = 5;
int g_piggyback_coef = 200;
int g_th_min = 0;
ValiantType g_valiant_type = SRCEXC;
valiantMisroutingDestination g_valiant_misrouting_destination = NODE;
ugalMisroutingInformationScope g_ugal_misrouting_information_scope = MISGLOBAL;
bool g_reset_val = false;
bool g_vc_misrouting_congested_restriction = false;
int g_vc_misrouting_congested_restriction_coef_percent = 150;
int g_vc_misrouting_congested_restriction_th = 5;
GlobalMisroutingPolicy g_global_misrouting = MM_L;
MisroutingTrigger g_misrouting_trigger = CGA;
CongestionDetection g_congestion_detection = PER_PORT;
bool g_relative_threshold = 0;
int g_percent_local_threshold = 100;
int g_percent_global_threshold = 100;
bool g_contention_aware = false;
int g_contention_aware_th = 3;
int g_contention_aware_local_th = -1;
int g_contention_aware_global_th = 8;
bool g_increaseContentionAtHeader = true;
float g_filtered_contention_regressive_coefficient = 0.5;
DeadlockAvoidance g_deadlock_avoidance = DALLY;
int g_rings = 0;
int g_ringDirs = 0;
int g_ring_ports = 0;
bool g_onlyRing2 = 0;
bool g_forbid_from_inj_queues_to_ring = 1;
int g_restrictLocalCycles = 0;
int g_globalEmbeddedRingSwitchesCount = -1;
int g_localEmbeddedRingSwitchesCount = -1;
int g_tree_root_node = -1;
int g_tree_root_switch = -1;
int g_localEmbeddedTreeSwitchesCount = -1;
int g_channels_escape = 0;
CongestionManagement g_congestion_management = BCM;
int g_baseCongestionControl_bub = 0;
int g_escapeCongestion_th = 100;
int g_forceMisrouting = 0;
bool g_try_just_escape = 0;
float g_car_misroute_factor = 2;
float g_car_misroute_th = 1;
int g_local_window_size = 2;
int g_global_window_size = 2;
/* ACOR global parameters */
acorStateManagement g_acor_state_management = SWITCHCGCSRS;
int g_acor_hysteresis_cycle_duration_cycles;
int g_acor_inc_state_first_th_packets;
int g_acor_dec_state_first_th_packets;
int g_acor_inc_state_second_th_packets;
int g_acor_dec_state_second_th_packets;
/* IEEE 802.1Qbb */
unsigned int g_pause_go;
/* Quantized Congestion Nofitication - 802.1Qau */
float g_qcn_gd = (float) 1/128;
int g_qcn_bc_limit = 30000;
float g_qcn_timer_period = 0.01;
float g_qcn_r_ai = 0.0000125;
float g_qcn_r_hai = 0.000125;
int g_qcn_fast_recovery_th = 5;
float g_qcn_min_rate = 0.0000125;
unsigned int g_qcn_q_eq = 6600;
float g_qcn_w = 2.0;
float g_qcn_c = g_injection_probability;
long long g_qcn_queue_length = 1000;
unsigned int g_qcn_cp_sampling_interval = 30000;
int g_qcn_port;
QcnSwImplementation g_qcn_implementation = QCNSWBASE;
QcnSwPolicy g_qcn_policy = AIMD;
int g_qcn_th1 = 0;
int g_qcn_th2 = 0;
int g_qcn_cnms_percent = 10;
float ***g_qcn_g0_port_enroute_min_prob;
bool g_qcn_transient_stats = false;
int ***g_qcn_g0_port_congestion;
/* TPR configuration parameters */
short g_tpr_history_window_cycles = 50;
tprCountersMode g_tpr_counters_mode = INBOUND;
short g_tpr_combine_period = 0;
/* TPR/LITPR configuration parameters */
float g_tpr_intra_low_inj;
float g_tpr_intra_low_tra;
float g_tpr_intra_high_inj;
float g_tpr_intra_high_tra;
float g_tpr_inter_low_inj;
float g_tpr_inter_low_tra;
float g_tpr_inter_high_inj;
float g_tpr_inter_high_tra;
int g_tpr_intra_ugal_threshold_values[9];
int g_tpr_inter_ugal_threshold_values[9];
float g_tpr_remain_weigh;
short g_litpr_th_global_saturated;
short g_litpr_th_change2sw;
short g_litpr_th_change2rrg;
/* Statistics variables */
long double g_flit_latency = 0;
long double g_packet_latency = 0;
long double g_injection_queue_latency = 0;
long double g_base_latency = 0;
long double g_warmup_flit_latency;
long double g_warmup_packet_latency;
long double g_warmup_injection_latency;
long double g_response_latency;
float *g_transient_record_latency;
float *g_transient_record_injection_latency;
long double *g_group0_totalLatency;
long double *g_groupRoot_totalLatency;
int g_latency_histogram_maxLat = 1;
vector<long long> g_latency_histogram_no_global_misroute;
vector<long long> g_latency_histogram_global_misroute_at_injection;
vector<long long> g_latency_histogram_other_global_misroute;
long long g_tx_flit_counter = 0;
long long g_tx_cnmFlit_counter = 0;
long long g_tx_flit_counter_printC = 0;
long long g_rx_flit_counter = 0;
long long g_rx_cnmFlit_counter = 0;
long long g_rx_acorState_counter[4] = { 0 };
long long g_rx_tpr_intra_classification_counter[9] = { 0 };
long long g_rx_tpr_inter_classification_counter[9] = { 0 };
long long g_rx_flit_counter_printC = 0;
long long g_attended_flit_counter = 0;
long long g_tx_warmup_flit_counter = 0;
long long g_tx_warmup_cnmFlit_counter = 0;
long long g_rx_warmup_flit_counter = 0;
long long g_rx_warmup_cnmFlit_counter = 0;
long long g_rx_warmup_acorState_counter[4] = { 0 };
long long g_rx_warmup_tpr_intra_classification_counter[9] = { 0 };
long long g_rx_warmup_tpr_inter_classification_counter[9] = { 0 };
long long g_response_counter = 0;
long long g_response_warmup_counter = 0;
long long g_nonminimal_counter = 0;
long long g_nonminimal_warmup_counter = 0;
long long g_nonminimal_inj = 0;
long long g_nonminimal_warmup_inj = 0;
long long g_nonminimal_src = 0;
long long g_nonminimal_warmup_src = 0;
long long g_nonminimal_int = 0;
long long g_nonminimal_warmup_int = 0;
long long g_min_flit_counter[4] = { 0 };
long long g_global_misrouted_flit_counter[4] = { 0 };
long long g_global_mandatory_misrouted_flit_counter[4] = { 0 };
long long g_local_misrouted_flit_counter[4] = { 0 };
int *g_transient_record_flits;
int *g_transient_record_misrouted_flits;
long long ***g_group0_numFlits;
// g_group0_misroutedFlitsType[router][host][CRG,RRG,NRG,MM][GROUP,NODE]
long long ****g_group0_misroutedFlitsType;
int **g_acor_group0_sws_packets_blocked;
int **g_acor_group0_sws_status;
long long *g_groupRoot_numFlits;
float *g_transient_net_injection_latency;
float *g_transient_net_injection_inj_latency;
int *g_transient_net_injection_flits;
int *g_transient_net_injection_misrouted_flits;
long long g_tx_packet_counter = 0;
long long g_rx_packet_counter = 0;
long long g_tx_warmup_packet_counter = 0;
long long g_rx_warmup_packet_counter = 0;
long long g_injected_packet_counter = 0;
long long g_injected_bursts_counter = 0;
long long g_total_hop_counter = 0;
long long g_local_hop_counter = 0;
long long g_global_hop_counter = 0;
long long g_local_ring_hop_counter = 0;
long long g_global_ring_hop_counter = 0;
long long g_local_tree_hop_counter = 0;
long long g_global_tree_hop_counter = 0;
long long g_max_hops = 0;
long long g_max_local_hops = 0;
long long g_max_global_hops = 0;
long long g_max_local_subnetwork_hops = 0;
long long g_max_global_subnetwork_hops = 0;
long long g_max_local_ring_hops = 0;
long long g_max_global_ring_hops = 0;
long long g_max_local_tree_hops = 0;
long long g_max_global_tree_hops = 0;
int g_hops_histogram_maxHops = 200;
long long * g_hops_histogram;
long long g_port_usage_counter[100];
vector<vector<long long> > g_vc_counter;
long long g_port_contention_counter[100];
long long g_subnetwork_injections_counter = 0;
long long g_root_subnetwork_injections_counter = 0;
long long g_source_subnetwork_injections_counter = 0;
long long g_dest_subnetwork_injections_counter = 0;
long double g_local_contention_counter = 0;
long double g_global_contention_counter = 0;
long double g_local_escape_contention_counter = 0;
long double g_global_escape_contention_counter = 0;
unsigned int g_petitions = 0;
unsigned int g_served_petitions = 0;
unsigned int g_injection_petitions = 0;
unsigned int g_served_injection_petitions = 0;
long long g_max_injection_packets_per_sw = 0;
long long g_max_injection_cnmPackets_per_sw = 0;
int g_sw_with_max_injection_pkts = -1;
int g_sw_with_max_injection_cnmPkts = -1;
long long g_min_injection_packets_per_sw = 0;
long long g_min_injection_cnmPackets_per_sw = 0;
int g_sw_with_min_injection_pkts = -1;
int g_sw_with_min_injection_cnmPkts = -1;
int g_transient_record_len = 10100;
int g_transient_record_num_cycles = 10000;
int g_transient_record_num_prev_cycles = 100;
int g_AllToAll_generators_finished_count = 0;
int g_burst_generators_finished_count = 0;
long long g_max_subnetwork_injections = 0;
long long g_max_root_subnetwork_injections = 0;
long long g_max_source_subnetwork_injections = 0;
long long g_max_dest_subnetwork_injections = 0;
set<int> g_verbose_switches;
int g_verbose_cycles = 5;
/* TPR/LITPR group 0 statistics */
unsigned short ***g_tpr_group0_intra_l2r;
unsigned short ***g_tpr_group0_intra_l2r_min;
unsigned short ***g_tpr_group0_intra_l2r_max;
unsigned short ***g_tpr_group0_intra_otp;
unsigned short ***g_tpr_group0_intra_otp_min;
unsigned short ***g_tpr_group0_intra_otp_max;
unsigned short ***g_tpr_group0_inter_l2g;
unsigned short ***g_tpr_group0_inter_l2g_min;
unsigned short ***g_tpr_group0_inter_l2g_max;
unsigned short ***g_tpr_group0_interCombined_l2g;
unsigned short ***g_tpr_group0_interCombined_l2g_min;
unsigned short ***g_tpr_group0_interCombined_l2g_max;
unsigned short ***g_tpr_group0_inter_otr2g;
unsigned short ***g_tpr_group0_inter_otr2g_min;
unsigned short ***g_tpr_group0_inter_otr2g_max;
unsigned short ***g_tpr_group0_inter_otp;
unsigned short ***g_tpr_group0_inter_otp_min;
unsigned short ***g_tpr_group0_inter_otp_max;
unsigned short ***g_litpr_group0_derived_counter;
unsigned short ***g_litpr_group0_derived_counter_min;
unsigned short ***g_litpr_group0_derived_counter_max;
unsigned int **g_litpr_group0_derived_global;
/* Traces support */
int g_num_traces = 0;
vector<string> g_trace_file;
vector<string> g_pcf_file;
vector<vector<long> > g_event_deadlock;
vector<long> g_trace_nodes;
vector<int> g_trace_instances;
vector<vector<bool> > g_trace_ended;
vector<vector<long> > g_trace_end_cycle;
TraceAssignation g_trace_distribution = CONSECUTIVE;
double g_cpu_speed = 1e9;
long g_op_per_cycle = 50;
long g_multitask = 1;
long g_phit_size = 4; /* Phit size in bytes, for trace messages translation into simulator packets */
bool g_cutmpi = 1;
map<long, long> g_events_map;
map<int, TraceNodeId> g_gen_2_trace_map;
vector<vector<vector<int> > > g_trace_2_gen_map;