@@ -140,11 +140,10 @@ static void update_td_delta_costs(const PlaceDelayModel* delay_model,
140
140
bool is_src_moving);
141
141
142
142
/* *
143
- * @brief if "net" is not already stored as an affected net, mark it in ts_nets_to_update and increment num_affected_nets
143
+ * @brief if "net" is not already stored as an affected net, mark it in ts_nets_to_update and increment the size ofts_nets_to_update.
144
144
* @param net ID of a net affected by a move
145
- * @param num_affected_nets Incremented if this is a new net affected, and returned via reference.
146
145
*/
147
- static void record_affected_net (const ClusterNetId net, int & num_affected_nets );
146
+ static void record_affected_net (const ClusterNetId net);
148
147
149
148
/* *
150
149
* @brief Call suitable function based on the bounding box type to update the bounding box of the net connected to pin_id. Also,
@@ -157,7 +156,6 @@ static void record_affected_net(const ClusterNetId net, int& num_affected_nets);
157
156
* @param moving_blk_inf Data structure that holds information, e.g., old location and new locatoin, about all moving blocks
158
157
* @param affected_pins Netlist pins which are affected, in terms placement cost, by the proposed move.
159
158
* @param timing_delta_c Timing cost change based on the proposed move
160
- * @param num_affected_nets A pointer to the first free element of ts_nets_to_update. If a new net is added, the pointer should be increamented.
161
159
* @param is_src_moving Is the moving pin the source of a net.
162
160
*/
163
161
static void update_net_info_on_pin_move (const t_place_algorithm& place_algorithm,
@@ -168,7 +166,6 @@ static void update_net_info_on_pin_move(const t_place_algorithm& place_algorithm
168
166
const t_pl_moved_block& moving_blk_inf,
169
167
std::vector<ClusterPinId>& affected_pins,
170
168
double & timing_delta_c,
171
- int & num_affected_nets,
172
169
bool is_src_moving);
173
170
174
171
/* *
@@ -446,10 +443,9 @@ static double wirelength_crossing_count(size_t fanout);
446
443
/* *
447
444
* @brief Calculates and returns the total bb (wirelength) cost change that would result from moving the blocks
448
445
* indicated in the blocks_affected data structure.
449
- * @param num_affected_nets Number of valid elements in ts_bb_coord_new
450
446
* @param bb_delta_c Cost difference after and before moving the block
451
447
*/
452
- static void set_bb_delta_cost (const int num_affected_nets, double & bb_delta_c);
448
+ static void set_bb_delta_cost (double & bb_delta_c);
453
449
454
450
/* ****************************** End of Function definitions ************************************/
455
451
@@ -642,13 +638,14 @@ static void update_td_delta_costs(const PlaceDelayModel* delay_model,
642
638
}
643
639
644
640
// /@brief Record effected nets.
645
- static void record_affected_net (const ClusterNetId net,
646
- int & num_affected_nets) {
641
+ static void record_affected_net (const ClusterNetId net) {
647
642
/* Record effected nets. */
648
643
if (proposed_net_cost[net] < 0 .) {
649
644
/* Net not marked yet. */
650
- ts_nets_to_update[num_affected_nets] = net;
651
- num_affected_nets++;
645
+ size_t last_size = ts_nets_to_update.size ();
646
+ VTR_ASSERT (last_size < ts_nets_to_update.capacity ());
647
+ ts_nets_to_update.resize (last_size + 1 );
648
+ ts_nets_to_update[last_size] = net;
652
649
653
650
/* Flag to say we've marked this net. */
654
651
proposed_net_cost[net] = 1 .;
@@ -663,7 +660,6 @@ static void update_net_info_on_pin_move(const t_place_algorithm& place_algorithm
663
660
const t_pl_moved_block& moving_blk_inf,
664
661
std::vector<ClusterPinId>& affected_pins,
665
662
double & timing_delta_c,
666
- int & num_affected_nets,
667
663
bool is_src_moving) {
668
664
const auto & cluster_ctx = g_vpr_ctx.clustering ();
669
665
const ClusterNetId net_id = cluster_ctx.clb_nlist .pin_net (pin_id);
@@ -677,7 +673,7 @@ static void update_net_info_on_pin_move(const t_place_algorithm& place_algorithm
677
673
}
678
674
679
675
/* Record effected nets */
680
- record_affected_net (net_id, num_affected_nets );
676
+ record_affected_net (net_id);
681
677
682
678
const auto & cube_bb = g_vpr_ctx.placement ().cube_bb ;
683
679
@@ -1852,8 +1848,8 @@ static double wirelength_crossing_count(size_t fanout) {
1852
1848
}
1853
1849
}
1854
1850
1855
- static void set_bb_delta_cost (const int num_affected_nets, double & bb_delta_c) {
1856
- for (int inet_affected = 0 ; inet_affected < num_affected_nets ;
1851
+ static void set_bb_delta_cost (double & bb_delta_c) {
1852
+ for (size_t inet_affected = 0 ; inet_affected < ts_nets_to_update. size () ;
1857
1853
inet_affected++) {
1858
1854
ClusterNetId net_id = ts_nets_to_update[inet_affected];
1859
1855
const auto & cube_bb = g_vpr_ctx.placement ().cube_bb ;
@@ -1871,7 +1867,7 @@ static void set_bb_delta_cost(const int num_affected_nets, double& bb_delta_c) {
1871
1867
}
1872
1868
}
1873
1869
1874
- int find_affected_nets_and_update_costs (
1870
+ void find_affected_nets_and_update_costs (
1875
1871
const t_place_algorithm& place_algorithm,
1876
1872
const PlaceDelayModel* delay_model,
1877
1873
const PlacerCriticalities* criticalities,
@@ -1882,7 +1878,7 @@ int find_affected_nets_and_update_costs(
1882
1878
VTR_ASSERT_SAFE (timing_delta_c == 0 .);
1883
1879
auto & clb_nlist = g_vpr_ctx.clustering ().clb_nlist ;
1884
1880
1885
- int num_affected_nets = 0 ;
1881
+ ts_nets_to_update. resize ( 0 ) ;
1886
1882
1887
1883
/* Go through all the blocks moved. */
1888
1884
for (int iblk = 0 ; iblk < blocks_affected.num_moved_blocks ; iblk++) {
@@ -1907,16 +1903,13 @@ int find_affected_nets_and_update_costs(
1907
1903
moving_block_inf,
1908
1904
affected_pins,
1909
1905
timing_delta_c,
1910
- num_affected_nets,
1911
1906
is_src_moving);
1912
1907
}
1913
1908
}
1914
1909
1915
1910
/* Now update the bounding box costs (since the net bounding *
1916
1911
* boxes are up-to-date). The cost is only updated once per net. */
1917
- set_bb_delta_cost (num_affected_nets, bb_delta_c);
1918
-
1919
- return num_affected_nets;
1912
+ set_bb_delta_cost (bb_delta_c);
1920
1913
}
1921
1914
1922
1915
double comp_bb_cost (e_cost_methods method) {
@@ -1997,13 +1990,12 @@ double comp_layer_bb_cost(e_cost_methods method) {
1997
1990
return cost;
1998
1991
}
1999
1992
2000
- void update_move_nets (int num_nets_affected,
2001
- const bool cube_bb) {
1993
+ void update_move_nets (const bool cube_bb) {
2002
1994
/* update net cost functions and reset flags. */
2003
1995
auto & cluster_ctx = g_vpr_ctx.clustering ();
2004
1996
auto & place_move_ctx = g_placer_ctx.mutable_move ();
2005
1997
2006
- for (int inet_affected = 0 ; inet_affected < num_nets_affected ;
1998
+ for (size_t inet_affected = 0 ; inet_affected < ts_nets_to_update. size () ;
2007
1999
inet_affected++) {
2008
2000
ClusterNetId net_id = ts_nets_to_update[inet_affected];
2009
2001
@@ -2033,9 +2025,9 @@ void update_move_nets(int num_nets_affected,
2033
2025
}
2034
2026
}
2035
2027
2036
- void reset_move_nets (int num_nets_affected ) {
2028
+ void reset_move_nets () {
2037
2029
/* Reset the net cost function flags first. */
2038
- for (int inet_affected = 0 ; inet_affected < num_nets_affected ;
2030
+ for (size_t inet_affected = 0 ; inet_affected < ts_nets_to_update. size () ;
2039
2031
inet_affected++) {
2040
2032
ClusterNetId net_id = ts_nets_to_update[inet_affected];
2041
2033
proposed_net_cost[net_id] = -1 ;
@@ -2242,7 +2234,8 @@ void init_try_swap_net_cost_structs(size_t num_nets, bool cube_bb) {
2242
2234
/* This initialize the whole matrix to OPEN which is an invalid value*/
2243
2235
ts_layer_sink_pin_count.resize ({num_nets, size_t (num_layers)}, OPEN);
2244
2236
2245
- ts_nets_to_update.resize (num_nets, ClusterNetId::INVALID ());
2237
+ ts_nets_to_update.reserve (num_nets);
2238
+ ts_nets_to_update.resize (0 );
2246
2239
}
2247
2240
2248
2241
void free_try_swap_net_cost_structs () {
0 commit comments