@@ -231,27 +231,27 @@ static vtr::vector<NocTrafficFlowId, int> quantize_traffic_flow_bandwidths(int b
231
231
return rescaled_traffic_flow_bandwidths;
232
232
}
233
233
234
- static void add_congestion_constraints (t_flow_link_var_map& flow_link_vars,
235
- orsat::CpModelBuilder& cp_model,
236
- int bandwidth_resolution) {
237
- const auto & noc_ctx = g_vpr_ctx.noc ();
238
- const auto & traffic_flow_storage = noc_ctx.noc_traffic_flows_storage ;
239
-
240
- vtr::vector<NocTrafficFlowId, int > rescaled_traffic_flow_bandwidths = quantize_traffic_flow_bandwidths (bandwidth_resolution);
241
-
242
- // add NoC link congestion constraints
243
- for (const auto & noc_link : noc_ctx.noc_model .get_noc_links ()) {
244
- const NocLinkId noc_link_id = noc_link.get_link_id ();
245
- orsat::LinearExpr lhs;
246
-
247
- for (auto traffic_flow_id : traffic_flow_storage.get_all_traffic_flow_id ()) {
248
- orsat::BoolVar binary_var = flow_link_vars[{traffic_flow_id, noc_link_id}];
249
- lhs += orsat::LinearExpr::Term (binary_var, rescaled_traffic_flow_bandwidths[traffic_flow_id]);
250
- }
251
-
252
- cp_model.AddLessOrEqual (lhs, bandwidth_resolution);
253
- }
254
- }
234
+ // static void add_congestion_constraints(t_flow_link_var_map& flow_link_vars,
235
+ // orsat::CpModelBuilder& cp_model,
236
+ // int bandwidth_resolution) {
237
+ // const auto& noc_ctx = g_vpr_ctx.noc();
238
+ // const auto& traffic_flow_storage = noc_ctx.noc_traffic_flows_storage;
239
+ //
240
+ // vtr::vector<NocTrafficFlowId, int> rescaled_traffic_flow_bandwidths = quantize_traffic_flow_bandwidths(bandwidth_resolution);
241
+ //
242
+ // // add NoC link congestion constraints
243
+ // for (const auto& noc_link : noc_ctx.noc_model.get_noc_links()) {
244
+ // const NocLinkId noc_link_id = noc_link.get_link_id();
245
+ // orsat::LinearExpr lhs;
246
+ //
247
+ // for (auto traffic_flow_id : traffic_flow_storage.get_all_traffic_flow_id()) {
248
+ // orsat::BoolVar binary_var = flow_link_vars[{traffic_flow_id, noc_link_id}];
249
+ // lhs += orsat::LinearExpr::Term(binary_var, rescaled_traffic_flow_bandwidths[traffic_flow_id]);
250
+ // }
251
+ //
252
+ // cp_model.AddLessOrEqual(lhs, bandwidth_resolution);
253
+ // }
254
+ // }
255
255
256
256
static void create_congested_link_vars (vtr::vector<NocLinkId , orsat::BoolVar>& congested_link_vars,
257
257
t_flow_link_var_map& flow_link_vars,
@@ -346,39 +346,39 @@ static void add_continuity_constraints(t_flow_link_var_map& flow_link_vars,
346
346
}
347
347
}
348
348
349
- static void group_noc_links_based_on_direction (std::vector<NocLinkId>& up,
350
- std::vector<NocLinkId>& down,
351
- std::vector<NocLinkId>& right,
352
- std::vector<NocLinkId>& left) {
353
- const auto & noc_ctx = g_vpr_ctx.noc ();
354
- const auto & noc_model = noc_ctx.noc_model ;
355
-
356
- for (const auto & noc_link : noc_model.get_noc_links ()) {
357
- const NocLinkId noc_link_id = noc_link.get_link_id ();
358
- const NocRouterId src_noc_router_id = noc_link.get_source_router ();
359
- const NocRouterId dst_noc_router_id = noc_link.get_sink_router ();
360
- const NocRouter& src_noc_router = noc_model.get_single_noc_router (src_noc_router_id);
361
- const NocRouter& dst_noc_router = noc_model.get_single_noc_router (dst_noc_router_id);
362
- auto src_loc = src_noc_router.get_router_physical_location ();
363
- auto dst_loc = dst_noc_router.get_router_physical_location ();
364
-
365
- VTR_ASSERT (src_loc.x == dst_loc.x || src_loc.y == dst_loc.y );
366
-
367
- if (src_loc.x == dst_loc.x ) { // vertical link
368
- if (dst_loc.y > src_loc.y ) {
369
- up.push_back (noc_link_id);
370
- } else {
371
- down.push_back (noc_link_id);
372
- }
373
- } else { // horizontal link
374
- if (dst_loc.x > src_loc.x ) {
375
- right.push_back (noc_link_id);
376
- } else {
377
- left.push_back (noc_link_id);
378
- }
379
- }
380
- }
381
- }
349
+ // static void group_noc_links_based_on_direction(std::vector<NocLinkId>& up,
350
+ // std::vector<NocLinkId>& down,
351
+ // std::vector<NocLinkId>& right,
352
+ // std::vector<NocLinkId>& left) {
353
+ // const auto& noc_ctx = g_vpr_ctx.noc();
354
+ // const auto& noc_model = noc_ctx.noc_model;
355
+ //
356
+ // for (const auto& noc_link : noc_model.get_noc_links()) {
357
+ // const NocLinkId noc_link_id = noc_link.get_link_id();
358
+ // const NocRouterId src_noc_router_id = noc_link.get_source_router();
359
+ // const NocRouterId dst_noc_router_id = noc_link.get_sink_router();
360
+ // const NocRouter& src_noc_router = noc_model.get_single_noc_router(src_noc_router_id);
361
+ // const NocRouter& dst_noc_router = noc_model.get_single_noc_router(dst_noc_router_id);
362
+ // auto src_loc = src_noc_router.get_router_physical_location();
363
+ // auto dst_loc = dst_noc_router.get_router_physical_location();
364
+ //
365
+ // VTR_ASSERT(src_loc.x == dst_loc.x || src_loc.y == dst_loc.y);
366
+ //
367
+ // if (src_loc.x == dst_loc.x) { // vertical link
368
+ // if (dst_loc.y > src_loc.y) {
369
+ // up.push_back(noc_link_id);
370
+ // } else {
371
+ // down.push_back(noc_link_id);
372
+ // }
373
+ // } else { // horizontal link
374
+ // if (dst_loc.x > src_loc.x) {
375
+ // right.push_back(noc_link_id);
376
+ // } else {
377
+ // left.push_back(noc_link_id);
378
+ // }
379
+ // }
380
+ // }
381
+ // }
382
382
383
383
static std::vector<NocLinkId> sort_noc_links_in_chain_order (const std::vector<NocLinkId>& links) {
384
384
std::vector<NocLinkId> route;
@@ -879,9 +879,7 @@ static orsat::LinearExpr create_objective(orsat::CpModelBuilder& cp_model,
879
879
880
880
881
881
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> noc_sat_route (bool minimize_aggregate_bandwidth,
882
- int bandwidth_resolution,
883
- int latency_overrun_weight,
884
- int congestion_weight,
882
+ const t_noc_opts& noc_opts,
885
883
int seed) {
886
884
vtr::ScopedStartFinishTimer timer (" NoC SAT Routing" );
887
885
@@ -910,20 +908,24 @@ vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> noc_sat_route(bool minimiz
910
908
911
909
forbid_illegal_turns (flow_link_vars, cp_model);
912
910
913
- create_congested_link_vars (link_congested_vars, flow_link_vars, cp_model, bandwidth_resolution );
911
+ create_congested_link_vars (link_congested_vars, flow_link_vars, cp_model, noc_opts. noc_sat_routing_bandwidth_resolution );
914
912
915
913
add_continuity_constraints (flow_link_vars, cp_model);
916
914
917
915
auto objective = create_objective (cp_model, flow_link_vars, latency_overrun_vars, link_congested_vars,
918
- bandwidth_resolution, latency_overrun_weight, congestion_weight,
916
+ noc_opts.noc_sat_routing_bandwidth_resolution ,
917
+ noc_opts.noc_sat_routing_latency_overrun_weighting ,
918
+ noc_opts.noc_sat_routing_congestion_weighting ,
919
919
minimize_aggregate_bandwidth);
920
920
921
921
cp_model.Minimize (objective);
922
922
923
923
orsat::SatParameters sat_params;
924
- // sat_params.set_num_workers(1);
924
+ if (noc_opts.noc_sat_routing_num_workers > 0 ) {
925
+ sat_params.set_num_workers (noc_opts.noc_sat_routing_num_workers );
926
+ }
925
927
sat_params.set_random_seed (seed);
926
- sat_params.set_log_search_progress (true );
928
+ sat_params.set_log_search_progress (noc_opts. noc_sat_routing_log_search_progress );
927
929
928
930
orsat::Model model;
929
931
model.Add (NewSatParameters (sat_params));
@@ -936,5 +938,6 @@ vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> noc_sat_route(bool minimiz
936
938
return routes;
937
939
}
938
940
941
+ // when no feasible solution was found, return an empty vector
939
942
return {};
940
943
}
0 commit comments