Skip to content

Commit 0827d99

Browse files
Updated test_find_affected_noc_routers_and_update_noc_costs to check routes after revert
1 parent 304de90 commit 0827d99

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

vpr/test/test_noc_place_utils.cpp

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
11951195
SECTION("Test case where the bandwidth cost is 0") {
11961196
costs.noc_aggregate_bandwidth_cost = 0.;
11971197
costs.noc_latency_cost = 1.;
1198+
costs.noc_congestion_cost = 1.;
11981199

11991200
// run the test function
12001201
update_noc_normalization_factors(costs);
@@ -1206,6 +1207,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
12061207
SECTION("Test case where the latency cost is 0") {
12071208
costs.noc_aggregate_bandwidth_cost = 1.;
12081209
costs.noc_latency_cost = 0.;
1210+
costs.noc_congestion_cost = 1.;
12091211

12101212
// run the test function
12111213
update_noc_normalization_factors(costs);
@@ -1217,6 +1219,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
12171219
SECTION("Test case where the bandwidth cost is an expected value") {
12181220
costs.noc_aggregate_bandwidth_cost = 1.e9;
12191221
costs.noc_latency_cost = 0.;
1222+
costs.noc_congestion_cost = 1.;
12201223

12211224
// run the test function
12221225
update_noc_normalization_factors(costs);
@@ -1228,6 +1231,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
12281231
SECTION("Test case where the latency cost is an expected value") {
12291232
costs.noc_aggregate_bandwidth_cost = 1.;
12301233
costs.noc_latency_cost = 50.e-12;
1234+
costs.noc_congestion_cost = 1.;
12311235

12321236
// run the test function
12331237
update_noc_normalization_factors(costs);
@@ -1239,6 +1243,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
12391243
SECTION("Test case where the latency cost is lower than the smallest expected value") {
12401244
costs.noc_aggregate_bandwidth_cost = 1.;
12411245
costs.noc_latency_cost = 999.e-15;
1246+
costs.noc_congestion_cost = 1.;
12421247

12431248
// run the test function
12441249
update_noc_normalization_factors(costs);
@@ -1247,6 +1252,41 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
12471252
// this should not be trimmed
12481253
REQUIRE(costs.noc_latency_cost_norm == 1.e12);
12491254
}
1255+
SECTION("Test case where the congestion cost is zero") {
1256+
costs.noc_aggregate_bandwidth_cost = 1.;
1257+
costs.noc_latency_cost = 1.;
1258+
costs.noc_congestion_cost = 0.;
1259+
1260+
// run the test function
1261+
update_noc_normalization_factors(costs);
1262+
1263+
// verify the congestion normalization factor
1264+
// this should not be infinite
1265+
REQUIRE(costs.noc_congestion_cost_norm == 1.e3);
1266+
}
1267+
SECTION("Test case where the congestion cost is lower than the smallest expected value") {
1268+
costs.noc_aggregate_bandwidth_cost = 1.;
1269+
costs.noc_latency_cost = 1.;
1270+
costs.noc_congestion_cost = 999.e-15;
1271+
1272+
// run the test function
1273+
update_noc_normalization_factors(costs);
1274+
1275+
// verify the congestion normalization factor
1276+
// this should not be infinite
1277+
REQUIRE(costs.noc_congestion_cost_norm == 1.e3);
1278+
}
1279+
SECTION("Test case where the congestion cost is an expected value") {
1280+
costs.noc_aggregate_bandwidth_cost = 1.;
1281+
costs.noc_latency_cost = 1.;
1282+
costs.noc_congestion_cost = 1.e2;
1283+
1284+
// run the test function
1285+
update_noc_normalization_factors(costs);
1286+
1287+
// verify the congestion normalization factor
1288+
REQUIRE(costs.noc_congestion_cost_norm == 1.e-2);
1289+
}
12501290
}
12511291
TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
12521292
// setup random number generation
@@ -1284,10 +1324,12 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
12841324
t_noc_opts noc_opts;
12851325
noc_opts.noc_latency_constraints_weighting = dist_3(double_engine);
12861326
noc_opts.noc_latency_weighting = dist_3(double_engine);
1327+
noc_opts.noc_congestion_weighting = dist_3(double_engine);
12871328

12881329
// setting the NoC parameters
12891330
noc_ctx.noc_model.set_noc_link_latency(1);
12901331
noc_ctx.noc_model.set_noc_router_latency(1);
1332+
noc_ctx.noc_model.set_noc_link_bandwidth(1);
12911333

12921334
// keeps track of which hard router each cluster block is placed
12931335
vtr::vector<ClusterBlockId, NocRouterId> router_where_cluster_is_placed;
@@ -1375,7 +1417,9 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
13751417
int traffic_flow_priority = dist_1(rand_num_gen);
13761418

13771419
// create and add the traffic flow
1378-
noc_ctx.noc_traffic_flows_storage.create_noc_traffic_flow(source_traffic_flow_name, sink_traffic_flow_name, source_router_for_traffic_flow, sink_router_for_traffic_flow, traffic_flow_bandwidth_usage, traffic_flow_latency_constraint, traffic_flow_priority);
1420+
noc_ctx.noc_traffic_flows_storage.create_noc_traffic_flow(source_traffic_flow_name, sink_traffic_flow_name,
1421+
source_router_for_traffic_flow, sink_router_for_traffic_flow,
1422+
traffic_flow_bandwidth_usage, traffic_flow_latency_constraint, traffic_flow_priority);
13791423

13801424
number_of_created_traffic_flows++;
13811425

@@ -1392,7 +1436,7 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
13921436
noc_ctx.noc_flows_router = std::make_unique<XYRouting>();
13931437

13941438
// create a local routing algorithm for the unit test
1395-
NocRouting* routing_algorithm = new XYRouting();
1439+
auto routing_algorithm = std::make_unique<XYRouting>();
13961440

13971441
// store the traffic flow routes found
13981442
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> golden_traffic_flow_routes;
@@ -1410,6 +1454,8 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
14101454
routing_algorithm->route_flow((NocRouterId)source_hard_router_id, (NocRouterId)sink_hard_routed_id, golden_traffic_flow_routes[(NocTrafficFlowId)traffic_flow_number], noc_ctx.noc_model);
14111455
}
14121456

1457+
const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> initial_golden_traffic_flow_routes = golden_traffic_flow_routes;
1458+
14131459
// assume this works
14141460
// this is needed to set up the global noc packet router and also global datastructures
14151461
initial_noc_routing();
@@ -1567,9 +1613,15 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
15671613
const NocLink& current_link = noc_ctx.noc_model.get_single_noc_link(current_link_id);
15681614

15691615
REQUIRE(golden_link_bandwidths[current_link_id] == current_link.get_bandwidth_usage());
1616+
15701617
}
15711618

1572-
delete routing_algorithm;
1619+
for (int traffic_flow_number = 0; traffic_flow_number < NUM_OF_TRAFFIC_FLOWS_NOC_PLACE_UTILS_TEST; traffic_flow_number++) {
1620+
auto traffic_flow_id = (NocTrafficFlowId)traffic_flow_number;
1621+
const auto& traffic_flow_route = noc_ctx.noc_traffic_flows_storage.get_traffic_flow_route(traffic_flow_id);
1622+
const auto& golden_traffic_flow_route = initial_golden_traffic_flow_routes[traffic_flow_id];
1623+
REQUIRE(traffic_flow_route == golden_traffic_flow_route);
1624+
}
15731625
}
15741626
TEST_CASE("test_check_noc_placement_costs", "[noc_place_utils]") {
15751627
// setup random number generation

0 commit comments

Comments
 (0)