Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fd2797f

Browse files
committedMar 3, 2025··
[Router] Upstream Fine-Grained Parallel Router (FPT'24)
Upstreamed the fine-grained parallel router implementation into the VTR master. The original branch is https://github.com/verilog-to-routing/vtr-verilog-to-routing/tree/mq-parallel-router. Modified the MultiQueue (SPAA'24) implementation and integrated it into the VTR codebase.
1 parent ef945a7 commit fd2797f

27 files changed

+2234
-71
lines changed
 

‎utils/route_diag/src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ static void do_one_route(const Netlist<>& net_list,
9797
segment_inf,
9898
is_flat);
9999

100-
ConnectionRouter<FourAryHeap> router(
100+
// TODO: adding tests for parallel connection router
101+
SerialConnectionRouter<FourAryHeap> router(
101102
device_ctx.grid,
102103
*router_lookahead,
103104
device_ctx.rr_graph.rr_nodes(),

‎vpr/src/base/SetupVPR.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@ static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts)
433433
RouterOpts->astar_fac = Options.astar_fac;
434434
RouterOpts->astar_offset = Options.astar_offset;
435435
RouterOpts->router_profiler_astar_fac = Options.router_profiler_astar_fac;
436+
RouterOpts->enable_parallel_connection_router = Options.enable_parallel_connection_router;
437+
RouterOpts->post_target_prune_fac = Options.post_target_prune_fac;
438+
RouterOpts->post_target_prune_offset = Options.post_target_prune_offset;
439+
RouterOpts->multi_queue_num_threads = Options.multi_queue_num_threads;
440+
RouterOpts->multi_queue_num_queues = Options.multi_queue_num_queues;
441+
RouterOpts->multi_queue_direct_draining = Options.multi_queue_direct_draining;
436442
RouterOpts->bb_factor = Options.bb_factor;
437443
RouterOpts->criticality_exp = Options.criticality_exp;
438444
RouterOpts->max_criticality = Options.max_criticality;

‎vpr/src/base/ShowSetup.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
376376
VTR_LOG("RouterOpts.astar_fac: %f\n", RouterOpts.astar_fac);
377377
VTR_LOG("RouterOpts.astar_offset: %f\n", RouterOpts.astar_offset);
378378
VTR_LOG("RouterOpts.router_profiler_astar_fac: %f\n", RouterOpts.router_profiler_astar_fac);
379+
VTR_LOG("RouterOpts.enable_parallel_connection_router: %s\n", RouterOpts.enable_parallel_connection_router ? "true" : "false");
380+
VTR_LOG("RouterOpts.post_target_prune_fac: %f\n", RouterOpts.post_target_prune_fac);
381+
VTR_LOG("RouterOpts.post_target_prune_offset: %f\n", RouterOpts.post_target_prune_offset);
382+
VTR_LOG("RouterOpts.multi_queue_num_threads: %d\n", RouterOpts.multi_queue_num_threads);
383+
VTR_LOG("RouterOpts.multi_queue_num_queues: %d\n", RouterOpts.multi_queue_num_queues);
384+
VTR_LOG("RouterOpts.multi_queue_direct_draining: %s\n", RouterOpts.multi_queue_direct_draining ? "true" : "false");
379385
VTR_LOG("RouterOpts.criticality_exp: %f\n", RouterOpts.criticality_exp);
380386
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
381387
VTR_LOG("RouterOpts.init_wirelength_abort_threshold: %f\n", RouterOpts.init_wirelength_abort_threshold);

‎vpr/src/base/read_options.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,36 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
25492549
.default_value("1.2")
25502550
.show_in(argparse::ShowIn::HELP_ONLY);
25512551

2552+
route_timing_grp.add_argument<bool, ParseOnOff>(args.enable_parallel_connection_router, "--enable_parallel_connection_router")
2553+
.help("TODO")
2554+
.default_value("off")
2555+
.show_in(argparse::ShowIn::HELP_ONLY);
2556+
2557+
route_timing_grp.add_argument(args.post_target_prune_fac, "--post_target_prune_fac")
2558+
.help("TODO")
2559+
.default_value("1.2")
2560+
.show_in(argparse::ShowIn::HELP_ONLY);
2561+
2562+
route_timing_grp.add_argument(args.post_target_prune_offset, "--post_target_prune_offset")
2563+
.help("TODO")
2564+
.default_value("0.0")
2565+
.show_in(argparse::ShowIn::HELP_ONLY);
2566+
2567+
route_timing_grp.add_argument<int>(args.multi_queue_num_threads, "--multi_queue_num_threads")
2568+
.help("TODO")
2569+
.default_value("1")
2570+
.show_in(argparse::ShowIn::HELP_ONLY);
2571+
2572+
route_timing_grp.add_argument<int>(args.multi_queue_num_queues, "--multi_queue_num_queues")
2573+
.help("TODO")
2574+
.default_value("2")
2575+
.show_in(argparse::ShowIn::HELP_ONLY);
2576+
2577+
route_timing_grp.add_argument<bool, ParseOnOff>(args.multi_queue_direct_draining, "--multi_queue_direct_draining")
2578+
.help("TODO")
2579+
.default_value("off")
2580+
.show_in(argparse::ShowIn::HELP_ONLY);
2581+
25522582
route_timing_grp.add_argument(args.max_criticality, "--max_criticality")
25532583
.help(
25542584
"Sets the maximum fraction of routing cost derived from delay (vs routability) for any net."

‎vpr/src/base/read_options.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ struct t_options {
226226
argparse::ArgValue<float> astar_fac;
227227
argparse::ArgValue<float> astar_offset;
228228
argparse::ArgValue<float> router_profiler_astar_fac;
229+
argparse::ArgValue<bool> enable_parallel_connection_router;
230+
argparse::ArgValue<float> post_target_prune_fac;
231+
argparse::ArgValue<float> post_target_prune_offset;
232+
argparse::ArgValue<int> multi_queue_num_threads;
233+
argparse::ArgValue<int> multi_queue_num_queues;
234+
argparse::ArgValue<bool> multi_queue_direct_draining;
229235
argparse::ArgValue<float> max_criticality;
230236
argparse::ArgValue<float> criticality_exp;
231237
argparse::ArgValue<float> router_init_wirelength_abort_threshold;

‎vpr/src/base/vpr_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,12 @@ struct t_router_opts {
11911191
float astar_fac;
11921192
float astar_offset;
11931193
float router_profiler_astar_fac;
1194+
bool enable_parallel_connection_router;
1195+
float post_target_prune_fac;
1196+
float post_target_prune_offset;
1197+
int multi_queue_num_threads;
1198+
int multi_queue_num_queues;
1199+
bool multi_queue_direct_draining;
11941200
float max_criticality;
11951201
float criticality_exp;
11961202
float init_wirelength_abort_threshold;

‎vpr/src/route/DecompNetlistRouter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ class DecompNetlistRouter : public NetlistRouter {
8585
/** A single task to route nets inside a PartitionTree node and add tasks for its child nodes to task group \p g. */
8686
void route_partition_tree_node(tbb::task_group& g, PartitionTreeNode& node);
8787

88-
ConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) {
88+
SerialConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) {
8989
auto& device_ctx = g_vpr_ctx.device();
9090
auto& route_ctx = g_vpr_ctx.mutable_routing();
9191

92-
return ConnectionRouter<HeapType>(
92+
return SerialConnectionRouter<HeapType>(
9393
device_ctx.grid,
9494
*router_lookahead,
9595
device_ctx.rr_graph.rr_nodes(),
@@ -101,8 +101,8 @@ class DecompNetlistRouter : public NetlistRouter {
101101
}
102102

103103
/* Context fields. Most of them will be forwarded to route_net (see route_net.tpp) */
104-
/** Per-thread storage for ConnectionRouters. */
105-
tbb::enumerable_thread_specific<ConnectionRouter<HeapType>> _routers_th;
104+
/** Per-thread storage for SerialConnectionRouter. */
105+
tbb::enumerable_thread_specific<SerialConnectionRouter<HeapType>> _routers_th;
106106
const Netlist<>& _net_list;
107107
const t_router_opts& _router_opts;
108108
CBRR& _connections_inf;

‎vpr/src/route/DecompNetlistRouter.tpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ void DecompNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group& g
204204
route_ctx.route_bb[net_id],
205205
false);
206206
if (!flags.success && !flags.retry_with_full_bb) {
207-
/* Disconnected RRG and ConnectionRouter doesn't think growing the BB will work */
207+
/* Disconnected RRG and SerialConnectionRouter doesn't think growing the BB will work */
208208
_results_th.local().is_routable = false;
209209
return;
210210
}
211211
if (flags.retry_with_full_bb) {
212-
/* ConnectionRouter thinks we should grow the BB. Do that and leave this net unrouted for now */
212+
/*SerialConnectionRouter thinks we should grow the BB. Do that and leave this net unrouted for now */
213213
route_ctx.route_bb[net_id] = full_device_bb();
214214
_results_th.local().bb_updated_nets.push_back(net_id);
215215
/* Disable decomposition for nets like this: they're already problematic */

‎vpr/src/route/ParallelNetlistRouter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <tbb/task_group.h>
1616

1717
/** Parallel impl for NetlistRouter.
18-
* Holds enough context members to glue together ConnectionRouter and net routing functions,
18+
* Holds enough context members to glue together SerialConnectionRouter and net routing functions,
1919
* such as \ref route_net. Keeps the members in thread-local storage where needed,
2020
* i.e. ConnectionRouters and RouteIterResults-es.
2121
* See \ref route_net. */
@@ -62,11 +62,11 @@ class ParallelNetlistRouter : public NetlistRouter {
6262
/** A single task to route nets inside a PartitionTree node and add tasks for its child nodes to task group \p g. */
6363
void route_partition_tree_node(tbb::task_group& g, PartitionTreeNode& node);
6464

65-
ConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) {
65+
SerialConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) {
6666
auto& device_ctx = g_vpr_ctx.device();
6767
auto& route_ctx = g_vpr_ctx.mutable_routing();
6868

69-
return ConnectionRouter<HeapType>(
69+
return SerialConnectionRouter<HeapType>(
7070
device_ctx.grid,
7171
*router_lookahead,
7272
device_ctx.rr_graph.rr_nodes(),
@@ -79,7 +79,7 @@ class ParallelNetlistRouter : public NetlistRouter {
7979

8080
/* Context fields. Most of them will be forwarded to route_net (see route_net.tpp) */
8181
/** Per-thread storage for ConnectionRouters. */
82-
tbb::enumerable_thread_specific<ConnectionRouter<HeapType>> _routers_th;
82+
tbb::enumerable_thread_specific<SerialConnectionRouter<HeapType>> _routers_th;
8383
const Netlist<>& _net_list;
8484
const t_router_opts& _router_opts;
8585
CBRR& _connections_inf;

‎vpr/src/route/ParallelNetlistRouter.tpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ void ParallelNetlistRouter<HeapType>::route_partition_tree_node(tbb::task_group&
7979
route_ctx.route_bb[net_id]);
8080

8181
if (!flags.success && !flags.retry_with_full_bb) {
82-
/* Disconnected RRG and ConnectionRouter doesn't think growing the BB will work */
82+
/* Disconnected RRG and SerialConnectionRouter doesn't think growing the BB will work */
8383
_results_th.local().is_routable = false;
8484
return;
8585
}
8686
if (flags.retry_with_full_bb) {
87-
/* ConnectionRouter thinks we should grow the BB. Do that and leave this net unrouted for now */
87+
/* SerialConnectionRouter thinks we should grow the BB. Do that and leave this net unrouted for now */
8888
route_ctx.route_bb[net_id] = full_device_bb();
8989
_results_th.local().bb_updated_nets.push_back(net_id);
9090
continue;

‎vpr/src/route/SerialNetlistRouter.h

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/** @file Serial case for \ref NetlistRouter: just loop through nets */
44

55
#include "netlist_routers.h"
6+
#include "serial_connection_router.h"
7+
#include "parallel_connection_router.h"
68

79
template<typename HeapType>
810
class SerialNetlistRouter : public NetlistRouter {
@@ -20,7 +22,7 @@ class SerialNetlistRouter : public NetlistRouter {
2022
const RoutingPredictor& routing_predictor,
2123
const vtr::vector<ParentNetId, std::vector<std::unordered_map<RRNodeId, int>>>& choking_spots,
2224
bool is_flat)
23-
: _router(_make_router(router_lookahead, is_flat))
25+
: _router(_make_router(router_lookahead, router_opts, is_flat))
2426
, _net_list(net_list)
2527
, _router_opts(router_opts)
2628
, _connections_inf(connections_inf)
@@ -32,30 +34,51 @@ class SerialNetlistRouter : public NetlistRouter {
3234
, _routing_predictor(routing_predictor)
3335
, _choking_spots(choking_spots)
3436
, _is_flat(is_flat) {}
35-
~SerialNetlistRouter() {}
37+
~SerialNetlistRouter() {
38+
delete _router;
39+
}
3640

3741
RouteIterResults route_netlist(int itry, float pres_fac, float worst_neg_slack);
3842
void handle_bb_updated_nets(const std::vector<ParentNetId>& nets);
3943
void set_rcv_enabled(bool x);
4044
void set_timing_info(std::shared_ptr<SetupHoldTimingInfo> timing_info);
4145

4246
private:
43-
ConnectionRouter<HeapType> _make_router(const RouterLookahead* router_lookahead, bool is_flat) {
47+
ConnectionRouterInterface *_make_router(const RouterLookahead* router_lookahead,
48+
const t_router_opts& router_opts,
49+
bool is_flat) {
4450
auto& device_ctx = g_vpr_ctx.device();
4551
auto& route_ctx = g_vpr_ctx.mutable_routing();
4652

47-
return ConnectionRouter<HeapType>(
48-
device_ctx.grid,
49-
*router_lookahead,
50-
device_ctx.rr_graph.rr_nodes(),
51-
&device_ctx.rr_graph,
52-
device_ctx.rr_rc_data,
53-
device_ctx.rr_graph.rr_switch(),
54-
route_ctx.rr_node_route_inf,
55-
is_flat);
53+
if (!router_opts.enable_parallel_connection_router) {
54+
// Serial Connection Router
55+
return new SerialConnectionRouter<HeapType>(
56+
device_ctx.grid,
57+
*router_lookahead,
58+
device_ctx.rr_graph.rr_nodes(),
59+
&device_ctx.rr_graph,
60+
device_ctx.rr_rc_data,
61+
device_ctx.rr_graph.rr_switch(),
62+
route_ctx.rr_node_route_inf,
63+
is_flat);
64+
} else {
65+
// Parallel Connection Router
66+
return new ParallelConnectionRouter<HeapType>(
67+
device_ctx.grid,
68+
*router_lookahead,
69+
device_ctx.rr_graph.rr_nodes(),
70+
&device_ctx.rr_graph,
71+
device_ctx.rr_rc_data,
72+
device_ctx.rr_graph.rr_switch(),
73+
route_ctx.rr_node_route_inf,
74+
is_flat,
75+
router_opts.multi_queue_num_threads,
76+
router_opts.multi_queue_num_queues,
77+
router_opts.multi_queue_direct_draining);
78+
}
5679
}
5780
/* Context fields */
58-
ConnectionRouter<HeapType> _router;
81+
ConnectionRouterInterface *_router;
5982
const Netlist<>& _net_list;
6083
const t_router_opts& _router_opts;
6184
CBRR& _connections_inf;

‎vpr/src/route/SerialNetlistRouter.tpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ inline RouteIterResults SerialNetlistRouter<HeapType>::route_netlist(int itry, f
2222
for (size_t inet = 0; inet < sorted_nets.size(); inet++) {
2323
ParentNetId net_id = sorted_nets[inet];
2424
NetResultFlags flags = route_net(
25-
_router,
25+
*_router,
2626
_net_list,
2727
net_id,
2828
itry,
@@ -42,7 +42,7 @@ inline RouteIterResults SerialNetlistRouter<HeapType>::route_netlist(int itry, f
4242
route_ctx.route_bb[net_id]);
4343

4444
if (!flags.success && !flags.retry_with_full_bb) {
45-
/* Disconnected RRG and ConnectionRouter doesn't think growing the BB will work */
45+
/* Disconnected RRG and SerialConnectionRouter doesn't think growing the BB will work */
4646
out.is_routable = false;
4747
return out;
4848
}
@@ -74,7 +74,7 @@ void SerialNetlistRouter<HeapType>::handle_bb_updated_nets(const std::vector<Par
7474

7575
template<typename HeapType>
7676
void SerialNetlistRouter<HeapType>::set_rcv_enabled(bool x) {
77-
_router.set_rcv_enabled(x);
77+
_router->set_rcv_enabled(x);
7878
}
7979

8080
template<typename HeapType>

‎vpr/src/route/connection_router_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct t_conn_cost_params {
2424
float criticality = 1.;
2525
float astar_fac = 1.2;
2626
float astar_offset = 0.f;
27+
float post_target_prune_fac = 1.2f;
28+
float post_target_prune_offset = 0.f;
2729
float bend_cost = 1.;
2830
float pres_fac = 1.;
2931
const t_conn_delay_budget* delay_budget = nullptr;

‎vpr/src/route/d_ary_heap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
template<unsigned D>
2222
class DAryHeap : public HeapInterface {
2323
public:
24+
static constexpr unsigned arg_D = D;
25+
2426
using priority_queue = customized_d_ary_priority_queue<D, HeapNode, std::vector<HeapNode>, HeapNodeComparator>;
2527

2628
DAryHeap() {}

0 commit comments

Comments
 (0)
Please sign in to comment.