Skip to content

Commit 78e7dba

Browse files
remove static ts_info from net_cost_handler
1 parent 57cf345 commit 78e7dba

File tree

3 files changed

+65
-92
lines changed

3 files changed

+65
-92
lines changed

libs/libvtrutil/src/vtr_memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace vtr {
1414
/**
1515
* @brief This function will force the container to be cleared
1616
*
17-
* It release it's held memory.
17+
* It release its held memory.
1818
* For efficiency, STL containers usually don't
1919
* release their actual heap-allocated memory until
2020
* destruction (even if Container::clear() is called).

vpr/src/place/net_cost_handler.cpp

Lines changed: 41 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -106,34 +106,17 @@ struct PLNetCost {
106106

107107
/* The following arrays are used by the try_swap function for speed. */
108108

109-
/**
110-
* @brief The wire length estimation is based on the bounding box of the net. In the case of the 2D architecture,
111-
* we use a 3D BB with the z-dimension (layer) set to 1. In the case of 3D architecture, there 2 types of bounding box:
112-
* 3D and per-layer. The type is determined at the beginning of the placement and stored in the placement context.
113-
* If the bonding box is of the type 3D, ts_bb_coord_new and ts_bb_edge_new are used. Otherwise, layer_ts_bb_edge_new and
114-
* layer_ts_bb_coord_new are used.
115-
*/
116109

117-
struct TSInfo {
118-
/* [0...cluster_ctx.clb_nlist.nets().size()-1] -> 3D bounding box*/
119-
vtr::vector<ClusterNetId, t_bb> ts_bb_coord_new, ts_bb_edge_new;
120-
/* [0...cluster_ctx.clb_nlist.nets().size()-1][0...num_layers-1] -> 2D bonding box on a layer*/
121-
vtr::vector<ClusterNetId, std::vector<t_2D_bb>> layer_ts_bb_edge_new, layer_ts_bb_coord_new;
122-
/* [0...cluster_ctx.clb_nlist.nets().size()-1][0...num_layers-1] -> number of sink pins on a layer*/
123-
vtr::Matrix<int> ts_layer_sink_pin_count;
124-
/* [0...num_afftected_nets] -> net_id of the affected nets */
125-
std::vector<ClusterNetId> ts_nets_to_update;
126-
// TSInfo(const TSInfo&) = delete;
127-
// TSInfo(TSInfo&&) = delete;
128-
};
110+
111+
//struct TSInfo {
112+
//
113+
//};
129114

130115

131116
} // namespace
132117

133118
static struct PLNetCost pl_net_cost;
134119

135-
static struct TSInfo ts_info;
136-
137120

