Skip to content

Commit f2939b1

Browse files
committed
[vpr][place][net_cost] fix typos
1 parent e15a796 commit f2939b1

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts,
155155
}
156156

157157
void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_() {
158-
float place_cost_exp = placer_opts_.place_cost_exp;
158+
const double place_cost_exp = static_cast<double>(placer_opts_.place_cost_exp);
159159
auto& device_ctx = g_vpr_ctx.device();
160160

161161
const int grid_height = device_ctx.grid.height();
@@ -197,7 +197,7 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_() {
197197
}
198198

199199
chanx_place_cost_fac_[high][low] = (high - low + 1.) / chanx_place_cost_fac_[high][low];
200-
chanx_place_cost_fac_[high][low] = pow((double)chanx_place_cost_fac_[high][low], (double)place_cost_exp);
200+
chanx_place_cost_fac_[high][low] = pow((double)chanx_place_cost_fac_[high][low], place_cost_exp);
201201
}
202202
}
203203

@@ -227,7 +227,7 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_() {
227227
}
228228

229229
chany_place_cost_fac_[high][low] = (high - low + 1.) / chany_place_cost_fac_[high][low];
230-
chany_place_cost_fac_[high][low] = pow((double)chany_place_cost_fac_[high][low], (double)place_cost_exp);
230+
chany_place_cost_fac_[high][low] = pow((double)chany_place_cost_fac_[high][low], place_cost_exp);
231231
}
232232
}
233233

@@ -268,22 +268,27 @@ void NetCostHandler::alloc_and_load_for_fast_vertical_cost_update_() {
268268
* the block on the lower left connection of the block is added twice, that part needs to be removed.
269269
*/
270270
for (const auto& src_rr_node : rr_graph.nodes()) {
271-
for (auto edge_range: {rr_graph.configurable_edges(src_rr_node), rr_graph.non_configurable_edges(src_rr_node)}) {
272-
for (const auto& rr_edge_idx : edge_range) {
273-
const auto& sink_rr_node = rr_graph.edge_sink_node(src_rr_node, rr_edge_idx);
274-
if (rr_graph.node_layer(src_rr_node) != rr_graph.node_layer(sink_rr_node)) {
275-
// We assume that the nodes driving the inter-layer connection or being driven by it
276-
// are not stretched across multiple tiles
277-
int src_x = rr_graph.node_xhigh(src_rr_node);
278-
int src_y = rr_graph.node_yhigh(src_rr_node);
279-
VTR_ASSERT(rr_graph.node_xlow(src_rr_node) == src_x && rr_graph.node_ylow(src_rr_node) == src_y);
280-
281-
tile_num_inter_die_conn[src_x][src_y]++;
282-
}
271+
for (const auto& rr_edge_idx : rr_graph.edges(src_rr_node)) {
272+
const auto& sink_rr_node = rr_graph.edge_sink_node(src_rr_node, rr_edge_idx);
273+
if (rr_graph.node_layer(src_rr_node) != rr_graph.node_layer(sink_rr_node)) {
274+
// We assume that the nodes driving the inter-layer connection or being driven by it
275+
// are not stretched across multiple tiles
276+
int src_x = rr_graph.node_xhigh(src_rr_node);
277+
int src_y = rr_graph.node_yhigh(src_rr_node);
278+
VTR_ASSERT(rr_graph.node_xlow(src_rr_node) == src_x && rr_graph.node_ylow(src_rr_node) == src_y);
279+
280+
tile_num_inter_die_conn[src_x][src_y]++;
283281
}
284282
}
285283
}
286284

285+
int num_layers = device_ctx.grid.get_num_layers();
286+
for (size_t x = 0; x < device_ctx.grid.width(); x++) {
287+
for (size_t y = 0; y < device_ctx.grid.height(); y++) {
288+
tile_num_inter_die_conn[x][y] /= (num_layers-1);
289+
}
290+
}
291+
287292
// Step 2: Calculate prefix sum of the inter-die connectivity up to and including the channel at (x, y).
288293
acc_tile_num_inter_die_conn_[0][0] = tile_num_inter_die_conn[0][0];
289294
// Initialize the first row and column

vpr/src/place/net_cost_handler.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,14 @@ class NetCostHandler {
198198
vtr::NdOffsetMatrix<float, 2> chanx_place_cost_fac_; // [-1...device_ctx.grid.width()-1]
199199
vtr::NdOffsetMatrix<float, 2> chany_place_cost_fac_; // [-1...device_ctx.grid.height()-1]
200200
/**
201-
@brief This data structure stores the cumulative number of inter-die connections from the lower-left corner.
202-
* It is later used to calculate the chanZ factor, which functions similarly to chanx_place_cost_fac_ and chany_place_cost_fac_,
203-
* but applies to the height of the bounding box. The chanZ factor is calculated during block placement because storing it in the
204-
* same way as the X and Y cost factors would require a 4D array and population it is an O(n^2) operation.
201+
* @brief The matrix below is used to calculate a chanz_place_cost_fac based on the average channel width in
202+
* the cross-die-layer direction over a 2D (x,y) region. We don't assume the inter-die connectivity is the same at all (x,y) locations, so we
203+
* can't compute the full chanz_place_cost_fac for all possible (xlow,ylow)(xhigh,yhigh) without a 4D array, which would
204+
* be too big: O(n^2) in circuit size. Instead we compute a prefix sum that stores the number of inter-die connections per layer from
205+
* (x=0,y=0) to (x,y). Given this, we can compute the average number of inter-die connections over a (xlow,ylow) to (xhigh,yhigh)
206+
* region in O(1) (by adding and subtracting 4 entries)
205207
*/
206-
vtr::NdMatrix<int, 2> acc_tile_num_inter_die_conn_;
208+
vtr::NdMatrix<int, 2> acc_tile_num_inter_die_conn_; // [0..grid_width-1][0..grid_height-1]
207209

208210

209211
private:

0 commit comments

Comments
 (0)