Skip to content

Commit cf73987

Browse files
change DimRange from {-1, grid_height} to {-2, grid_height}
1 parent 68ecb55 commit cf73987

File tree

2 files changed

+10
-63
lines changed

2 files changed

+10
-63
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 8 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -153,89 +153,36 @@ NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts,
153153
}
154154

155155
void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_cost_exp) {
156-
auto& device_ctx = g_vpr_ctx.device();
156+
const auto& device_ctx = g_vpr_ctx.device();
157157

158158
const int grid_height = device_ctx.grid.height();
159159
const int grid_width = device_ctx.grid.width();
160160

161161
/* Access arrays below as chan?_place_cost_fac_(subhigh, sublow). Since subhigh must be greater than or
162162
* equal to sublow, we will only access the lower half of a matrix, but we allocate the whole matrix anyway
163163
* for simplicity, so we can use the vtr utility matrix functions. */
164-
acc_chanx_width_ = vtr::NdOffsetMatrix<int, 1>({{{-1, grid_height}}});
165-
acc_chany_width_ = vtr::NdOffsetMatrix<int, 1>({{{-1, grid_width}}});
164+
acc_chanx_width_ = vtr::NdOffsetMatrix<int, 1>({{{-2, grid_height}}});
165+
acc_chany_width_ = vtr::NdOffsetMatrix<int, 1>({{{-2, grid_width}}});
166166

167167
// First compute the number of tracks between channel high and channel low, inclusive.
168-
acc_chanx_width_[-1] = 0;
168+
acc_chanx_width_[-2] = 0;
169+
acc_chanx_width_[-1] = 1;
169170
for (int y = 0; y < grid_height; y++) {
170171
acc_chanx_width_[y] = acc_chanx_width_[y - 1] + device_ctx.chan_width.x_list[y];
171172
if (acc_chanx_width_[y] == acc_chanx_width_[y - 1]) {
172173
acc_chanx_width_[y]++;
173174
}
174175
}
175176

176-
acc_chany_width_[-1] = 0;
177-
for (int x = 0; x < grid_height; x++) {
177+
acc_chany_width_[-2] = 0;
178+
acc_chany_width_[-1] = 1;
179+
for (int x = 0; x < grid_width; x++) {
178180
acc_chany_width_[x] = acc_chany_width_[x - 1] + device_ctx.chan_width.y_list[x];
179181
if (acc_chany_width_[x] == acc_chany_width_[x - 1]) {
180182
acc_chany_width_[x]++;
181183
}
182184
}
183185

184-
185-
// /* Now compute the inverse of the average number of tracks per channel *
186-
// * between high and low. The cost function divides by the average *
187-
// * number of tracks per channel, so by storing the inverse I convert *
188-
// * this to a faster multiplication. Take this final number to the *
189-
// * place_cost_exp power -- numbers other than one mean this is no *
190-
// * longer a simple "average number of tracks"; it is some power of *
191-
// * that, allowing greater penalization of narrow channels. */
192-
// for (int high = -1; high < grid_height; high++) {
193-
// for (int low = -1; low <= high; low++) {
194-
// /* Since we will divide the wiring cost by the average channel *
195-
// * capacity between high and low, having only 0 width channels *
196-
// * will result in infinite wiring capacity normalization *
197-
// * factor, and extremely bad placer behaviour. Hence we change *
198-
// * this to a small (1 track) channel capacity instead. */
199-
// if (chanx_place_cost_fac_[high][low] == 0.0f) {
200-
// VTR_LOG_WARN("CHANX place cost fac is 0 at %d %d\n", high, low);
201-
// chanx_place_cost_fac_[high][low] = 1.0f;
202-
// }
203-
//
204-
// chanx_place_cost_fac_[high][low] = (high - low + 1.) / chanx_place_cost_fac_[high][low];
205-
// chanx_place_cost_fac_[high][low] = pow((double)chanx_place_cost_fac_[high][low], (double)place_cost_exp);
206-
// }
207-
// }
208-
//
209-
// /* Now do the same thing for the y-directed channels. First get the
210-
// * number of tracks between channel high and channel low, inclusive. */
211-
// chany_place_cost_fac_[-1][-1] = 0;
212-
//
213-
// for (int high = 0; high < grid_width; high++) {
214-
// chany_place_cost_fac_[high][high] = device_ctx.chan_width.y_list[high];
215-
// for (int low = -1; low < high; low++) {
216-
// chany_place_cost_fac_[high][low] = chany_place_cost_fac_[high - 1][low] + device_ctx.chan_width.y_list[high];
217-
// }
218-
// }
219-
//
220-
// /* Now compute the inverse of the average number of tracks per channel
221-
// * between high and low. Take to specified power. */
222-
// for (int high = -1; high < grid_width; high++) {
223-
// for (int low = -1; low <= high; low++) {
224-
// /* Since we will divide the wiring cost by the average channel *
225-
// * capacity between high and low, having only 0 width channels *
226-
// * will result in infinite wiring capacity normalization *
227-
// * factor, and extremely bad placer behaviour. Hence we change *
228-
// * this to a small (1 track) channel capacity instead. */
229-
// if (chany_place_cost_fac_[high][low] == 0.0f) {
230-
// VTR_LOG_WARN("CHANY place cost fac is 0 at %d %d\n", high, low);
231-
// chany_place_cost_fac_[high][low] = 1.0f;
232-
// }
233-
//
234-
// chany_place_cost_fac_[high][low] = (high - low + 1.) / chany_place_cost_fac_[high][low];
235-
// chany_place_cost_fac_[high][low] = pow((double)chany_place_cost_fac_[high][low], (double)place_cost_exp);
236-
// }
237-
// }
238-
239186
if (device_ctx.grid.get_num_layers() > 1) {
240187
alloc_and_load_for_fast_vertical_cost_update_(place_cost_exp);
241188
}

vpr/src/place/net_cost_handler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,11 @@ class NetCostHandler {
514514

515515
template<typename BBT>
516516
std::pair<double, double> get_chan_place_fac_(const BBT& bb) {
517-
const int total_chanx_width = acc_chanx_width_[bb.ymax] - acc_chanx_width_[bb.ymin - 1];
517+
const int total_chanx_width = acc_chanx_width_[bb.ymax] - acc_chanx_width_[bb.ymin - 2];
518518
const double inverse_average_chanx_width = (bb.ymax - bb.ymin + 2.0) / total_chanx_width;
519519
const double inverse_average_chanx_width_sharpened = std::pow(inverse_average_chanx_width, (double)placer_opts_.place_cost_exp);
520520

521-
const int total_chany_width = acc_chany_width_[bb.xmax] - acc_chany_width_[bb.xmin - 1];
521+
const int total_chany_width = acc_chany_width_[bb.xmax] - acc_chany_width_[bb.xmin - 2];
522522
const double inverse_average_chany_width = (bb.xmax - bb.xmin + 2.0) / total_chany_width;
523523
const double inverse_average_chany_width_sharpened = std::pow(inverse_average_chany_width, (double)placer_opts_.place_cost_exp);
524524

0 commit comments

Comments
 (0)