Skip to content

Commit 94b51b9

Browse files
committed
[vpr][place] add more comments to net_cost_handler.h
1 parent 5adfa2b commit 94b51b9

File tree

3 files changed

+60
-61
lines changed

3 files changed

+60
-61
lines changed

vpr/src/place/move_utils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ e_create_move create_move(t_pl_blocks_to_be_moved& blocks_affected, ClusterBlock
9797

9898
/**
9999
* @brief Find the blocks that will be affected by a move of b_from to to_loc
100-
* @param blocks_affected
101-
* @param b_from
102-
* @param to
100+
* @param blocks_affected Loaded by this routine and returned via reference; it lists the blocks etc. moved
101+
* @param b_from Id of the cluster-level block to be moved
102+
* @param to Where b_from will be moved to
103103
* @return e_block_move_result ABORT if either of the the moving blocks are already stored, or either of the blocks are fixed, to location is not
104104
* compatible, etc. INVERT if the "from" block is a single block and the "to" block is a macro. VALID otherwise.
105105
*/
@@ -121,7 +121,7 @@ e_block_move_result record_macro_self_swaps(t_pl_blocks_to_be_moved& blocks_affe
121121
* @brief Check whether the "to" location is legal for the given "blk"
122122
* @param blk
123123
* @param to
124-
* @return
124+
* @return True if this would be a legal move, false otherwise
125125
*/
126126
bool is_legal_swap_to_location(ClusterBlockId blk, t_pl_loc to);
127127

vpr/src/place/net_cost_handler.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,28 +1854,6 @@ static void set_bb_delta_cost(const int num_affected_nets, double& bb_delta_c) {
18541854
}
18551855
}
18561856

1857-
/**
1858-
* @brief Find all the nets and pins affected by this swap and update costs.
1859-
*
1860-
* Find all the nets affected by this swap and update the bounding box (wiring)
1861-
* costs. This cost function doesn't depend on the timing info.
1862-
*
1863-
* Find all the connections affected by this swap and update the timing cost.
1864-
* For a connection to be affected, it not only needs to be on or driven by
1865-
* a block, but it also needs to have its delay changed. Otherwise, it will
1866-
* not be added to the affected_pins structure.
1867-
*
1868-
* For more, see update_td_delta_costs().
1869-
*
1870-
* The timing costs are calculated by getting the new connection delays,
1871-
* multiplied by the connection criticalities returned by the timing
1872-
* analyzer. These timing costs are stored in the proposed_* data structures.
1873-
*
1874-
* The change in the bounding box cost is stored in `bb_delta_c`.
1875-
* The change in the timing cost is stored in `timing_delta_c`.
1876-
*
1877-
* @return The number of affected nets.
1878-
*/
18791857
int find_affected_nets_and_update_costs(
18801858
const t_place_algorithm& place_algorithm,
18811859
const PlaceDelayModel* delay_model,
@@ -2258,11 +2236,7 @@ void init_try_swap_net_cost_structs(size_t num_nets, bool cube_bb) {
22582236
layer_ts_bb_coord_new.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
22592237
}
22602238

2261-
ts_layer_sink_pin_count.resize({num_nets, size_t(num_layers)});
2262-
for (size_t flat_idx = 0; flat_idx < ts_layer_sink_pin_count.size(); flat_idx++) {
2263-
auto& elem = ts_layer_sink_pin_count.get(flat_idx);
2264-
elem = OPEN;
2265-
}
2239+
ts_layer_sink_pin_count.resize({num_nets, size_t(num_layers)}, OPEN);
22662240

22672241
ts_nets_to_update.resize(num_nets, ClusterNetId::INVALID());
22682242
}

vpr/src/place/net_cost_handler.h

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,43 @@
44
#include "move_transactions.h"
55
#include "place_util.h"
66

7+
/**
8+
* @brief The method used to calculate palcement cost
9+
* NORMAL: Compute cost efficiently using incremental techniques.
10+
* CHECK: Brute-force cost computation; useful to validate the more complex incremental cost update code.
11+
*/
712
enum e_cost_methods {
813
NORMAL,
914
CHECK
1015
};
1116

1217
/**
13-
* @brief Update the wire length and timing cost of the blocks (ts and proposed_* data structures) and set
14-
* the delta costs in bb_delta_c and timing_delta_c. This functions is used when the moving bocks are clusters
18+
* @brief Find all the nets and pins affected by this swap and update costs.
19+
*
20+
* Find all the nets affected by this swap and update the bounding box (wiring)
21+
* costs. This cost function doesn't depend on the timing info.
22+
*
23+
* Find all the connections affected by this swap and update the timing cost.
24+
* For a connection to be affected, it not only needs to be on or driven by
25+
* a block, but it also needs to have its delay changed. Otherwise, it will
26+
* not be added to the affected_pins structure.
27+
*
28+
* For more, see update_td_delta_costs().
29+
*
30+
* The timing costs are calculated by getting the new connection delays,
31+
* multiplied by the connection criticalities returned by the timing
32+
* analyzer. These timing costs are stored in the proposed_* data structures.
33+
*
34+
* The change in the bounding box cost is stored in `bb_delta_c`.
35+
* The change in the timing cost is stored in `timing_delta_c`.
36+
*
1537
* @param place_algorithm
1638
* @param delay_model
1739
* @param criticalities
1840
* @param blocks_affected
1941
* @param bb_delta_c
2042
* @param timing_delta_c
21-
* @return
43+
* @return The number of affected nets.
2244
*/
2345
int find_affected_nets_and_update_costs(
2446
const t_place_algorithm& place_algorithm,
@@ -29,37 +51,36 @@ int find_affected_nets_and_update_costs(
2951
double& timing_delta_c);
3052

3153
/**
32-
* @brief Finds the bb cost from scratch (based on 3D BB). Done only when the placement *
33-
* has been radically changed (i.e. after initial placement). *
34-
* Otherwise find the cost change incrementally. If method *
35-
* check is NORMAL, we find bounding boxes that are updatable *
36-
* for the larger nets. If method is CHECK, all bounding boxes *
37-
* are found via the non_updateable_bb routine, to provide a *
38-
* cost which can be used to check the correctness of the *
39-
* other routine. *
54+
* @brief Finds the bb cost from scratch (based on 3D BB).
55+
* Done only when the placement has been radically changed
56+
* (i.e. after initial placement). Otherwise find the cost
57+
* change incrementally. If method check is NORMAL, we find
58+
* bounding boxes that are updatable for the larger nets.
59+
* If method is CHECK, all bounding boxes are found via the
60+
* non_updateable_bb routine, to provide a cost which can be
61+
* used to check the correctness of the other routine.
4062
* @param method
41-
* @return
63+
* @return The bounding box cost of the placement, computed by the 3D method.
4264
*/
4365
double comp_bb_cost(e_cost_methods method);
4466

4567
/**
46-
* @brief Finds the bb cost from scratch (based on per-layer BB). Done only when the placement *
47-
* has been radically changed (i.e. after initial placement). *
48-
* Otherwise find the cost change incrementally. If method *
49-
* check is NORMAL, we find bounding boxes that are updateable *
50-
* for the larger nets. If method is CHECK, all bounding boxes *
51-
* are found via the non_updateable_bb routine, to provide a *
52-
* cost which can be used to check the correctness of the *
53-
* other routine. *
68+
* @brief Finds the bb cost from scratch (based on per-layer BB).
69+
* Done only when the placement has been radically changed
70+
* (i.e. after initial placement). Otherwise find the cost change
71+
* incrementally. If method check is NORMAL, we find bounding boxes
72+
* that are updateable for the larger nets. If method is CHECK, all
73+
* bounding boxes are found via the non_updateable_bb routine, to provide
74+
* a cost which can be used to check the correctness of the other routine.
5475
* @param method
55-
* @return
76+
* @return The placement bounding box cost, computed by the per layer method.
5677
*/
5778
double comp_layer_bb_cost(e_cost_methods method);
5879

5980
/**
6081
* @brief update net cost data structures (in placer context and net_cost in .cpp file) and reset flags (proposed_net_cost and bb_updated_before).
61-
* @param num_nets_affected
62-
* @param cube_bb
82+
* @param num_nets_affected The number of nets affected by the move. It is used to determine the index up to which elements in ts_nets_to_update are valid.
83+
* @param cube_bb True if we should use the 3D bounding box (cube_bb), false otherwise.
6384
*/
6485
void update_move_nets(int num_nets_affected,
6586
const bool cube_bb);
@@ -72,12 +93,13 @@ void reset_move_nets(int num_nets_affected);
7293

7394
/**
7495
* @brief re-calculates different terms of the cost function (wire-length, timing, NoC) and update "costs" accordingly. It is important to note that
75-
* in this function bounding box and connection delays are not calculated from scratch. However, it iterated over nets and add their costs from beginning.
96+
* in this function bounding box and connection delays are not calculated from scratch. However, it iterates over all nets and connections and updates
97+
* their costs by a complete summation, rather than incrementally.
7698
* @param placer_opts
7799
* @param noc_opts
78100
* @param delay_model
79101
* @param criticalities
80-
* @param costs
102+
* @param costs passed by reference and computed by this routine (i.e. returned by reference)
81103
*/
82104
void recompute_costs_from_scratch(const t_placer_opts& placer_opts,
83105
const t_noc_opts& noc_opts,
@@ -89,7 +111,8 @@ void recompute_costs_from_scratch(const t_placer_opts& placer_opts,
89111
* @brief Allocates and loads the chanx_place_cost_fac and chany_place_cost_fac
90112
* arrays with the inverse of the average number of tracks per channel
91113
* between [subhigh] and [sublow].
92-
* @param place_cost_exp
114+
* @param place_cost_exp It is an exponent to which you take the average inverse channel
115+
* capacity; a higher value would favour wider channels more over narrower channels during placement (usually we use 1).
93116
*/
94117
void alloc_and_load_for_fast_cost_update(float place_cost_exp);
95118

@@ -100,7 +123,7 @@ void free_fast_cost_update();
100123

101124
/**
102125
* @brief Resize net_cost, proposed_net_cost, and bb_updated_before data structures to accommodate all nets.
103-
* @param num_nets
126+
* @param num_nets Number of nets in the netlist (clustered currently) that the placement engine uses.
104127
*/
105128
void init_net_cost_structs(size_t num_nets);
106129

@@ -110,9 +133,11 @@ void init_net_cost_structs(size_t num_nets);
110133
void free_net_cost_structs();
111134

112135
/**
113-
* @brief Resize (layer_)ts_bb_edge_new, (layer_)ts_bb_coord_new, ts_layer_sink_pin_count, and ts_nets_to_update to accommodate all nets.
114-
* @param num_nets
115-
* @param cube_bb
136+
* @brief Resize temporary storage data structures needed to determine which nets are affected by a move and data needed per net
137+
* about where their terminals are in order to quickly (incrementally) update their wirelength costs. These data structures are
138+
* (layer_)ts_bb_edge_new, (layer_)ts_bb_coord_new, ts_layer_sink_pin_count, and ts_nets_to_update.
139+
* @param num_nets Number of nets in the netlist used by the placement engine (currently clustered netlist)
140+
* @param cube_bb True if the 3D bounding box should be used, false otherwise.
116141
*/
117142
void init_try_swap_net_cost_structs(size_t num_nets, bool cube_bb);
118143

0 commit comments

Comments
 (0)