@@ -1195,6 +1195,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
1195
1195
SECTION (" Test case where the bandwidth cost is 0" ) {
1196
1196
costs.noc_aggregate_bandwidth_cost = 0 .;
1197
1197
costs.noc_latency_cost = 1 .;
1198
+ costs.noc_congestion_cost = 1 .;
1198
1199
1199
1200
// run the test function
1200
1201
update_noc_normalization_factors (costs);
@@ -1206,6 +1207,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
1206
1207
SECTION (" Test case where the latency cost is 0" ) {
1207
1208
costs.noc_aggregate_bandwidth_cost = 1 .;
1208
1209
costs.noc_latency_cost = 0 .;
1210
+ costs.noc_congestion_cost = 1 .;
1209
1211
1210
1212
// run the test function
1211
1213
update_noc_normalization_factors (costs);
@@ -1217,6 +1219,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
1217
1219
SECTION (" Test case where the bandwidth cost is an expected value" ) {
1218
1220
costs.noc_aggregate_bandwidth_cost = 1 .e9 ;
1219
1221
costs.noc_latency_cost = 0 .;
1222
+ costs.noc_congestion_cost = 1 .;
1220
1223
1221
1224
// run the test function
1222
1225
update_noc_normalization_factors (costs);
@@ -1228,6 +1231,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
1228
1231
SECTION (" Test case where the latency cost is an expected value" ) {
1229
1232
costs.noc_aggregate_bandwidth_cost = 1 .;
1230
1233
costs.noc_latency_cost = 50 .e -12 ;
1234
+ costs.noc_congestion_cost = 1 .;
1231
1235
1232
1236
// run the test function
1233
1237
update_noc_normalization_factors (costs);
@@ -1239,6 +1243,7 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
1239
1243
SECTION (" Test case where the latency cost is lower than the smallest expected value" ) {
1240
1244
costs.noc_aggregate_bandwidth_cost = 1 .;
1241
1245
costs.noc_latency_cost = 999 .e -15 ;
1246
+ costs.noc_congestion_cost = 1 .;
1242
1247
1243
1248
// run the test function
1244
1249
update_noc_normalization_factors (costs);
@@ -1247,6 +1252,41 @@ TEST_CASE("test_update_noc_normalization_factors", "[noc_place_utils]") {
1247
1252
// this should not be trimmed
1248
1253
REQUIRE (costs.noc_latency_cost_norm == 1 .e12 );
1249
1254
}
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
+ }
1250
1290
}
1251
1291
TEST_CASE (" test_revert_noc_traffic_flow_routes" , " [noc_place_utils]" ) {
1252
1292
// setup random number generation
@@ -1284,10 +1324,12 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
1284
1324
t_noc_opts noc_opts;
1285
1325
noc_opts.noc_latency_constraints_weighting = dist_3 (double_engine);
1286
1326
noc_opts.noc_latency_weighting = dist_3 (double_engine);
1327
+ noc_opts.noc_congestion_weighting = dist_3 (double_engine);
1287
1328
1288
1329
// setting the NoC parameters
1289
1330
noc_ctx.noc_model .set_noc_link_latency (1 );
1290
1331
noc_ctx.noc_model .set_noc_router_latency (1 );
1332
+ noc_ctx.noc_model .set_noc_link_bandwidth (1 );
1291
1333
1292
1334
// keeps track of which hard router each cluster block is placed
1293
1335
vtr::vector<ClusterBlockId, NocRouterId> router_where_cluster_is_placed;
@@ -1375,7 +1417,9 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
1375
1417
int traffic_flow_priority = dist_1 (rand_num_gen);
1376
1418
1377
1419
// 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);
1379
1423
1380
1424
number_of_created_traffic_flows++;
1381
1425
@@ -1392,7 +1436,7 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
1392
1436
noc_ctx.noc_flows_router = std::make_unique<XYRouting>();
1393
1437
1394
1438
// create a local routing algorithm for the unit test
1395
- NocRouting* routing_algorithm = new XYRouting ();
1439
+ auto routing_algorithm = std::make_unique< XYRouting> ();
1396
1440
1397
1441
// store the traffic flow routes found
1398
1442
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]") {
1410
1454
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 );
1411
1455
}
1412
1456
1457
+ const vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> initial_golden_traffic_flow_routes = golden_traffic_flow_routes;
1458
+
1413
1459
// assume this works
1414
1460
// this is needed to set up the global noc packet router and also global datastructures
1415
1461
initial_noc_routing ();
@@ -1567,9 +1613,15 @@ TEST_CASE("test_revert_noc_traffic_flow_routes", "[noc_place_utils]") {
1567
1613
const NocLink& current_link = noc_ctx.noc_model .get_single_noc_link (current_link_id);
1568
1614
1569
1615
REQUIRE (golden_link_bandwidths[current_link_id] == current_link.get_bandwidth_usage ());
1616
+
1570
1617
}
1571
1618
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
+ }
1573
1625
}
1574
1626
TEST_CASE (" test_check_noc_placement_costs" , " [noc_place_utils]" ) {
1575
1627
// setup random number generation
0 commit comments