138121
/**
139122
* @param net
@@ -143,17 +126,6 @@ static struct TSInfo ts_info;
143126
static bool driven_by_moved_block(const ClusterNetId net,
144127
const std::vector<t_pl_moved_block>& moved_blocks);
145128

146-
147-
148-
149-
/**
150-
* @brief if "net" is not already stored as an affected net, add it in ts_nets_to_update.
151-
* @param net ID of a net affected by a move
152-
*/
153-
static void record_affected_net(const ClusterNetId net);
154-
155-
156-
157129
/**
158130
* @brief Given the per-layer BB, calculate the wire-length cost of the net on each layer
159131
* and return the sum of the costs
@@ -385,12 +357,12 @@ void NetCostHandler::update_td_delta_costs_(const PlaceDelayModel* delay_model,
385357
}
386358

387359
///@brief Record effected nets.
388-
static void record_affected_net(const ClusterNetId net) {
360+
void NetCostHandler::record_affected_net_(const ClusterNetId net) {
389361
/* Record effected nets. */
390362
if (pl_net_cost.proposed_net_cost[net] < 0.) {
391363
/* Net not marked yet. */
392-
VTR_ASSERT_SAFE(ts_info.ts_nets_to_update.size() < ts_info.ts_nets_to_update.capacity());
393-
ts_info.ts_nets_to_update.push_back(net);
364+
VTR_ASSERT_SAFE(ts_nets_to_update_.size() < ts_nets_to_update_.capacity());
365+
ts_nets_to_update_.push_back(net);
394366

395367
/* Flag to say we've marked this net. */
396368
pl_net_cost.proposed_net_cost[net] = 1.;
@@ -418,7 +390,7 @@ void NetCostHandler::update_net_info_on_pin_move_(const t_place_algorithm& place
418390
}
419391

420392
/* Record effected nets */
421-
record_affected_net(net_id);
393+
record_affected_net_(net_id);
422394

423395
/* Update the net bounding boxes. */
424396
update_net_bb_(net_id, blk_id, pin_id, moving_blk_inf);
@@ -1557,7 +1529,7 @@ static double wirelength_crossing_count(size_t fanout) {
15571529
}
15581530

15591531
void NetCostHandler::set_bb_delta_cost_(double& bb_delta_c) {
1560-
for (const ClusterNetId ts_net: ts_info.ts_nets_to_update) {
1532+
for (const ClusterNetId ts_net: ts_nets_to_update_) {
15611533
ClusterNetId net_id = ts_net;
15621534

15631535
pl_net_cost.proposed_net_cost[net_id] = get_net_cost_(net_id);
@@ -1576,7 +1548,7 @@ void NetCostHandler::find_affected_nets_and_update_costs(const t_place_algorithm
15761548
VTR_ASSERT_SAFE(timing_delta_c == 0.);
15771549
auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
15781550

1579-
ts_info.ts_nets_to_update.resize(0);
1551+
ts_nets_to_update_.resize(0);
15801552

15811553
/* Go through all the blocks moved. */
15821554
for (const auto& block : blocks_affected.moved_blocks) {
@@ -1693,13 +1665,13 @@ void NetCostHandler::update_move_nets() {
16931665
auto& cluster_ctx = g_vpr_ctx.clustering();
16941666
auto& place_move_ctx = placer_ctx_.mutable_move();
16951667

1696-
for (const ClusterNetId ts_net : ts_info.ts_nets_to_update) {
1668+
for (const ClusterNetId ts_net : ts_nets_to_update_) {
16971669
ClusterNetId net_id = ts_net;
16981670

16991671
set_ts_bb_coord_(net_id);
17001672

17011673
for (int layer_num = 0; layer_num < g_vpr_ctx.device().grid.get_num_layers(); layer_num++) {
1702-
place_move_ctx.num_sink_pin_layer[size_t(net_id)][layer_num] = ts_info.ts_layer_sink_pin_count[size_t(net_id)][layer_num];
1674+
place_move_ctx.num_sink_pin_layer[size_t(net_id)][layer_num] = ts_layer_sink_pin_count_[size_t(net_id)][layer_num];
17031675
}
17041676

17051677
if (cluster_ctx.clb_nlist.net_sinks(net_id).size() >= SMALL_NET) {
@@ -1716,7 +1688,7 @@ void NetCostHandler::update_move_nets() {
17161688

17171689
void NetCostHandler::reset_move_nets() {
17181690
/* Reset the net cost function flags first. */
1719-
for (const ClusterNetId ts_net : ts_info.ts_nets_to_update) {
1691+
for (const ClusterNetId ts_net : ts_nets_to_update_) {
17201692
ClusterNetId net_id = ts_net;
17211693
pl_net_cost.proposed_net_cost[net_id] = -1;
17221694
pl_net_cost.bb_update_status[net_id] = NetUpdateState::NOT_UPDATED_YET;
@@ -1897,12 +1869,12 @@ void NetCostHandler::free_place_move_structs() {
18971869
}
18981870

18991871
void NetCostHandler::free_try_swap_net_cost_structs() {
1900-
vtr::release_memory(ts_info.ts_bb_edge_new);
1901-
vtr::release_memory(ts_info.ts_bb_coord_new);
1902-
vtr::release_memory(ts_info.layer_ts_bb_edge_new);
1903-
vtr::release_memory(ts_info.layer_ts_bb_coord_new);
1904-
ts_info.ts_layer_sink_pin_count.clear();
1905-
vtr::release_memory(ts_info.ts_nets_to_update);
1872+
vtr::release_memory(ts_bb_edge_new_);
1873+
vtr::release_memory(ts_bb_coord_new_);
1874+
vtr::release_memory(layer_ts_bb_edge_new_);
1875+
vtr::release_memory(layer_ts_bb_coord_new_);
1876+
ts_layer_sink_pin_count_.clear();
1877+
vtr::release_memory(ts_nets_to_update_);
19061878
}
19071879

19081880
NetCostHandler::NetCostHandler(PlacerContext& placer_ctx, size_t num_nets, bool cube_bb, float place_cost_exp)
@@ -1912,19 +1884,19 @@ NetCostHandler::NetCostHandler(PlacerContext& placer_ctx, size_t num_nets, bool
19121884

19131885
// Either 3D BB or per layer BB data structure are used, not both.
19141886
if (cube_bb_) {
1915-
ts_info.ts_bb_edge_new.resize(num_nets, t_bb());
1916-
ts_info.ts_bb_coord_new.resize(num_nets, t_bb());
1887+
ts_bb_edge_new_.resize(num_nets, t_bb());
1888+
ts_bb_coord_new_.resize(num_nets, t_bb());
19171889
comp_bb_cost_functor_ = std::bind(&NetCostHandler::comp_3d_bb_cost_, this, std::placeholders::_1);
19181890
} else {
1919-
ts_info.layer_ts_bb_edge_new.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
1920-
ts_info.layer_ts_bb_coord_new.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
1891+
layer_ts_bb_edge_new_.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
1892+
layer_ts_bb_coord_new_.resize(num_nets, std::vector<t_2D_bb>(num_layers, t_2D_bb()));
19211893
comp_bb_cost_functor_ = std::bind(&NetCostHandler::comp_per_layer_bb_cost_, this, std::placeholders::_1);
19221894
}
19231895

19241896
/* This initializes the whole matrix to OPEN which is an invalid value*/
1925-
ts_info.ts_layer_sink_pin_count.resize({num_nets, size_t(num_layers)}, OPEN);
1897+
ts_layer_sink_pin_count_.resize({num_nets, size_t(num_layers)}, OPEN);
19261898

1927-
ts_info.ts_nets_to_update.resize(num_nets, ClusterNetId::INVALID());
1899+
ts_nets_to_update_.resize(num_nets, ClusterNetId::INVALID());
19281900

19291901
pl_net_cost.net_cost.resize(num_nets, -1.);
19301902
pl_net_cost.proposed_net_cost.resize(num_nets, -1.);
@@ -1940,31 +1912,31 @@ NetCostHandler::NetCostHandler(PlacerContext& placer_ctx, size_t num_nets, bool
19401912
void NetCostHandler::get_non_updatable_bb_(const ClusterNetId net) {
19411913
if (cube_bb_) {
19421914
get_non_updatable_bb_(net,
1943-
ts_info.ts_bb_coord_new[net],
1944-
ts_info.ts_layer_sink_pin_count[size_t(net)]);
1915+
ts_bb_coord_new_[net],
1916+
ts_layer_sink_pin_count_[size_t(net)]);
19451917
}
19461918
else {
19471919
get_non_updatable_layer_bb_(net,
1948-
ts_info.layer_ts_bb_coord_new[net],
1949-
ts_info.ts_layer_sink_pin_count[size_t(net)]);
1920+
layer_ts_bb_coord_new_[net],
1921+
ts_layer_sink_pin_count_[size_t(net)]);
19501922
}
19511923
}
19521924

19531925
void NetCostHandler::update_bb_(ClusterNetId net_id, t_physical_tile_loc pin_old_loc, t_physical_tile_loc pin_new_loc, bool is_driver) {
19541926
if (cube_bb_) {
19551927
update_bb_(net_id,
1956-
ts_info.ts_bb_edge_new[net_id],
1957-
ts_info.ts_bb_coord_new[net_id],
1958-
ts_info.ts_layer_sink_pin_count[size_t(net_id)],
1928+
ts_bb_edge_new_[net_id],
1929+
ts_bb_coord_new_[net_id],
1930+
ts_layer_sink_pin_count_[size_t(net_id)],
19591931
pin_old_loc,
19601932
pin_new_loc,
19611933
is_driver);
19621934
}
19631935
else {
19641936
update_layer_bb_(net_id,
1965-
ts_info.layer_ts_bb_edge_new[net_id],
1966-
ts_info.layer_ts_bb_coord_new[net_id],
1967-
ts_info.ts_layer_sink_pin_count[size_t(net_id)],
1937+
layer_ts_bb_edge_new_[net_id],
1938+
layer_ts_bb_coord_new_[net_id],
1939+
ts_layer_sink_pin_count_[size_t(net_id)],
19681940
pin_old_loc,
19691941
pin_new_loc,
19701942
is_driver);
@@ -1973,27 +1945,27 @@ void NetCostHandler::update_bb_(ClusterNetId net_id, t_physical_tile_loc pin_old
19731945

19741946
double NetCostHandler::get_net_cost_(const ClusterNetId net_id) {
19751947
if (cube_bb_) {
1976-
return ::get_net_cost(net_id, ts_info.ts_bb_coord_new[net_id]);
1948+
return ::get_net_cost(net_id, ts_bb_coord_new_[net_id]);
19771949
}
19781950
else {
1979-
return ::get_net_layer_bb_wire_cost(net_id, ts_info.layer_ts_bb_coord_new[net_id], ts_info.ts_layer_sink_pin_count[size_t(net_id)]);
1951+
return ::get_net_layer_bb_wire_cost(net_id, layer_ts_bb_coord_new_[net_id], ts_layer_sink_pin_count_[size_t(net_id)]);
19801952
}
19811953
}
19821954

19831955
void NetCostHandler::set_ts_bb_coord_(const ClusterNetId net_id) {
19841956
auto& place_move_ctx = placer_ctx_.mutable_move();
19851957
if (cube_bb_) {
1986-
place_move_ctx.bb_coords[net_id] = ts_info.ts_bb_coord_new[net_id];
1958+
place_move_ctx.bb_coords[net_id] = ts_bb_coord_new_[net_id];
19871959
} else {
1988-
place_move_ctx.layer_bb_coords[net_id] = ts_info.layer_ts_bb_coord_new[net_id];
1960+
place_move_ctx.layer_bb_coords[net_id] = layer_ts_bb_coord_new_[net_id];
19891961
}
19901962
}
19911963

19921964
void NetCostHandler::set_ts_edge_(const ClusterNetId net_id) {
19931965
auto& place_move_ctx = placer_ctx_.mutable_move();
19941966
if (cube_bb_) {
1995-
place_move_ctx.bb_num_on_edges[net_id] = ts_info.ts_bb_edge_new[net_id];
1967+
place_move_ctx.bb_num_on_edges[net_id] = ts_bb_edge_new_[net_id];
19961968
} else {
1997-
place_move_ctx.layer_bb_num_on_edges[net_id] = ts_info.layer_ts_bb_edge_new[net_id];
1969+
place_move_ctx.layer_bb_num_on_edges[net_id] = layer_ts_bb_edge_new_[net_id];
19981970
}
19991971
}

vpr/src/place/net_cost_handler.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,34 +130,29 @@ class NetCostHandler {
130130
*/
131131
void free_try_swap_net_cost_structs();
132132

133-
// private:
134-
/**
135-
* @brief This class is used to hide control flows needed to distinguish 2d and 3d placement
136-
*/
137-
// class BBUpdater {
138-
// public:
139-
// BBUpdater() = delete;
140-
// BBUpdater(const BBUpdater&) = delete;
141-
// BBUpdater(BBUpdater&&) = delete;
142-
// BBUpdater& operator=(const BBUpdater&) = delete;
143-
// BBUpdater& operator=(BBUpdater&&) = delete;
144-
//
145-
// BBUpdater(PlacerContext& placer_ctx_, size_t num_nets, bool cube_bb);
146-
//
147-
// private:
148-
//
149-
// PlacerContext& placer_ctx_;
150-
//
151-
// public:
152-
//
153-
// };
154-
155133
private:
156134
bool cube_bb_ = false;
157135
PlacerContext& placer_ctx_;
158136

159137
std::function<double(e_cost_methods method)> comp_bb_cost_functor_;
160138

139+
140+
/**
141+
* @brief The wire length estimation is based on the bounding box of the net. In the case of the 2D architecture,
142+
* we use a 3D BB with the z-dimension (layer) set to 1. In the case of 3D architecture, there 2 types of bounding box:
143+
* 3D and per-layer. The type is determined at the beginning of the placement and stored in the placement context.
144+
* If the bonding box is of the type 3D, ts_bb_coord_new and ts_bb_edge_new are used. Otherwise, layer_ts_bb_edge_new and
145+
* layer_ts_bb_coord_new are used.
146+
*/
147+
/* [0...cluster_ctx.clb_nlist.nets().size()-1] -> 3D bounding box*/
148+
vtr::vector<ClusterNetId, t_bb> ts_bb_coord_new_, ts_bb_edge_new_;
149+
/* [0...cluster_ctx.clb_nlist.nets().size()-1][0...num_layers-1] -> 2D bonding box on a layer*/
150+
vtr::vector<ClusterNetId, std::vector<t_2D_bb>> layer_ts_bb_edge_new_, layer_ts_bb_coord_new_;
151+
/* [0...cluster_ctx.clb_nlist.nets().size()-1][0...num_layers-1] -> number of sink pins on a layer*/
152+
vtr::Matrix<int> ts_layer_sink_pin_count_;
153+
/* [0...num_afftected_nets] -> net_id of the affected nets */
154+
std::vector<ClusterNetId> ts_nets_to_update_;
155+
161156
private:
162157
/**
163158
* @brief Update the bounding box (3D) of the net connected to blk_pin. The old and new locations of the pin are
@@ -407,4 +402,10 @@ class NetCostHandler {
407402
double comp_per_layer_bb_cost_(e_cost_methods method);
408403
double comp_3d_bb_cost_(e_cost_methods method);
409404

405+
/**
406+
* @brief if "net" is not already stored as an affected net, add it in ts_nets_to_update.
407+
* @param net ID of a net affected by a move
408+
*/
409+
void record_affected_net_(const ClusterNetId net);
410+
410411
};

0 commit comments

Comments
 (0)