Skip to content

Commit e697f64

Browse files
noc_sat_routing_num_workers and noc_sat_routing_log_search_progress command line options
1 parent 87aed01 commit e697f64

File tree

8 files changed

+86
-67
lines changed

8 files changed

+86
-67
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static void SetupNocOpts(const t_options& Options, t_noc_opts* NocOpts) {
743743
NocOpts->noc_sat_routing_bandwidth_resolution = Options.noc_sat_routing_bandwidth_resolution;
744744
NocOpts->noc_sat_routing_latency_overrun_weighting = Options.noc_sat_routing_latency_overrun_weighting_factor;
745745
NocOpts->noc_sat_routing_congestion_weighting = Options.noc_sat_routing_congestion_weighting_factor;
746+
NocOpts->noc_sat_routing_num_workers = Options.noc_sat_routing_num_workers;
747+
NocOpts->noc_sat_routing_log_search_progress = Options.noc_sat_routing_log_search_progress;
746748
NocOpts->noc_placement_file_name = Options.noc_placement_file_name;
747749
}
748750

vpr/src/base/ShowSetup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ static void ShowNocOpts(const t_noc_opts& NocOpts) {
803803
VTR_LOG("NocOpts.noc_sat_routing_bandwidth_resolution: %d\n", NocOpts.noc_sat_routing_bandwidth_resolution);
804804
VTR_LOG("NocOpts.noc_sat_routing_latency_overrun_weighting: %d\n", NocOpts.noc_sat_routing_latency_overrun_weighting);
805805
VTR_LOG("NocOpts.noc_sat_routing_congestion_weighting: %d\n", NocOpts.noc_sat_routing_congestion_weighting);
806+
VTR_LOG("NocOpts.noc_sat_routing_num_workers: %d\n", NocOpts.noc_sat_routing_num_workers);
806807
VTR_LOG("NocOpts.noc_routing_algorithm: %s\n", NocOpts.noc_placement_file_name.c_str());
807808
VTR_LOG("\n");
808809
}

vpr/src/base/read_options.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,19 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
28872887
.default_value("16384")
28882888
.show_in(argparse::ShowIn::HELP_ONLY);
28892889

2890+
noc_grp.add_argument<int>(args.noc_sat_routing_num_workers, "--noc_sat_routing_num_workers")
2891+
.help(
2892+
"The maximum number of parallel threads that the SAT solver can use to explore the solution space.\n"
2893+
"When set to 0, the number of parallel workers is set automatically to maximize parallelism.")
2894+
.default_value("0")
2895+
.show_in(argparse::ShowIn::HELP_ONLY);
2896+
2897+
noc_grp.add_argument<bool>(args.noc_sat_routing_log_search_progress, "--noc_sat_routing_log_search_progress")
2898+
.help(
2899+
"Print the detailed log of the SAT solver's search progress.")
2900+
.default_value("off")
2901+
.show_in(argparse::ShowIn::HELP_ONLY);
2902+
28902903
noc_grp.add_argument<std::string>(args.noc_placement_file_name, "--noc_placement_file_name")
28912904
.help(
28922905
"Name of the output file that contains the NoC placement information."

vpr/src/base/read_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ struct t_options {
160160
argparse::ArgValue<int> noc_sat_routing_bandwidth_resolution;
161161
argparse::ArgValue<int> noc_sat_routing_latency_overrun_weighting_factor;
162162
argparse::ArgValue<int> noc_sat_routing_congestion_weighting_factor;
163+
argparse::ArgValue<int> noc_sat_routing_num_workers;
164+
argparse::ArgValue<bool> noc_sat_routing_log_search_progress;
163165
argparse::ArgValue<std::string> noc_placement_file_name;
164166

165167
/* Timing-driven placement options only */

vpr/src/base/vpr_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,8 @@ struct t_noc_opts {
15031503
int noc_sat_routing_bandwidth_resolution; ///<the resolution by which traffic flow and link bandwidths are converted to integers in SAT routing algorithm
15041504
int noc_sat_routing_latency_overrun_weighting; ///<controls the importance of reducing traffic flow latency overrun in SAT routing [0-inf)
15051505
int noc_sat_routing_congestion_weighting; ///<controls the importance of reducing the number of congested NoC links in SAT routing [0-inf)
1506+
int noc_sat_routing_num_workers; ///<the number of parallel worker threads that the SAT solver can use to explore the solution space
1507+
bool noc_sat_routing_log_search_progress; ///<indicates whether the detailed log of the SAT solver's search progress in printed
15061508
std::string noc_placement_file_name; ///<is the name of the output file that contains the NoC placement information
15071509
};
15081510

vpr/src/noc/sat_routing.cpp

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,27 @@ static vtr::vector<NocTrafficFlowId, int> quantize_traffic_flow_bandwidths(int b
231231
return rescaled_traffic_flow_bandwidths;
232232
}
233233

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+
//}
255255

256256
static void create_congested_link_vars(vtr::vector<NocLinkId , orsat::BoolVar>& congested_link_vars,
257257
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,
346346
}
347347
}
348348

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+
//}
382382

383383
static std::vector<NocLinkId> sort_noc_links_in_chain_order(const std::vector<NocLinkId>& links) {
384384
std::vector<NocLinkId> route;
@@ -879,9 +879,7 @@ static orsat::LinearExpr create_objective(orsat::CpModelBuilder& cp_model,
879879

880880

881881
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,
885883
int seed) {
886884
vtr::ScopedStartFinishTimer timer("NoC SAT Routing");
887885

@@ -910,20 +908,24 @@ vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> noc_sat_route(bool minimiz
910908

911909
forbid_illegal_turns(flow_link_vars, cp_model);
912910

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);
914912

915913
add_continuity_constraints(flow_link_vars, cp_model);
916914

917915
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,
919919
minimize_aggregate_bandwidth);
920920

921921
cp_model.Minimize(objective);
922922

923923
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+
}
925927
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);
927929

928930
orsat::Model model;
929931
model.Add(NewSatParameters(sat_params));
@@ -936,5 +938,6 @@ vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> noc_sat_route(bool minimiz
936938
return routes;
937939
}
938940

941+
// when no feasible solution was found, return an empty vector
939942
return {};
940943
}

vpr/src/noc/sat_routing.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
* @return The generated routes for all traffic flows.
2626
*/
2727
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> noc_sat_route(bool minimize_aggregate_bandwidth,
28-
int bandwidth_resolution,
29-
int latency_overrun_weight,
30-
int congestion_weight,
28+
const t_noc_opts& noc_opts,
3129
int seed);
3230

3331
//void noc_sat_place_and_route(vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>>& traffic_flow_routes,

vpr/src/place/place.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,9 +1204,7 @@ void try_place(const Netlist<>& net_list,
12041204
if (costs.noc_cost_terms.congestion > 0.0) {
12051205
VTR_LOG("NoC routing configuration is congested. Invoking the SAT NoC router.\n");
12061206
auto traffic_flow_routes = noc_sat_route(true,
1207-
noc_opts.noc_sat_routing_bandwidth_resolution,
1208-
noc_opts.noc_sat_routing_latency_overrun_weighting,
1209-
noc_opts.noc_sat_routing_congestion_weighting,
1207+
noc_opts,
12101208
placer_opts.seed);
12111209

12121210
if (!traffic_flow_routes.empty()) {

0 commit comments

Comments
 (0)