Skip to content

Commit 023239a

Browse files
apply some pr comments
1 parent 77ce5f5 commit 023239a

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

vpr/src/noc/channel_dependency_graph.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ class ChannelDependencyGraph {
3333
* @brief Constructor
3434
*
3535
* @param n_links The total number of NoC links.
36-
* @param traffic_flow_routes Generated traffic flow routes by the routing
37-
* algorithm.
36+
* @param traffic_flow_routes The route of each traffic flow generated
37+
* by a routing algorithm.
3838
*/
3939
ChannelDependencyGraph(size_t n_links,
4040
const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& traffic_flow_routes);
4141

4242
/**
43-
* @brief Checks whether CDG has any cycles.
43+
* @brief Checks whether CDG has any cycles. A cycle implies that
44+
* deadlocks are possible. If CDG has no cycles, deadlock freedom
45+
* is guaranteed.
4446
*
4547
* @return True if the CDG has any cycles, otherwise false is returned.
4648
*/

vpr/src/noc/turn_model_routing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ size_t TurnModelRouting::get_hash_value(NocRouterId src_router_id,
88
NocRouterId curr_router_id,
99
NocTrafficFlowId traffic_flow_id) {
1010
// clear inputs from the last time this function was called
11-
inputs_to_murmur3_hahser.clear();
11+
inputs_to_murmur3_hasher.clear();
1212

1313
// used to cast vtr::StrongId types to uint32_t
1414
auto cast_to_uint32 = [](const auto& input) {
1515
return static_cast<uint32_t>(static_cast<size_t>(input));
1616
};
1717

1818
// insert IDs into the vector
19-
inputs_to_murmur3_hahser.push_back(cast_to_uint32(src_router_id));
20-
inputs_to_murmur3_hahser.push_back(cast_to_uint32(dst_router_id));
21-
inputs_to_murmur3_hahser.push_back(cast_to_uint32(curr_router_id));
22-
inputs_to_murmur3_hahser.push_back(cast_to_uint32(traffic_flow_id));
19+
inputs_to_murmur3_hasher.push_back(cast_to_uint32(src_router_id));
20+
inputs_to_murmur3_hasher.push_back(cast_to_uint32(dst_router_id));
21+
inputs_to_murmur3_hasher.push_back(cast_to_uint32(curr_router_id));
22+
inputs_to_murmur3_hasher.push_back(cast_to_uint32(traffic_flow_id));
2323

24-
uint32_t hash_val = murmur3_32(inputs_to_murmur3_hahser, 0);
24+
uint32_t hash_val = murmur3_32(inputs_to_murmur3_hasher, 0);
2525

2626
return hash_val;
2727
}

vpr/src/noc/turn_model_routing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
*
1111
* Overview
1212
* ========
13-
* The TurnModelRouting class abstract Turn Model routing algorithms.
13+
* The TurnModelRouting class abstracts Turn Model routing algorithms.
1414
* The main idea in Turn Model algorithm is to forbid specific turns
1515
* for traffic flows based on the source, destination, and current NoC
1616
* router locations in a mesh or torus topology. TurnModelRouting class
1717
* exposes a shared interface for all Turn Model routing algorithms.
18-
* Derived class can implement specific routing algorithms by implementing
18+
* Derived classes can implement specific routing algorithms by implementing
1919
* their override of the exposed interface. More specifically,
2020
* get_legal_directions() method returns legal directions that a
2121
* traffic flow can follow based on the source, destination, and current
2222
* NoC routers are located. select_next_direction() selects one of these
2323
* legal directions. TurnModelRouting() method does not implement these
2424
* methods, but calls them in route_flow(). For example, XYRouting can be
25-
* implemented by override these two methods. get_legal_directions()
25+
* implemented by overriding these two methods. get_legal_directions()
2626
* should return horizontal directions when the current router and the
2727
* destination are not in the same column. When the traffic flow arrives
2828
* a router located in the same column as the destination,
@@ -219,7 +219,7 @@ class TurnModelRouting : public NocRouting {
219219
std::vector<TurnModelRouting::Direction> returned_legal_direction{4};
220220

221221
private:
222-
std::vector<uint32_t> inputs_to_murmur3_hahser{4};
222+
std::vector<uint32_t> inputs_to_murmur3_hasher{4};
223223

224224
};
225225

vpr/test/test_xy_routing.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
#include "xy_routing.h"
55

6+
namespace {
7+
68
/**
79
* @brief Compares two vectors of NocLinks. These vectors represent
810
* two routes between a start and destination routers. This function
911
* verifies whether the two routers are the exact same or not.
1012
*
1113
*/
12-
static void compare_routes(const std::vector<NocLink>& golden_path, const std::vector<NocLinkId>& found_path, const NocStorage& noc_model) {
14+
void compare_routes(const std::vector<NocLink>& golden_path, const std::vector<NocLinkId>& found_path, const NocStorage& noc_model) {
1315
// make sure that size of the found route and golden route match
1416
REQUIRE(found_path.size() == golden_path.size());
1517

@@ -86,7 +88,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
8688
// choosing the start and end routers as router 10
8789
auto start_router_id = NocRouterId(10);
8890
auto sink_router_id = NocRouterId(10);
89-
auto traffic_flow_id = NocTrafficFlowId (33);
91+
auto traffic_flow_id = NocTrafficFlowId(33);
9092

9193
// store the route found by the algorithm
9294
std::vector<NocLinkId> found_path;
@@ -101,14 +103,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
101103
// choose start router as 7, and choose the destination router as 4
102104
auto start_router_id = NocRouterId(7);
103105
auto sink_router_id = NocRouterId(4);
104-
auto traffic_flow_id = NocTrafficFlowId (34);
106+
auto traffic_flow_id = NocTrafficFlowId(34);
105107

106108
// build the golden route that we expect the algorithm to produce
107109
// the expectation is a number of links that path horizontally from router 7 to router 4
108110
std::vector<NocLink> golden_path;
109111

110112
for (int current_router = 7; current_router != 4; current_router--) {
111-
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1));
113+
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1));
112114
const auto& link = noc_model.get_single_noc_link(link_id);
113115
golden_path.push_back(link);
114116
}
@@ -126,14 +128,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
126128
// choose start router as 2, and choose the destination router as 14
127129
auto start_router_id = NocRouterId(2);
128130
auto sink_router_id = NocRouterId(14);
129-
auto traffic_flow_id = NocTrafficFlowId (35);
131+
auto traffic_flow_id = NocTrafficFlowId(35);
130132

