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;

0 commit comments

Comments
 (0)