@@ -157,22 +157,22 @@ NetCostHandler::NetCostHandler(const t_placer_opts& placer_opts,
157
157
void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_ (float place_cost_exp) {
158
158
auto & device_ctx = g_vpr_ctx.device ();
159
159
160
- const size_t grid_height = device_ctx.grid .height ();
161
- const size_t grid_width = device_ctx.grid .width ();
160
+ const int grid_height = device_ctx.grid .height ();
161
+ const int grid_width = device_ctx.grid .width ();
162
162
163
163
/* Access arrays below as chan?_place_cost_fac_(subhigh, sublow). Since subhigh must be greater than or
164
164
* equal to sublow, we will only access the lower half of a matrix, but we allocate the whole matrix anyway
165
165
* for simplicity, so we can use the vtr utility matrix functions. */
166
- chanx_place_cost_fac_. resize ({ grid_height + 1 , grid_height + 1 });
167
- chany_place_cost_fac_. resize ({ grid_width + 1 , grid_width + 1 });
166
+ chanx_place_cost_fac_ = vtr::NdOffsetMatrix< float , 2 >({{{- 1 , grid_height - 1 }, {- 1 , grid_height - 1 }} });
167
+ chanx_place_cost_fac_ = vtr::NdOffsetMatrix< float , 2 >({{{- 1 , grid_width - 1 }, {- 1 , grid_width - 1 }} });
168
168
169
169
// First compute the number of tracks between channel high and channel low, inclusive.
170
- chanx_place_cost_fac_ (- 1 , - 1 ) = 0 ;
170
+ chanx_place_cost_fac_[- 1 ][- 1 ] = 0 ;
171
171
172
- for (int high = 0 ; high < ( int ) grid_height; high++) {
173
- chanx_place_cost_fac_ ( high, high) = (float )device_ctx.chan_width .x_list [high];
172
+ for (int high = 0 ; high < grid_height; high++) {
173
+ chanx_place_cost_fac_[ high][ high] = (float )device_ctx.chan_width .x_list [high];
174
174
for (int low = -1 ; low < high; low++) {
175
- chanx_place_cost_fac_ ( high, low) = chanx_place_cost_fac_ ( high - 1 , low) + (float )device_ctx.chan_width .x_list [high];
175
+ chanx_place_cost_fac_[ high][ low] = chanx_place_cost_fac_[ high - 1 ][ low] + (float )device_ctx.chan_width .x_list [high];
176
176
}
177
177
}
178
178
@@ -183,50 +183,50 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c
183
183
* place_cost_exp power -- numbers other than one mean this is no *
184
184
* longer a simple "average number of tracks"; it is some power of *
185
185
* that, allowing greater penalization of narrow channels. */
186
- for (int high = -1 ; high < ( int ) grid_height; high++) {
186
+ for (int high = -1 ; high < grid_height; high++) {
187
187
for (int low = -1 ; low <= high; low++) {
188
188
/* Since we will divide the wiring cost by the average channel *
189
189
* capacity between high and low, having only 0 width channels *
190
190
* will result in infinite wiring capacity normalization *
191
191
* factor, and extremely bad placer behaviour. Hence we change *
192
192
* this to a small (1 track) channel capacity instead. */
193
- if (chanx_place_cost_fac_ ( high, low) == 0 .0f ) {
193
+ if (chanx_place_cost_fac_[ high][ low] == 0 .0f ) {
194
194
VTR_LOG_WARN (" CHANX place cost fac is 0 at %d %d\n " , high, low);
195
- chanx_place_cost_fac_ ( high, low) = 1 .0f ;
195
+ chanx_place_cost_fac_[ high][ low] = 1 .0f ;
196
196
}
197
197
198
- chanx_place_cost_fac_ ( high, low) = (high - low + 1 .) / chanx_place_cost_fac_ ( high, low) ;
199
- chanx_place_cost_fac_ ( high, low) = pow ((double )chanx_place_cost_fac_ ( high, low) , (double )place_cost_exp);
198
+ chanx_place_cost_fac_[ high][ low] = (high - low + 1 .) / chanx_place_cost_fac_[ high][ low] ;
199
+ chanx_place_cost_fac_[ high][ low] = pow ((double )chanx_place_cost_fac_[ high][ low] , (double )place_cost_exp);
200
200
}
201
201
}
202
202
203
203
/* Now do the same thing for the y-directed channels. First get the
204
204
* number of tracks between channel high and channel low, inclusive. */
205
- chany_place_cost_fac_ (- 1 , - 1 ) = 0 ;
205
+ chany_place_cost_fac_[- 1 ][- 1 ] = 0 ;
206
206
207
- for (int high = 0 ; high < ( int ) grid_width; high++) {
208
- chany_place_cost_fac_ ( high, high) = device_ctx.chan_width .y_list [high];
207
+ for (int high = 0 ; high < grid_width; high++) {
208
+ chany_place_cost_fac_[ high][ high] = device_ctx.chan_width .y_list [high];
209
209
for (int low = -1 ; low < high; low++) {
210
- chany_place_cost_fac_ ( high, low) = chany_place_cost_fac_ ( high - 1 , low) + device_ctx.chan_width .y_list [high];
210
+ chany_place_cost_fac_[ high][ low] = chany_place_cost_fac_[ high - 1 ][ low] + device_ctx.chan_width .y_list [high];
211
211
}
212
212
}
213
213
214
214
/* Now compute the inverse of the average number of tracks per channel
215
215
* between high and low. Take to specified power. */
216
- for (int high = -1 ; high < ( int ) grid_width; high++) {
216
+ for (int high = -1 ; high < grid_width; high++) {
217
217
for (int low = -1 ; low <= high; low++) {
218
218
/* Since we will divide the wiring cost by the average channel *
219
219
* capacity between high and low, having only 0 width channels *
220
220
* will result in infinite wiring capacity normalization *
221
221
* factor, and extremely bad placer behaviour. Hence we change *
222
222
* this to a small (1 track) channel capacity instead. */
223
- if (chany_place_cost_fac_ ( high, low) == 0 .0f ) {
223
+ if (chany_place_cost_fac_[ high][ low] == 0 .0f ) {
224
224
VTR_LOG_WARN (" CHANY place cost fac is 0 at %d %d\n " , high, low);
225
- chany_place_cost_fac_ ( high, low) = 1 .0f ;
225
+ chany_place_cost_fac_[ high][ low] = 1 .0f ;
226
226
}
227
227
228
- chany_place_cost_fac_ ( high, low) = (high - low + 1 .) / chany_place_cost_fac_ ( high, low) ;
229
- chany_place_cost_fac_ ( high, low) = pow ((double )chany_place_cost_fac_ ( high, low) , (double )place_cost_exp);
228
+ chany_place_cost_fac_[ high][ low] = (high - low + 1 .) / chany_place_cost_fac_[ high][ low] ;
229
+ chany_place_cost_fac_[ high][ low] = pow ((double )chany_place_cost_fac_[ high][ low] , (double )place_cost_exp);
230
230
}
231
231
}
232
232
}
@@ -1411,8 +1411,8 @@ double NetCostHandler::get_net_cube_bb_cost_(ClusterNetId net_id, bool use_ts) {
1411
1411
*/
1412
1412
1413
1413
double ncost;
1414
- ncost = (bb.xmax - bb.xmin + 1 ) * crossing * chanx_place_cost_fac_ ( bb.ymax , bb.ymin - 1 ) ;
1415
- ncost += (bb.ymax - bb.ymin + 1 ) * crossing * chany_place_cost_fac_ ( bb.xmax , bb.xmin - 1 ) ;
1414
+ ncost = (bb.xmax - bb.xmin + 1 ) * crossing * chanx_place_cost_fac_[ bb.ymax ][ bb.ymin - 1 ] ;
1415
+ ncost += (bb.ymax - bb.ymin + 1 ) * crossing * chany_place_cost_fac_[ bb.xmax ][ bb.xmin - 1 ] ;
1416
1416
1417
1417
return ncost;
1418
1418
}
@@ -1454,10 +1454,10 @@ double NetCostHandler::get_net_per_layer_bb_cost_(ClusterNetId net_id , bool use
1454
1454
*/
1455
1455
1456
1456
ncost += (bb[layer_num].xmax - bb[layer_num].xmin + 1 ) * crossing
1457
- * chanx_place_cost_fac_ ( bb[layer_num].ymax , bb[layer_num].ymin - 1 ) ;
1457
+ * chanx_place_cost_fac_[ bb[layer_num].ymax ][ bb[layer_num].ymin - 1 ] ;
1458
1458
1459
1459
ncost += (bb[layer_num].ymax - bb[layer_num].ymin + 1 ) * crossing
1460
- * chany_place_cost_fac_ ( bb[layer_num].xmax , bb[layer_num].xmin - 1 ) ;
1460
+ * chany_place_cost_fac_[ bb[layer_num].xmax ][ bb[layer_num].xmin - 1 ] ;
1461
1461
}
1462
1462
1463
1463
return ncost;
0 commit comments