Skip to content

Commit 09b5802

Browse files
move DEFAULT_MAX_TRAFFIC_FLOW_LATENCY to NocTrafficFlows
1 parent 2fe22e8 commit 09b5802

5 files changed

+30
-41
lines changed

vpr/src/noc/noc_traffic_flows.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ NocTrafficFlows::NocTrafficFlows() {
99

1010
// getters for the traffic flows
1111

12-
int NocTrafficFlows::get_number_of_traffic_flows(void) const {
12+
int NocTrafficFlows::get_number_of_traffic_flows() const {
1313
return noc_traffic_flows.size();
1414
}
1515

@@ -33,7 +33,7 @@ const std::vector<NocTrafficFlowId>& NocTrafficFlows::get_traffic_flows_associat
3333
}
3434
}
3535

36-
int NocTrafficFlows::get_number_of_routers_used_in_traffic_flows(void) {
36+
int NocTrafficFlows::get_number_of_routers_used_in_traffic_flows() {
3737
return traffic_flows_associated_to_router_blocks.size();
3838
}
3939

@@ -49,11 +49,11 @@ const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& NocTrafficFlows::ge
4949
return traffic_flow_routes;
5050
}
5151

52-
const std::vector<ClusterBlockId>& NocTrafficFlows::get_router_clusters_in_netlist(void) const {
52+
const std::vector<ClusterBlockId>& NocTrafficFlows::get_router_clusters_in_netlist() const {
5353
return router_cluster_in_netlist;
5454
}
5555

56-
const std::vector<NocTrafficFlowId>& NocTrafficFlows::get_all_traffic_flow_id(void) const {
56+
const std::vector<NocTrafficFlowId>& NocTrafficFlows::get_all_traffic_flow_id() const {
5757
return noc_traffic_flows_ids;
5858
}
5959

@@ -84,8 +84,6 @@ void NocTrafficFlows::create_noc_traffic_flow(const std::string& source_router_m
8484
// now add the new traffic flow to flows associated with the current source and sink router
8585
add_traffic_flow_to_associated_routers(curr_traffic_flow_id, source_router_cluster_id);
8686
add_traffic_flow_to_associated_routers(curr_traffic_flow_id, sink_router_cluster_id);
87-
88-
return;
8987
}
9088

9189
void NocTrafficFlows::set_router_cluster_in_netlist(const std::vector<ClusterBlockId>& routers_cluster_id_in_netlist) {
@@ -98,18 +96,16 @@ void NocTrafficFlows::set_router_cluster_in_netlist(const std::vector<ClusterBlo
9896

9997
// utility functions for the noc traffic flows
10098

101-
void NocTrafficFlows::finished_noc_traffic_flows_setup(void) {
99+
void NocTrafficFlows::finished_noc_traffic_flows_setup() {
102100
// all the traffic flows have been added, so indicate that the class has been constructed and cannot be modified anymore
103101
built_traffic_flows = true;
104102

105103
// create the storage space for all the traffic flow routes
106104
int number_of_traffic_flows = noc_traffic_flows.size();
107105
traffic_flow_routes.resize(number_of_traffic_flows);
108-
109-
return;
110106
}
111107

112-
void NocTrafficFlows::clear_traffic_flows(void) {
108+
void NocTrafficFlows::clear_traffic_flows() {
113109
// delete any information from internal datastructures
114110
noc_traffic_flows.clear();
115111
noc_traffic_flows_ids.clear();
@@ -119,8 +115,6 @@ void NocTrafficFlows::clear_traffic_flows(void) {
119115

120116
// indicate that traffic flows need to be added again after clear
121117
built_traffic_flows = false;
122-
123-
return;
124118
}
125119

126120
bool NocTrafficFlows::check_if_cluster_block_has_traffic_flows(ClusterBlockId block_id) const {
@@ -144,8 +138,6 @@ void NocTrafficFlows::add_traffic_flow_to_associated_routers(NocTrafficFlowId tr
144138
// there already is a vector associated of traffic flows for the current router, so add it
145139
router_traffic_flows->second.emplace_back(traffic_flow_id);
146140
}
147-
148-
return;
149141
}
150142

151143
void NocTrafficFlows::echo_noc_traffic_flows(char* file_name) {
@@ -208,6 +200,4 @@ void NocTrafficFlows::echo_noc_traffic_flows(char* file_name) {
208200
}
209201

210202
vtr::fclose(fp);
211-
212-
return;
213203
}

vpr/src/noc/noc_traffic_flows.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class NocTrafficFlows {
154154
* @return int An integer that represents the number of unique traffic
155155
* flows within the NoC.
156156
*/
157-
int get_number_of_traffic_flows(void) const;
157+
int get_number_of_traffic_flows() const;
158158

159159
/**
160160
* @brief Given a unique id of a traffic flow (t_noc_traffic_flow)
@@ -192,7 +192,7 @@ class NocTrafficFlows {
192192
* @return int The total number of unique routers used in
193193
* the traffic flows provided by the user.
194194
*/
195-
int get_number_of_routers_used_in_traffic_flows(void);
195+
int get_number_of_routers_used_in_traffic_flows();
196196

197197
/**
198198
* @brief Gets the routed path of traffic flow. This cannot be
@@ -229,13 +229,13 @@ class NocTrafficFlows {
229229
* @return a vector ([0..num_logical_router-1]) where each entry gives the clusterBlockId
230230
* of a logical NoC router. Used for fast lookups in the placer.
231231
*/
232-
const std::vector<ClusterBlockId>& get_router_clusters_in_netlist(void) const;
232+
const std::vector<ClusterBlockId>& get_router_clusters_in_netlist() const;
233233

234234
/**
235235
* @return provides access to all traffic flows' ids to allow a range-based
236236
* loop through all traffic flows, used in noc_place_utils.cpp functions.
237237
*/
238-
const std::vector<NocTrafficFlowId>& get_all_traffic_flow_id(void) const;
238+
const std::vector<NocTrafficFlowId>& get_all_traffic_flow_id() const;
239239

240240
// setters
241241

@@ -294,14 +294,14 @@ class NocTrafficFlows {
294294
*
295295
*/
296296

297-
void finished_noc_traffic_flows_setup(void);
297+
void finished_noc_traffic_flows_setup();
298298

299299
/**
300300
* @brief Resets the class by clearing internal
301301
* datastructures.
302302
*
303303
*/
304-
void clear_traffic_flows(void);
304+
void clear_traffic_flows();
305305

306306
/**
307307
* @brief Given a block from the clustered netlist, determine
@@ -331,6 +331,20 @@ class NocTrafficFlows {
331331
* traffic flow information
332332
*/
333333
void echo_noc_traffic_flows(char* file_name);
334+
335+
336+
/**
337+
* @brief Defines the latency constraint of a traffic flow
338+
* when not provided by the user.
339+
*
340+
* This value has to be significantly larger than latencies
341+
* seen within the NoC so that the net effect in the placement
342+
* cost is 0 (the latency constraint has no effect since there is none).
343+
* Since the traffic flow latencies will be in nanoseconds,
344+
* setting this value to 1 second which is significantly larger
345+
* than what will be seen in the NoC.
346+
*/
347+
static constexpr double DEFAULT_MAX_TRAFFIC_FLOW_LATENCY = 1.;
334348
};
335349

336350
#endif

vpr/src/noc/read_xml_noc_traffic_flows_file.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
void read_xml_noc_traffic_flows_file(const char* noc_flows_file) {
55
// start by checking that the provided file is a ".flows" file
6-
if (vtr::check_file_name_extension(noc_flows_file, ".flows") == false) {
6+
if (!vtr::check_file_name_extension(noc_flows_file, ".flows")) {
77
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "NoC traffic flows file '%s' has an unknown extension. Expecting .flows for NoC traffic flow files.", noc_flows_file);
88
}
99

@@ -72,8 +72,6 @@ void read_xml_noc_traffic_flows_file(const char* noc_flows_file) {
7272
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_NOC_TRAFFIC_FLOWS)) {
7373
noc_ctx.noc_traffic_flows_storage.echo_noc_traffic_flows(getEchoFileName(E_ECHO_NOC_TRAFFIC_FLOWS));
7474
}
75-
76-
return;
7775
}
7876

7977
void process_single_flow(pugi::xml_node single_flow_tag,
@@ -125,8 +123,6 @@ void process_single_flow(pugi::xml_node single_flow_tag,
125123
traffic_flow_bandwidth,
126124
max_traffic_flow_latency,
127125
traffic_flow_priority);
128-
129-
return;
130126
}
131127

132128
double get_traffic_flow_bandwidth(pugi::xml_node single_flow_tag, const pugiutil::loc_data& loc_data) {
@@ -144,7 +140,7 @@ double get_traffic_flow_bandwidth(pugi::xml_node single_flow_tag, const pugiutil
144140

145141
double get_max_traffic_flow_latency(pugi::xml_node single_flow_tag, const pugiutil::loc_data& loc_data) {
146142
// "set to large value, indicating no constraint
147-
double max_traffic_flow_latency = DEFAULT_MAX_TRAFFIC_FLOW_LATENCY;
143+
double max_traffic_flow_latency = NocTrafficFlows::DEFAULT_MAX_TRAFFIC_FLOW_LATENCY;
148144

149145
// holds the latency value as a string so that it can be used to convert to a floating point value (this is done so that scientific notation is supported)
150146
std::string max_traffic_flow_latency_intermediate_val;
@@ -194,8 +190,6 @@ void verify_traffic_flow_router_modules(const std::string& source_router_name, c
194190
// Cannot have the source and sink routers have the same name (they need to be different). A flow cant go to a single router.
195191
vpr_throw(VPR_ERROR_OTHER, loc_data.filename_c_str(), loc_data.line(single_flow_tag), "Source and sink NoC routers cannot be the same modules.");
196192
}
197-
198-
return;
199193
}
200194

201195
void verify_traffic_flow_properties(double traffic_flow_bandwidth, double max_traffic_flow_latency, int traffic_flow_priority, pugi::xml_node single_flow_tag, const pugiutil::loc_data& loc_data) {
@@ -213,8 +207,6 @@ void verify_traffic_flow_properties(double traffic_flow_bandwidth, double max_tr
213207
if (traffic_flow_priority <= 0) {
214208
vpr_throw(VPR_ERROR_OTHER, loc_data.filename_c_str(), loc_data.line(single_flow_tag), "The traffic flow priorities expected to be positive, non-zero integer values.");
215209
}
216-
217-
return;
218210
}
219211

220212
ClusterBlockId get_router_module_cluster_id(const std::string& router_module_name,
@@ -254,8 +246,6 @@ void check_traffic_flow_router_module_type(const std::string& router_module_name
254246
if (!is_tile_compatible(noc_router_tile_type, router_module_logical_type)) {
255247
vpr_throw(VPR_ERROR_OTHER, loc_data.filename_c_str(), loc_data.line(single_flow_tag), "The supplied module name '%s' is not a NoC router.", router_module_name.c_str());
256248
}
257-
258-
return;
259249
}
260250

261251
t_physical_tile_type_ptr get_physical_type_of_noc_router_tile(const DeviceContext& device_ctx, NocContext& noc_ctx) {

vpr/src/noc/read_xml_noc_traffic_flows_file.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
// identifier when an integer conversion failed while reading an attribute value in an xml file
4040
constexpr int NUMERICAL_ATTRIBUTE_CONVERSION_FAILURE = -1;
4141

42-
// defines the latency constraint of a traffic flow when not provided by the user
43-
// This value has to be significantly larger than latencies seen within the NoC so that the net effect in the placement cost is 0 (the latency constraint has no effect since there is none)
44-
// Since the traffic flow latencies will be in nanoseconds, setting this value to 1 second which is significantly larger that what will be seen in the NoC
45-
constexpr double DEFAULT_MAX_TRAFFIC_FLOW_LATENCY = 1.;
46-
4742
// defines the priority of a traffic flow when not specified by a user
4843
constexpr int DEFAULT_TRAFFIC_FLOW_PRIORITY = 1;
4944

vpr/src/noc/sat_routing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static void create_flow_link_vars(orsat::CpModelBuilder& cp_model,
482482
const auto& traffic_flow = traffic_flow_storage.get_single_noc_traffic_flow(traffic_flow_id);
483483

484484
// create an integer variable for each latency-constrained traffic flow
485-
if (traffic_flow.max_traffic_flow_latency < 0.1) {
485+
if (traffic_flow.max_traffic_flow_latency < NocTrafficFlows::DEFAULT_MAX_TRAFFIC_FLOW_LATENCY) {
486486
latency_overrun_vars[traffic_flow_id] = cp_model.NewIntVar(latency_overrun_domain);
487487
}
488488

@@ -530,7 +530,7 @@ static int comp_max_number_of_traversed_links(NocTrafficFlowId traffic_flow_id)
530530

531531
const double traffic_flow_latency_constraint = traffic_flow.max_traffic_flow_latency;
532532

533-
VTR_ASSERT(traffic_flow_latency_constraint < 0.1);
533+
VTR_ASSERT(traffic_flow_latency_constraint < NocTrafficFlows::DEFAULT_MAX_TRAFFIC_FLOW_LATENCY);
534534

535535
int n_max_links = std::floor((traffic_flow_latency_constraint - noc_router_latency) / (noc_link_latency + noc_router_latency));
536536

0 commit comments

Comments
 (0)