Skip to content

Commit 39e5c88

Browse files
Merge pull request #3031 from verilog-to-routing/temp_lookahead_chan_cong
Congestion-Aware Initial Accumulated Cost
2 parents cc11623 + 2788011 commit 39e5c88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+652
-357
lines changed

doc/src/vpr/command_line_usage.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,20 @@ The following options are only valid when the router is in timing-driven mode (t
18241824

18251825
**Default:** ``map``
18261826

1827+
.. option:: --router_initial_acc_cost_chan_congestion_threshold <float>
1828+
1829+
Utilization threshold above which initial accumulated routing cost (acc_cost) is increased to penalize congested channels.
1830+
Used to bias routing away from highly utilized regions during early routing iterations.
1831+
1832+
**Default:** ``0.5``
1833+
1834+
.. option:: --router_initial_acc_cost_chan_congestion_weight <float>
1835+
Weight applied to the excess channel utilization (above threshold) when computing the initial accumulated cost (acc_cost)of routing resources.
1836+
1837+
Higher values make the router more sensitive to early congestion.
1838+
1839+
**Default:** ``0.5``
1840+
18271841
.. option:: --router_max_convergence_count <float>
18281842

18291843
Controls how many times the router is allowed to converge to a legal routing before halting.

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ void check_rr_graph(const RRGraphView& rr_graph,
5353
const t_chan_width& chan_width,
5454
const e_graph_type graph_type,
5555
bool is_flat) {
56-
e_route_type route_type = DETAILED;
56+
e_route_type route_type = e_route_type::DETAILED;
5757
if (graph_type == e_graph_type::GLOBAL) {
58-
route_type = GLOBAL;
58+
route_type = e_route_type::GLOBAL;
5959
}
6060

6161
auto total_edges_to_node = std::vector<int>(rr_graph.num_nodes());
@@ -420,7 +420,7 @@ void check_rr_node(const RRGraphView& rr_graph,
420420
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
421421
"in check_rr_node: CHANX out of range for endpoints (%d,%d) and (%d,%d)\n", xlow, ylow, xhigh, yhigh);
422422
}
423-
if (route_type == GLOBAL && xlow != xhigh) {
423+
if (route_type == e_route_type::GLOBAL && xlow != xhigh) {
424424
VPR_ERROR(VPR_ERROR_ROUTE,
425425
"in check_rr_node: node %d spans multiple channel segments (not allowed for global routing).\n", inode);
426426
}
@@ -431,7 +431,7 @@ void check_rr_node(const RRGraphView& rr_graph,
431431
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
432432
"Error in check_rr_node: CHANY out of range for endpoints (%d,%d) and (%d,%d)\n", xlow, ylow, xhigh, yhigh);
433433
}
434-
if (route_type == GLOBAL && ylow != yhigh) {
434+
if (route_type == e_route_type::GLOBAL && ylow != yhigh) {
435435
VPR_ERROR(VPR_ERROR_ROUTE,
436436
"in check_rr_node: node %d spans multiple channel segments (not allowed for global routing).\n", inode);
437437
}
@@ -480,7 +480,7 @@ void check_rr_node(const RRGraphView& rr_graph,
480480

481481
case e_rr_type::CHANX:
482482
case e_rr_type::CHANY:
483-
if (route_type == DETAILED) {
483+
if (route_type == e_route_type::DETAILED) {
484484
nodes_per_chan = chan_width.max;
485485
tracks_per_node = 1;
486486
} else {

libs/librrgraph/src/base/rr_graph_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ struct t_chan_width {
1313
std::vector<int> y_list;
1414
};
1515

16-
enum e_route_type {
16+
/// @brief Specifies whether global routing or combined global and detailed routing is performed.
17+
enum class e_route_type {
1718
GLOBAL,
1819
DETAILED
1920
};

libs/librrgraph/src/base/rr_node_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ typedef vtr::Range<edge_idx_iterator> edge_idx_range;
103103

104104
typedef std::vector<std::map<int, int>> t_arch_switch_fanin;
105105

106-
/*
107-
* Resistance/Capacitance data for an RR Nodes
106+
/**
107+
* @brief Resistance/Capacitance data for an RR Node.
108108
*
109109
* In practice many RR nodes have the same values, so they are fly-weighted
110110
* to keep t_rr_node small. Each RR node holds an rc_index which allows
@@ -121,8 +121,8 @@ typedef std::vector<std::map<int, int>> t_arch_switch_fanin;
121121
struct t_rr_rc_data {
122122
t_rr_rc_data(float Rval, float Cval) noexcept;
123123

124-
float R;
125-
float C;
124+
float R; ///< Resistance to go through an RR node
125+
float C; ///< Total capacitance of an RR node.
126126
};
127127

128128
// This is the data type of fast lookups of an rr-node given an (rr_type, layer, x, y, and the side)

libs/librrgraph/src/base/rr_rc_data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "rr_node_types.h"
44

5-
/*
6-
* Returns the index to a t_rr_rc_data matching the specified values.
5+
/**
6+
* @brief Returns the index to a t_rr_rc_data matching the specified values.
77
*
88
* If an existing t_rr_rc_data matches the specified R/C it's index
99
* is returned, otherwise the t_rr_rc_data is created.

libs/libvtrutil/src/vtr_assert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
*
102102
* Note that to avoid 'unused' variable warnings when assertions are
103103
* disabled, we pass the expr and msg to sizeof(). We use sizeof specifically
104-
* since it accepts expressions, and the C++ standard gaurentees sizeof's arguments
104+
* since it accepts expressions, and the C++ standard guarantees sizeof's arguments
105105
* are never evaluated (ensuring any expensive expressions are not evaluated when
106106
* assertions are disabled). To avoid warnings about the unused result of sizeof()
107107
* we cast it to void.
@@ -140,7 +140,7 @@ namespace assert {
140140
* function will never return. This should ensure the
141141
* compiler won't warn about detected conditions such as
142142
* dead-code or potential null pointer dereferences
143-
* which are gaurded against by assertions.
143+
* which are guarded against by assertions.
144144
*/
145145
[[noreturn]] void handle_assert(const char* expr, const char* file, unsigned int line, const char* function, const char* msg);
146146
} // namespace assert

libs/libvtrutil/src/vtr_prefix_sum.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ class PrefixSum1D {
123123
return prefix_sum_[upper_x + 1] - prefix_sum_[lower_x];
124124
}
125125

126+
/// @brief Checks if the prefix sum is initialized or it is empty.
127+
bool empty() const {
128+
return prefix_sum_.empty();
129+
}
130+
126131
private:
127132
/**
128133
* @brief The 1D prefix sum of the original array of values.
@@ -268,6 +273,11 @@ class PrefixSum2D {
268273
+ prefix_sum_[lower_x][lower_y];
269274
}
270275

276+
/// @brief Checks if the prefix sum is initialized or it is empty.
277+
bool empty() const {
278+
return prefix_sum_.empty();
279+
}
280+
271281
private:
272282
/**
273283
* @brief The 2D prefix sum of the original grid of values.

vpr/src/analytical_place/detailed_placer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void AnnealerDetailedPlacer::optimize_placement() {
101101
placer_->place();
102102

103103
// Copy the placement solution into the global placement solution.
104-
placer_->copy_locs_to_global_state(g_vpr_ctx.mutable_placement());
104+
placer_->update_global_state();
105105

106106
// Since the placement was modified, need to resynchronize the pins in the
107107
// clusters.

vpr/src/base/CheckSetup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ void CheckSetup(const t_packer_opts& packer_opts,
3434
}
3535
}
3636

37-
if ((GLOBAL == router_opts.route_type)
38-
&& (placer_opts.place_algorithm.is_timing_driven())) {
37+
if (e_route_type::GLOBAL == router_opts.route_type
38+
&& placer_opts.place_algorithm.is_timing_driven()) {
3939
/* Works, but very weird. Can't optimize timing well, since you're
4040
* not doing proper architecture delay modelling. */
4141
VTR_LOG_WARN(
@@ -106,7 +106,7 @@ void CheckSetup(const t_packer_opts& packer_opts,
106106
}
107107
}
108108

109-
if (DETAILED == router_opts.route_type) {
109+
if (e_route_type::DETAILED == router_opts.route_type) {
110110
if ((chans.chan_x_dist.type != UNIFORM)
111111
|| (chans.chan_y_dist.type != UNIFORM)) {
112112
VPR_FATAL_ERROR(VPR_ERROR_OTHER,

vpr/src/base/SetupVPR.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ static void SetupRouterOpts(const t_options& Options, t_router_opts* RouterOpts)
488488
RouterOpts->router_debug_sink_rr = Options.router_debug_sink_rr;
489489
RouterOpts->router_debug_iteration = Options.router_debug_iteration;
490490
RouterOpts->lookahead_type = Options.router_lookahead_type;
491+
RouterOpts->initial_acc_cost_chan_congestion_threshold = Options.router_initial_acc_cost_chan_congestion_threshold;
492+
RouterOpts->initial_acc_cost_chan_congestion_weight = Options.router_initial_acc_cost_chan_congestion_weight;
493+
491494
RouterOpts->max_convergence_count = Options.router_max_convergence_count;
492495
RouterOpts->reconvergence_cpd_threshold = Options.router_reconvergence_cpd_threshold;
493496
RouterOpts->initial_timing = Options.router_initial_timing;

vpr/src/base/ShowSetup.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ static void ShowAnnealSched(const t_annealing_sched& AnnealSched) {
224224
static void ShowRouterOpts(const t_router_opts& RouterOpts) {
225225
VTR_LOG("RouterOpts.route_type: ");
226226
switch (RouterOpts.route_type) {
227-
case GLOBAL:
227+
case e_route_type::GLOBAL:
228228
VTR_LOG("GLOBAL\n");
229229
break;
230-
case DETAILED:
230+
case e_route_type::DETAILED:
231231
VTR_LOG("DETAILED\n");
232232
break;
233233
default:
@@ -248,7 +248,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
248248
VTR_LOG("off\n");
249249
}
250250

251-
VTR_ASSERT(GLOBAL == RouterOpts.route_type || DETAILED == RouterOpts.route_type);
251+
VTR_ASSERT(e_route_type::GLOBAL == RouterOpts.route_type || e_route_type::DETAILED == RouterOpts.route_type);
252252

253253
VTR_LOG("RouterOpts.router_algorithm: ");
254254
switch (RouterOpts.router_algorithm) {
@@ -266,9 +266,9 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
266266
break;
267267
default:
268268
switch (RouterOpts.route_type) {
269-
case DETAILED:
269+
case e_route_type::DETAILED:
270270
VPR_FATAL_ERROR(VPR_ERROR_UNKNOWN, "<Unknown>\n");
271-
case GLOBAL:
271+
case e_route_type::GLOBAL:
272272
VTR_LOG_ERROR("Unknown router algorithm\n");
273273
break;
274274
default:
@@ -282,31 +282,31 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
282282
VTR_LOG("DELAY_NORMALIZED\n");
283283
break;
284284
case DELAY_NORMALIZED_LENGTH:
285-
if (GLOBAL == RouterOpts.route_type) {
285+
if (e_route_type::GLOBAL == RouterOpts.route_type) {
286286
VTR_LOG_ERROR("Unknown router base cost type\n");
287287
break;
288288
}
289289

290290
VTR_LOG("DELAY_NORMALIZED_LENGTH\n");
291291
break;
292292
case DELAY_NORMALIZED_LENGTH_BOUNDED:
293-
if (GLOBAL == RouterOpts.route_type) {
293+
if (e_route_type::GLOBAL == RouterOpts.route_type) {
294294
VTR_LOG_ERROR("Unknown router base cost type\n");
295295
break;
296296
}
297297

298298
VTR_LOG("DELAY_NORMALIZED_LENGTH_BOUNDED\n");
299299
break;
300300
case DELAY_NORMALIZED_FREQUENCY:
301-
if (GLOBAL == RouterOpts.route_type) {
301+
if (e_route_type::GLOBAL == RouterOpts.route_type) {
302302
VTR_LOG_ERROR("Unknown router base cost type\n");
303303
break;
304304
}
305305

306306
VTR_LOG("DELAY_NORMALIZED_FREQUENCY\n");
307307
break;
308308
case DELAY_NORMALIZED_LENGTH_FREQUENCY:
309-
if (GLOBAL == RouterOpts.route_type) {
309+
if (e_route_type::GLOBAL == RouterOpts.route_type) {
310310
VTR_LOG_ERROR("Unknown router base cost type\n");
311311
break;
312312
}
@@ -317,7 +317,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
317317
VTR_LOG("DEMAND_ONLY\n");
318318
break;
319319
case DEMAND_ONLY_NORMALIZED_LENGTH:
320-
if (GLOBAL == RouterOpts.route_type) {
320+
if (e_route_type::GLOBAL == RouterOpts.route_type) {
321321
VTR_LOG_ERROR("Unknown router base cost type\n");
322322
break;
323323
}
@@ -326,9 +326,9 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
326326
break;
327327
default:
328328
switch (RouterOpts.route_type) {
329-
case DETAILED:
329+
case e_route_type::DETAILED:
330330
VPR_FATAL_ERROR(VPR_ERROR_UNKNOWN, "Unknown base_cost_type\n");
331-
case GLOBAL:
331+
case e_route_type::GLOBAL:
332332
VTR_LOG_ERROR("Unknown router base cost type\n");
333333
break;
334334
default:
@@ -343,7 +343,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
343343
VTR_LOG("%d\n", RouterOpts.fixed_channel_width);
344344
}
345345

346-
if (DETAILED == RouterOpts.route_type) {
346+
if (e_route_type::DETAILED == RouterOpts.route_type) {
347347
VTR_LOG("RouterOpts.check_route: ");
348348
switch (RouterOpts.check_route) {
349349
case e_check_route_option::OFF:
@@ -369,6 +369,8 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
369369
VTR_LOG("RouterOpts.max_pres_fac: %f\n", RouterOpts.max_pres_fac);
370370
VTR_LOG("RouterOpts.max_router_iterations: %d\n", RouterOpts.max_router_iterations);
371371
VTR_LOG("RouterOpts.min_incremental_reroute_fanout: %d\n", RouterOpts.min_incremental_reroute_fanout);
372+
VTR_LOG("RouterOpts.initial_acc_cost_chan_congestion_threshold: %f\n", RouterOpts.initial_acc_cost_chan_congestion_threshold);
373+
VTR_LOG("RouterOpts.initial_acc_cost_chan_congestion_weight: %f\n", RouterOpts.initial_acc_cost_chan_congestion_weight);
372374
VTR_LOG("RouterOpts.do_check_rr_graph: %s\n", RouterOpts.do_check_rr_graph ? "true" : "false");
373375
VTR_LOG("RouterOpts.verify_binary_search: %s\n", RouterOpts.verify_binary_search ? "true" : "false");
374376
VTR_LOG("RouterOpts.min_channel_width_hint: %d\n", RouterOpts.min_channel_width_hint);
@@ -389,7 +391,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
389391
VTR_LOG("RouterOpts.max_criticality: %f\n", RouterOpts.max_criticality);
390392
VTR_LOG("RouterOpts.init_wirelength_abort_threshold: %f\n", RouterOpts.init_wirelength_abort_threshold);
391393

392-
if (GLOBAL == RouterOpts.route_type)
394+
if (e_route_type::GLOBAL == RouterOpts.route_type)
393395
VTR_LOG("RouterOpts.incr_reroute_delay_ripup: %f\n", RouterOpts.incr_reroute_delay_ripup);
394396
else {
395397
std::string incr_delay_ripup_opts[3] = {"ON", "OFF", "AUTO"};
@@ -468,7 +470,7 @@ static void ShowRouterOpts(const t_router_opts& RouterOpts) {
468470
}
469471
}
470472

471-
if (DETAILED == RouterOpts.route_type) {
473+
if (e_route_type::DETAILED == RouterOpts.route_type) {
472474
if (RouterOpts.routing_failure_predictor == SAFE)
473475
VTR_LOG("RouterOpts.routing_failure_predictor = SAFE\n");
474476
else if (RouterOpts.routing_failure_predictor == AGGRESSIVE)

vpr/src/base/globals.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#include "globals.h"
2+
#include "route_common.h"
23

34
VprContext g_vpr_ctx;

vpr/src/base/old_traceback.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "clustered_netlist_fwd.h"
44
#include "globals.h"
55
#include "vtr_assert.h"
6+
#include "route_common.h"
67

78
#include <vector>
89

vpr/src/base/place_and_route.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
7979

8080
/* Allocate the major routing structures. */
8181

82-
if (router_opts.route_type == GLOBAL) {
82+
if (router_opts.route_type == e_route_type::GLOBAL) {
8383
graph_type = e_graph_type::GLOBAL;
8484
graph_directionality = e_graph_type::BIDIR;
8585
} else {
@@ -376,8 +376,8 @@ int binary_search_place_and_route(const Netlist<>& placement_net_list,
376376

377377
init_draw_coords(final, g_vpr_ctx.placement().blk_loc_registry());
378378

379-
/* Allocate and load additional rr_graph information needed only by the router. */
380-
alloc_and_load_rr_node_route_structs();
379+
// Allocate and load additional rr_graph information needed only by the router.
380+
alloc_and_load_rr_node_route_structs(router_opts);
381381

382382
init_route_structs(router_net_list,
383383
router_opts.bb_factor,
@@ -424,7 +424,7 @@ t_chan_width setup_chan_width(const t_router_opts& router_opts,
424424
width_fac = router_opts.fixed_channel_width;
425425
}
426426

427-
if (router_opts.route_type == GLOBAL) {
427+
if (router_opts.route_type == e_route_type::GLOBAL) {
428428
graph_directionality = e_graph_type::BIDIR;
429429
} else {
430430
graph_directionality = e_graph_type::UNIDIR;

0 commit comments

Comments
 (0)