3
3
4
4
#include " xy_routing.h"
5
5
6
+ namespace {
7
+
6
8
/* *
7
9
* @brief Compares two vectors of NocLinks. These vectors represent
8
10
* two routes between a start and destination routers. This function
9
11
* verifies whether the two routers are the exact same or not.
10
12
*
11
13
*/
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) {
13
15
// make sure that size of the found route and golden route match
14
16
REQUIRE (found_path.size () == golden_path.size ());
15
17
@@ -86,7 +88,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
86
88
// choosing the start and end routers as router 10
87
89
auto start_router_id = NocRouterId (10 );
88
90
auto sink_router_id = NocRouterId (10 );
89
- auto traffic_flow_id = NocTrafficFlowId (33 );
91
+ auto traffic_flow_id = NocTrafficFlowId (33 );
90
92
91
93
// store the route found by the algorithm
92
94
std::vector<NocLinkId> found_path;
@@ -101,14 +103,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
101
103
// choose start router as 7, and choose the destination router as 4
102
104
auto start_router_id = NocRouterId (7 );
103
105
auto sink_router_id = NocRouterId (4 );
104
- auto traffic_flow_id = NocTrafficFlowId (34 );
106
+ auto traffic_flow_id = NocTrafficFlowId (34 );
105
107
106
108
// build the golden route that we expect the algorithm to produce
107
109
// the expectation is a number of links that path horizontally from router 7 to router 4
108
110
std::vector<NocLink> golden_path;
109
111
110
112
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 ));
112
114
const auto & link = noc_model.get_single_noc_link (link_id);
113
115
golden_path.push_back (link );
114
116
}
@@ -126,14 +128,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
126
128
// choose start router as 2, and choose the destination router as 14
127
129
auto start_router_id = NocRouterId (2 );
128
130
auto sink_router_id = NocRouterId (14 );
129
- auto traffic_flow_id = NocTrafficFlowId (35 );
131
+ auto traffic_flow_id = NocTrafficFlowId (35 );
130
132
131
133
// build the golden route that we expect the algorithm to produce
132
134
// the expectation is a number of links that path vertically from router 2 to router 14
133
135
std::vector<NocLink> golden_path;
134
136
135
137
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 ));
137
139
const auto & link = noc_model.get_single_noc_link (link_id);
138
140
golden_path.push_back (link );
139
141
}
@@ -151,22 +153,22 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
151
153
// choose start router as 3, and choose the destination router as 14
152
154
auto start_router_id = NocRouterId (3 );
153
155
auto sink_router_id = NocRouterId (12 );
154
- auto traffic_flow_id = NocTrafficFlowId (37 );
156
+ auto traffic_flow_id = NocTrafficFlowId (37 );
155
157
156
158
// build the golden route that we expect the algorithm to produce
157
159
// the expectation is a number of links that path horizontally from router 3 to router 0 and then vertically from router 0 to 12
158
160
std::vector<NocLink> golden_path;
159
161
160
162
// generate the horizontal path first
161
163
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 ));
163
165
const auto & link = noc_model.get_single_noc_link (link_id);
164
166
golden_path.push_back (link );
165
167
}
166
168
167
169
// generate the vertical path next
168
170
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 ));
170
172
const auto & link = noc_model.get_single_noc_link (link_id);
171
173
golden_path.push_back (link );
172
174
}
@@ -195,14 +197,14 @@ TEST_CASE("test_route_flow", "[vpr_noc_xy_routing]") {
195
197
196
198
// generate the horizontal path first
197
199
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 ));
199
201
const auto & link = noc_model.get_single_noc_link (link_id);
200
202
golden_path.push_back (link );
201
203
}
202
204
203
205
// generate the vertical path next
204
206
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 ));
206
208
const auto & link = noc_model.get_single_noc_link (link_id);
207
209
golden_path.push_back (link );
208
210
}
@@ -282,7 +284,7 @@ TEST_CASE("test_route_flow when it fails in a mesh topology.", "[vpr_noc_xy_rout
282
284
// store the source and destination routers
283
285
auto start_router_id = NocRouterId (3 );
284
286
auto sink_router_id = NocRouterId (0 );
285
- auto traffic_flow_id = NocTrafficFlowId (39 );
287
+ auto traffic_flow_id = NocTrafficFlowId (39 );
286
288
287
289
// routers associated to the link to remove
288
290
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
308
310
// store the source and destination routers
309
311
auto start_router_id = NocRouterId (3 );
310
312
auto sink_router_id = NocRouterId (15 );
311
- auto traffic_flow_id = NocTrafficFlowId (41 );
313
+ auto traffic_flow_id = NocTrafficFlowId (41 );
312
314
313
315
// routers associated to the link to remove
314
316
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_
366
368
// now create the start and the destination routers of the route we want to test
367
369
auto start_router_id = NocRouterId (3 );
368
370
auto sink_router_id = NocRouterId (1 );
369
- auto traffic_flow_id = NocTrafficFlowId (40 );
371
+ auto traffic_flow_id = NocTrafficFlowId (40 );
370
372
371
373
// creating the XY routing object
372
374
XYRouting routing_algorithm;
@@ -377,4 +379,5 @@ TEST_CASE("test_route_flow when it fails in a non mesh topology.", "[vpr_noc_xy_
377
379
// now use the XY router to find a route. We expect this to fail to check that.
378
380
REQUIRE_THROWS_WITH (routing_algorithm.route_flow (start_router_id, sink_router_id, traffic_flow_id, found_path, noc_model),
379
381
" 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