Skip to content

Commit

Permalink
fix noc unit test compilation erros
Browse files Browse the repository at this point in the history
  • Loading branch information
soheilshahrouz committed Mar 3, 2024
1 parent 7f2f77e commit fa97eef
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 141 deletions.
8 changes: 6 additions & 2 deletions vpr/src/noc/noc_routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class NocRouting {
// pure virtual functions that should be implemented in derived classes.
public:
virtual ~NocRouting() {}
virtual ~NocRouting() = default;

/**
* @brief Finds a route that goes from the starting router in a
Expand All @@ -57,7 +57,11 @@ class NocRouting {
* @param noc_model A model of the NoC. This is used to traverse the
* NoC and find a route between the two routers.
*/
virtual void route_flow(NocRouterId src_router_id, NocRouterId sink_router_id, NocTrafficFlowId traffic_flow_id, std::vector<NocLinkId>& flow_route, const NocStorage& noc_model) = 0;
virtual void route_flow(NocRouterId src_router_id,
NocRouterId sink_router_id,
NocTrafficFlowId traffic_flow_id,
std::vector<NocLinkId>& flow_route,
const NocStorage& noc_model) = 0;
};

#endif
22 changes: 13 additions & 9 deletions vpr/test/test_bfs_routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,25 @@ TEST_CASE("test_route_flow", "[vpr_noc_bfs_routing]") {

SECTION("Test case where the destination router and the starting routers are the same") {
// choosing the start eand end routers as router 10
NocRouterId start_router_id = NocRouterId(10);
NocRouterId sink_router_id = NocRouterId(10);
auto start_router_id = NocRouterId(10);
auto sink_router_id = NocRouterId(10);
auto traffic_flow_id = NocTrafficFlowId(33);

// store the route found by the algorithm
std::vector<NocLinkId> found_path;

// make sure that a legal route was found (no error should be thrown)
REQUIRE_NOTHROW(routing_algorithm.route_flow(start_router_id, sink_router_id, found_path, noc_model));
REQUIRE_NOTHROW(routing_algorithm.route_flow(start_router_id, sink_router_id, traffic_flow_id, found_path, noc_model));

// now make sure that the found route is empty, we shouldn't be moving anywhere as the start and end routers are the same
REQUIRE(found_path.empty() == true);
}
SECTION("Test case where there is a single shortest path between the source and destination routers in the NoC.") {
// choosing the starting router (source) as the top left corner of the mesh
NocRouterId start_router_id = NocRouterId(12);
auto start_router_id = NocRouterId(12);
// choosing the destination router as the bottom right corner of the mesh
NocRouterId sink_router_id = NocRouterId(3);
auto sink_router_id = NocRouterId(3);
auto traffic_flow_id = NocTrafficFlowId(33);

// store the route to be found by the algorithm
std::vector<NocLinkId> found_path;
Expand All @@ -104,7 +106,7 @@ TEST_CASE("test_route_flow", "[vpr_noc_bfs_routing]") {

// now run the routinjg algorithm
// make sure that a legal route was found (no error should be thrown)
REQUIRE_NOTHROW(routing_algorithm.route_flow(start_router_id, sink_router_id, found_path, noc_model));
REQUIRE_NOTHROW(routing_algorithm.route_flow(start_router_id, sink_router_id, traffic_flow_id, found_path, noc_model));

// check that the found route has the exact same number of links as the expected path
REQUIRE(golden_path.size() == found_path.size());
Expand All @@ -116,9 +118,10 @@ TEST_CASE("test_route_flow", "[vpr_noc_bfs_routing]") {
}
SECTION("Test case where no path could be found") {
// choosing the starting router (source) as the top left corner of the mesh
NocRouterId start_router_id = NocRouterId(12);
auto start_router_id = NocRouterId(12);
// choosing the destination router as the bottom right corner of the mesh
NocRouterId sink_router_id = NocRouterId(3);
auto sink_router_id = NocRouterId(3);
auto traffic_flow_id = NocTrafficFlowId(33);

// Remove any direct links to router 3
noc_model.remove_link(NocRouterId(2), NocRouterId(3));
Expand All @@ -128,7 +131,8 @@ TEST_CASE("test_route_flow", "[vpr_noc_bfs_routing]") {
std::vector<NocLinkId> found_path;

// run the routing algorithm and we expect ir ro fail
REQUIRE_THROWS_WITH(routing_algorithm.route_flow(start_router_id, sink_router_id, found_path, noc_model), "No route could be found from starting router with id:'12' and the destination router with id:'3' using the breadth-first search routing algorithm.");
REQUIRE_THROWS_WITH(routing_algorithm.route_flow(start_router_id, sink_router_id, traffic_flow_id, found_path, noc_model),
"No route could be found from starting router with id:'12' and the destination router with id:'3' using the breadth-first search routing algorithm.");
}
}

Expand Down
Loading

0 comments on commit fa97eef

Please sign in to comment.