131133
// build the golden route that we expect the algorithm to produce
132134
// the expectation is a number of links that path vertically from router 2 to router 14
133135
std::vector<NocLink> golden_path;
134136

135137
for (int current_row = 0; current_row < 3; current_row++) {
136-
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 2), NocRouterId((current_row + 1) * 4 + 2));
138+
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 2), NocRouterId((current_row + 1) * 4 + 2));
137139
const auto& link = noc_model.get_single_noc_link(link_id);
138140
golden_path.push_back(link);
139141
}
@@ -151,22 +153,22 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
151153
// choose start router as 3, and choose the destination router as 14
152154
auto start_router_id = NocRouterId(3);
153155
auto sink_router_id = NocRouterId(12);
154-
auto traffic_flow_id = NocTrafficFlowId (37);
156+
auto traffic_flow_id = NocTrafficFlowId(37);
155157

156158
// build the golden route that we expect the algorithm to produce
157159
// the expectation is a number of links that path horizontally from router 3 to router 0 and then vertically from router 0 to 12
158160
std::vector<NocLink> golden_path;
159161

160162
// generate the horizontal path first
161163
for (int current_router = 3; current_router != 0; current_router--) {
162-
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1));
164+
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router - 1));
163165
const auto& link = noc_model.get_single_noc_link(link_id);
164166
golden_path.push_back(link);
165167
}
166168

167169
// generate the vertical path next
168170
for (int current_row = 0; current_row < 3; current_row++) {
169-
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4), NocRouterId((current_row + 1) * 4));
171+
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4), NocRouterId((current_row + 1) * 4));
170172
const auto& link = noc_model.get_single_noc_link(link_id);
171173
golden_path.push_back(link);
172174
}
@@ -195,14 +197,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
195197

196198
// generate the horizontal path first
197199
for (int current_router = 12; current_router != 15; current_router++) {
198-
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router + 1));
200+
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_router), NocRouterId(current_router + 1));
199201
const auto& link = noc_model.get_single_noc_link(link_id);
200202
golden_path.push_back(link);
201203
}
202204

203205
// generate the vertical path next
204206
for (int current_row = 3; current_row > 0; current_row--) {
205-
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 3), NocRouterId((current_row - 1) * 4 + 3));
207+
NocLinkId link_id = noc_model.get_single_noc_link_id(NocRouterId(current_row * 4 + 3), NocRouterId((current_row - 1) * 4 + 3));
206208
const auto& link = noc_model.get_single_noc_link(link_id);
207209
golden_path.push_back(link);
208210
}
@@ -282,7 +284,7 @@ TEST_CASE("test_route_flow when it fails in a mesh topology.", "[vpr_noc_xy_rout
282284
// store the source and destination routers
283285
auto start_router_id = NocRouterId(3);
284286
auto sink_router_id = NocRouterId(0);
285-
auto traffic_flow_id = NocTrafficFlowId (39);
287+
auto traffic_flow_id = NocTrafficFlowId(39);
286288

287289
// routers associated to the link to remove
288290
auto link_to_remove_src_router_id = NocRouterId(2);
@@ -308,7 +310,7 @@ TEST_CASE("test_route_flow when it fails in a mesh topology.", "[vpr_noc_xy_rout
308310
// store the source and destination routers
309311
auto start_router_id = NocRouterId(3);
310312
auto sink_router_id = NocRouterId(15);
311-
auto traffic_flow_id = NocTrafficFlowId (41);
313+
auto traffic_flow_id = NocTrafficFlowId(41);
312314

313315
// routers associated to the link to remove
314316
auto link_to_remove_src_router_id = NocRouterId(11);
@@ -366,7 +368,7 @@ TEST_CASE("test_route_flow when it fails in a non mesh topology.", "[vpr_noc_xy_
366368
// now create the start and the destination routers of the route we want to test
367369
auto start_router_id = NocRouterId(3);
368370
auto sink_router_id = NocRouterId(1);
369-
auto traffic_flow_id = NocTrafficFlowId (40);
371+
auto traffic_flow_id = NocTrafficFlowId(40);
370372

371373
// creating the XY routing object
372374
XYRouting routing_algorithm;
@@ -377,4 +379,5 @@ TEST_CASE("test_route_flow when it fails in a non mesh topology.", "[vpr_noc_xy_
377379
// now use the XY router to find a route. We expect this to fail to check that.
378380
REQUIRE_THROWS_WITH(routing_algorithm.route_flow(start_router_id, sink_router_id, traffic_flow_id, found_path, noc_model),
379381
"No route could be found from starting router with ID:'3' and the destination router with ID:'1' using the XY-Routing algorithm.");
380-
}
382+
}
383+
} // namespace

0 commit comments

Comments
 (0)